Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Watson speech to text returns strange error regarding file size

Just started to play with Watson's Voice API. Trying to use their demo file audio-file.flac. You'd have to take my word for it that I'm posting the curl command from the directory where it resides, and that according to the ls-l command the file size is 285928 bytes.

This is my post

curl -X POST -u xxxxxxxxxx-:yyyyyyyy --header "Content-Type: audio/flac" --data-binary "audio-file.flac" "https://stream.watsonplatform.net/speech-to-text/api/v1/recognize"

and I get back

{ "code_description": "Bad Request", "code": 400, "error": "Stream was 15 bytes but needs to be at least 100 bytes." }

It's the stream size that makes wonder. I have a great internet connection, and no matter how many times I try it comes back as 15. If I change the filename to an incorrect name it reports back as 0. So where is this 15 coming from?

Anyone have any experience with this?

Thanks

like image 295
Daniel Kaplan Avatar asked Jul 30 '18 04:07

Daniel Kaplan


1 Answers

The issue is here:

--data-binary "audio-file.flac"

You are telling the command line to send the 15 bytes of your filename as the content of your message. That's why it is failing.

Prepend the filename with an @ sign. Example:

--data-binary @audio-file.flac
like image 96
Simon O'Doherty Avatar answered Oct 16 '22 06:10

Simon O'Doherty