Watson speech to text returns strange error regarding file size
Asked Answered
P

2

8

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

Potpourri answered 30/7, 2018 at 4:25 Comment(0)
C
11

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
Classroom answered 30/7, 2018 at 5:37 Comment(8)
Sorry for the late reply. I've tried every form of appending the @ Before quotes, after quotes, and without quotes. All returns say that 0 bytes were read.Potpourri
@O'Doherty which means it's not finding my file. I can only swear that I am in the directory where the file exists, So maybe I have the formatting of the command wrong?Potpourri
Do 'curl --help' to find the command. I tested on OSX and it works. You can change your file name to see the error change.Devaluation
@O'Doherty Thinking maybe I have to look at apache and UFW ports on serverPotpourri
I used the output option and got the following result. Am I somehow being denied permission on the Watson side? ** % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0Warning: Failed to create the file output: Permission denied 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 curl: (23) Failed writing body (0 != 128)**Potpourri
xxxxxxxxxx-:yyyyyyyy should not have a - sign in it. Otherwise check your service credentials and end point URL.Devaluation
that was just me deleting my real username and password.Potpourri
@siminO'doherty It's the rights of the directory. I tried it as "su" and it worked. Can I ask what the permissions to set the directory to?Potpourri
A
0

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

Ammonite answered 18/4, 2021 at 1:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.