【发布时间】:2016-12-13 08:36:48
【问题描述】:
我们目前正在实时流媒体场景中评估 Bing 语音识别服务。我们正在获取 PCM 编码音频的实时流(16k 采样率、16 位、1 通道(又名单声道))并尝试将其发送到 Bing 语音识别服务。
我们已经成功地将来自https://www.nuget.org/packages/Microsoft.ProjectOxford.SpeechRecognition-x64/ 的 DataRecognitionClient 用于我们的场景,方法是在流式传输音频之前发送音频格式,如下所示:
_dataRecognitionClient.SendAudioFormat(SpeechAudioFormat.create16BitPCMFormat(16000));
然后我们像这样在循环中流式传输音频流:
_dataRecognitionClient.SendAudio(buffer, bytesRead);
这很好用。但是我们假设 ProjectOxford 库可能会被弃用,因为官方 Bing 语音识别网站 (https://www.microsoft.com/cognitive-services/en-us/Speech-api/documentation/GetStarted/GetStartedCSharpServiceLibrary) 指向不同的 Nuget 包,请参阅:https://www.nuget.org/packages/Microsoft.Bing.Speech/
当我们使用此包中的 SpeechClient 时,在 SpeechClient 上执行 RecognizeAsync 时,我们看到提到的“无法解析音频格式”错误。
var speechInput = new SpeechInput(producerConsumerStream,
new RequestMetadata(Guid.NewGuid(), new DeviceMetadata(DeviceType.Near,
DeviceFamily.Desktop, NetworkType.Ethernet, OsName.Windows, "Azure",
"Microsoft", "Current"), new ApplicationMetadata("App", "1.0"), "Speech"));
await _speechClient.RecognizeAsync(speechInput, new CancellationToken());
最后一行抛出错误。我们假设这是因为我们的 PCM 流没有 WAVE/RIFF 标头,因为它是流式传输的。对于流式传输场景,DataRecognitionClient 具有“SendAudioFormat”方法。
SpeechClient 不支持流式场景吗?
【问题讨论】:
标签: c# audio speech-recognition bing pcm