我正在尝试从 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() 的麦克风一起正常工作。
谢谢,肖恩