Closed birkanu closed 8 years ago
I also tried a flac file, but that did not work either.
Unfortunately, trying to transcript using HTTP or a WebSocket also fails with the same error.
When calling the recognize you need to specify the audio format and it should be a valid media type.
I just tested the example below and it's working:
final SpeechToText service = new SpeechToText();
service.setUsernameAndPassword("<username>", "<password>");
final File audio = new File("src/test/resources/sample1.wav");
final SpeechResults transcript = service.recognize(audio, HttpMediaType.AUDIO_WAV);
System.out.println(transcript);
Make sure that you send a valid contentType
link audio/wav
It's interesting because I used the exact same example with sample1.wav file, and I got the error I mentioned above. However, the same file worked when I used it in a cURL command.
So the request never gets to the server because the contentType
is incorrect. Try to use the example I pasted above and let me know if it doesn't work.
I've opened an issue (#135) to recognize the content type automatically based on the file extension.
The example works now. Turns out the path for my wav
file was incorrect.
@germanattanasio: Can we detect InputStreams that represent missing files and give a more useful error message?
we are returning "audio is not a valid audio file". I guess I could say "file not found"
what about "audio file is null or does not exist"
The point would be to have two separate error messages, assuming we can differentiate between them.
i don't know why you are keeping it to show "audio is not a valid audio file" you can separate messages
@gamal-ahmed I'm doing 2 checks.
.wav
, .flac
, etc..
Hi,
I am trying to run SpeechToTextExample.java with the sample wav file you provide. However, I have been getting the following error:
Does anyone know why this might be happening?
Thanks!