【发布时间】:2010-12-13 13:33:28
【问题描述】:
我正在尝试通过 TCP 套接字在 C# 中进行“流式”语音识别。我遇到的问题是 SpeechRecognitionEngine.SetInputToAudioStream() 似乎需要一个可以寻找的定义长度的流。现在我能想到的唯一方法是随着更多输入的进入,在 MemoryStream 上重复运行识别器。
这里有一些代码来说明:
SpeechRecognitionEngine appRecognizer = new SpeechRecognitionEngine();
System.Speech.AudioFormat.SpeechAudioFormatInfo formatInfo = new System.Speech.AudioFormat.SpeechAudioFormatInfo(8000, System.Speech.AudioFormat.AudioBitsPerSample.Sixteen, System.Speech.AudioFormat.AudioChannel.Mono);
NetworkStream stream = new NetworkStream(socket,true);
appRecognizer.SetInputToAudioStream(stream, formatInfo);
// At the line above a "NotSupportedException" complaining that "This stream does not support seek operations."
有谁知道如何解决这个问题?它必须支持某种类型的流式输入,因为它可以很好地与使用 SetInputToDefaultAudioDevice() 的麦克风配合使用。
谢谢,肖恩
【问题讨论】:
-
也许
SetInputToDefaultAudioDevice()是微软的“黑魔法”(常见),或者它执行某种批处理,如您所建议的。
标签: c# sockets streaming speech-recognition sapi