2

I'm trying to convert this curl command from the Kaldi docs:

curl -v -T test/data/english_test.raw -H "Content-Type: audio/x-raw-int; rate=16000" --header "Transfer-Encoding: chunked" --limit-rate 32000  "http://localhost:8888/client/dynamic/recognize"

To JS code, specifically fetch. I'm able to POST a binary file using fetch pretty easily but specifically what I need to do is use chunked transfer encoding. To the life of me I can't find any docs on this, and as far as I know in JS, it's really up to the user agent to set the transfer encoding. Would appreciate any pointers!

4
  • 2
    I don't think Fetch gives you this level of control. Commented May 22, 2019 at 20:27
  • See stackoverflow.com/a/49211413/441757 Commented May 22, 2019 at 22:52
  • @sideshowbarker so there's a lot on consuming the data but I'm not worried about the response (the response only comes in the last chunk to begin with so it suffices to treat it as a normal response), specifically I need to send the request body in chunks Commented May 23, 2019 at 1:04
  • 1
    Ah OK then maybe see stackoverflow.com/questions/40939857/… and github.com/whatwg/fetch/pull/425. So the Fetch spec provides a way to do this (create a request from a Request made from a ReadableStream), but unfortunately, I don’t think any browsers have shipped it yet. Commented May 23, 2019 at 2:45

1 Answer 1

0

this is your js fetch req :

fetch('http://localhost:8888/client/dynamic/recognize', {
  method: 'PUT',
  headers: {
    'Content-Type': 'audio/x-raw-int; rate=16000',
    'Transfer-Encoding': 'chunked'
  },
  body: File(['<data goes here>'], 'test/data/english_test.raw')
});

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.