作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试对这样的 wav 文件进行语音识别:
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();
}
但我收到此错误:
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
第 14 行是
using (var recognizer = new SpeechRecognizer(config, AudioConfig.FromWavFileInput(@"/Full/Path/To/File.wav")))
行
我实际上如何在文件上使用语音服务?我让它在现场麦克风输入上工作。
我刚刚再次尝试使用不同格式的文件(WAV 文件、16 kHz 采样率、单声道),现在出现此错误:
libc++abi.dylib: terminating with uncaught exception of type
Microsoft::CognitiveServices::Speech::Impl::ExceptionWithCallStack: Exception with
an error code: 0xd (SPXERR_ABORT)
最佳答案
正如您所说 - 它似乎正在使用标准 WAV 文件......
I downloaded a wav file for the Internet and I was able to make it work with
您自制的 WAV 文件似乎不符合预期的 WAV 格式规范(WAV/PCM 16 位、16 kHz/8 kHz、单声道音频)?
沃尔夫冈
关于c# - 如何从文件中进行语音识别,System.ApplicationException 0xa SPXERR_INVALID_HEADER,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56647060/
我正在尝试对这样的 wav 文件进行语音识别: var config = SpeechConfig.FromSubscription("mykey", "myregion"); using (var
我正在尝试对这样的 wav 文件进行语音识别: var config = SpeechConfig.FromSubscription("mykey", "myregion"); using (var
使用 Microsoft Python Speech-to-Text Quickstart ("Quickstart: Recognize speech from an audio file") 时出
我是一名优秀的程序员,十分优秀!