Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
I am trying to speech recognise on a wav file like this:
var config = SpeechConfig.FromSubscription("mykey", "myregion");
using (var recognizer = new SpeechRecognizer(config, AudioConfig.FromWavFileInput(@"/Full/Path/To/File.wav")))
recognizer.Recognized += (s, e) =>
if (e.Result.Reason == ResultReason.RecognizedSpeech)
Console.WriteLine(e.Result.Text);
await recognizer.StartContinuousRecognitionAsync();
But I am getting this error:
Unhandled Exception: System.AggregateException: One or more errors occurred. (Exception with an error code: 0xa (SPXERR_INVALID_HEADER)) ---> System.ApplicationException: Exception with an error code: 0xa (SPXERR_INVALID_HEADER)
at Microsoft.CognitiveServices.Speech.Internal.SpxExceptionThrower.ThrowIfFail(IntPtr hr)
at Microsoft.CognitiveServices.Speech.Recognizer.FromConfig(GetRecognizerFromConfigDelegate fromConfig, SpeechConfig speechConfig, AudioConfig audioConfig)
at Microsoft.CognitiveServices.Speech.SpeechRecognizer..ctor(SpeechConfig speechConfig, AudioConfig audioConfig)
at mynamespace.Program.RecognizeSpeechAsync() in Program.cs:line 14
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at mynamespace.Program.Main() in Program.cs:line 46
line 14 is the
using (var recognizer = new SpeechRecognizer(config, AudioConfig.FromWavFileInput(@"/Full/Path/To/File.wav")))
How am I actually meant to use the speech service on a file? I got it working on live mic input.
I just tried again with a file formatted differently (WAV file, 16 kHz sampling rate, mono) and I now get this error:
libc++abi.dylib: terminating with uncaught exception of type
Microsoft::CognitiveServices::Speech::Impl::ExceptionWithCallStack: Exception with
an error code: 0xd (SPXERR_ABORT)
–
–
It looks like your home-created WAV file isn't following the expected WAV format specification (WAV/PCM 16-bit, 16 kHz/8 kHz, single-channel audio)?
Wolfgang
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.