我试图从TCP套接字在C#中进行"流式"语音识别.我遇到的问题是SpeechRecognitionEngine.SetInputToAudioStream()似乎需要一个可以寻找的定义长度的Stream.现在,我能想到的唯一方法就是在更多输入进来时在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."
Run Code Online (Sandbox Code Playgroud)
有谁知道怎么解决这个问题?它必须支持某种类型的流输入,因为它使用SetInputToDefaultAudioDevice()与麦克风一起工作正常.
谢谢,肖恩