Daniel Kaplan
Daniel Kaplan

Reputation: 721

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

Upvotes: 8

Views: 2351

Answers (2)

karique
karique

Reputation: 538

In addition to Simon O'Doherty response my first problem was that i didn't set the @ but after fixing that i got the message:

"Stream was 0 bytes but needs to be at least 100 bytes."

And after some research i notice that my error was that i was using \ instead of / so i change that and it worked.

My final route was something like:

--data-binary @C:/Users/KARIQUE/Desktop/example.mp3

Pd: my OS is windows

Upvotes: 0

Simon O'Doherty
Simon O'Doherty

Reputation: 9359

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

Upvotes: 11

Related Questions