Say something...
CANCELLED: Reason=Error
CANCELED: ErrorCode=RuntimeError
CANCELED: ErrorDetails=0x15 (SPXERR_MIC_ERROR)
[CALL STACK BEGIN]
3 libMicrosoft.CognitiveServices.Speech.core.dylib 0x000000011e6e8b5b CreateModuleObject + 779307
4 libMicrosoft.CognitiveServices.Speech.core.dylib 0x000000011e6ea880 CreateModuleObject + 786768
5 libMicrosoft.CognitiveServices.Speech.core.dylib 0x000000011e64016d CreateModuleObject + 88637
6 libMicrosoft.CognitiveServices.Speech.core.dylib 0x000000011e63e673 CreateModuleObject + 81731
7 libMicrosoft.CognitiveServices.Speech.core.dylib 0x000000011e63dfd2 CreateModuleObject + 80034
8 libMicrosoft.CognitiveServices.Speech.core.dylib 0x000000011e65218b CreateModuleObject + 162395
9 libMicrosoft.CognitiveServices.Speech.core.dylib 0x000000011e6ad5e6 CreateModuleObject + 536246
10 libMicrosoft.CognitiveServices.Speech.core.dylib 0x000000011e6ad350 CreateModuleObject + 535584
11 libMicrosoft.CognitiveServices.Speech.core.dylib 0x000000011e6adb48 CreateModuleObject + 537624
12 libMicrosoft.CognitiveServices.Speech.core.dylib 0x000000011e6afba8 CreateModuleObject + 545912
13 libsystem_pthread.dylib 0x00007fff7eb1d2eb _pthread_body + 126
14 libsystem_pthread.dylib 0x00007fff7eb20249 _pthread_start + 66
15 libsystem_pthread.dylib 0x00007fff7eb1c40d thread_start + 13
[CALL STACK END]
CANCELED: Did you update the subscription info?
Recognition done. Your choice (0: Stop):
Can someone shed some light on this please?
Hi @asurjit79 - do you have a microphone connected to your Mac?
Could you try whether recognition from file works for you?
(For example, menu option 4, but please make sure to update to subscription key, region, and filename, cf. here -- https://github.com/Azure-Samples/cognitive-services-speech-sdk/blob/master/samples/java/jre/console/src/com/microsoft/cognitiveservices/speech/samples/console/SpeechRecognitionSamples.java#L155-L159)
Sure @mabasile-MSFT. I tried with option 4 and I am still getting the below exception
Your choice (0: Stop): 4
Unexpected java.lang.RuntimeException: Exception with an error code: 0x8 (SPXERR_FILE_OPEN_FAILED)
[CALL STACK BEGIN]
3 libMicrosoft.CognitiveServices.Speech.core.dylib 0x00000001053f1078 CreateModuleObject + 792904
4 libMicrosoft.CognitiveServices.Speech.core.dylib 0x00000001053ee963 CreateModuleObject + 782899
5 libMicrosoft.CognitiveServices.Speech.core.dylib 0x00000001053eefd5 CreateModuleObject + 784549
6 libMicrosoft.CognitiveServices.Speech.core.dylib 0x000000010533e3eb CreateModuleObject + 60603
SpeechConfig config = SpeechConfig.fromSubscription("xxxxxxxxx", "westus");
AudioConfig audioInput = AudioConfig.fromWavFileInput("/cognitive-services-speech-sdk/resources/YourAudioFile.wav");
I tried multiple different locations -
/cognitive-services-speech-sdk/resources/YourAudioFile.wav
./resources/YourAudioFile.wav
YourAudioFile.wav
But the error is still the same.
Hey @asurjit79 - you'll need to update YourAudioFile.wav to an audio file on your disk (WAV, single channel, 16-bit samples). For example, if you've downloaded all of the samples, you should find this .wav file: samples/csharp/sharedcontent/console/whatstheweatherlike.wav Can you try using this path (as an absolute path)?
Hmmm...the error is gone after giving the absolute path from the file system. I put the .wav file under resources folder as part of my project but it seems to be looking for local file system path :)
Finally, able to see this code working now. I will be trying out authentication using now!
Closing as issues seems resolved, let us know if there is more information needed.
Hola, la soluci贸n tambi茅n puede ser el codec, el error me salia debido a que enviaba un archivo convetido de formato MP4 a wav utilizando un codec no soportado por Speech to text, convert铆 el archivo utilizando el codec pcm_s16le y funcion贸. Eso de la ruta absoluta no es necesariamente el problema, yo utilizo rutas relativas y funciona. Hello, the solution may be the codec, the error was because when I sent a converted file from mp4 format to wav using a codec not supported by Azure Speech to text. The solution was converted the file using the pcm_s16le codec with the following parameters:
// Audio Attributes
AudioAttributes audio = new AudioAttributes();
audio.setCodec("pcm_s16le");
audio.setBitRate(256000);
audio.setChannels(1);
audio.setSamplingRate(16000);
and it worked. The absolute path is not necessarily the problem, in a Spring web app I use relative paths and it work fine.
You will use a online converter with support ffmpeg to test it.
This issue is closed but if anyone else is facing this issue, the right way to this in Java with maven is to resolve the file path dynamically like so:
Assume you have a file called audio.wav in your src/main/resources folder.
Build the project using standard maven command and then use this snippet in your code to correctly load the file.
// Get the file path
URL resource = FileVoiceRecognition.class.getResource("/audio.wav");
File file = Paths.get(resource.toURI()).toFile();
String absolutePath = file.getAbsolutePath();
// now init AudiConfig
AudioConfig audioConfig = AudioConfig.fromWavFileInput(absolutePath);
// and pass the audioConfig to SpeechRecognizer
SpeechRecognizer reco = new SpeechRecognizer(config, audioConfig);
Most helpful comment
This issue is closed but if anyone else is facing this issue, the right way to this in Java with
mavenis to resolve the file path dynamically like so:Assume you have a file called
audio.wavin yoursrc/main/resourcesfolder.Build the project using standard maven command and then use this snippet in your code to correctly load the file.