相关疑难解决方法(0)

将输入流式传输到System.Speech.Recognition.SpeechRecognitionEngine

我试图从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()与麦克风一起工作正常.

谢谢,肖恩

c# sockets streaming speech-recognition sapi

8
推荐指数
2
解决办法
7398
查看次数

帮助SAPI v5.1 SpeechRecognitionEngine始终使用C#提供相同的错误结果

我正在玩这个SAPI v5.1库.所以我正在测试我的样本WAV文件.(从这里下载).无论如何,该文件中的声音清晰简单.它只包含一个单词,即第三个单词.现在,当我运行以下代码时,我得到数字8或"8".如果我删除它,我得到7.如果我尝试随机化列表我得到不同的结果,依此类推.我真的很困惑,开始认为SAPI库中的SpeachRecognition根本不起作用......

无论如何这里是我正在做的,

    private void button1_Click(object sender, EventArgs e)
    {
        //Add choices to grammar.
        Choices mychoices = new Choices();
        mychoices.Add("one");
        mychoices.Add("two");
        mychoices.Add("three");
        mychoices.Add("four");
        mychoices.Add("five");
        mychoices.Add("six");
        mychoices.Add("seven");
        mychoices.Add("eight");
        mychoices.Add("nine");
        mychoices.Add("zero");
        mychoices.Add("1");
        mychoices.Add("2");
        mychoices.Add("3");
        mychoices.Add("4");
        mychoices.Add("5");
        mychoices.Add("6");
        mychoices.Add("7");
        mychoices.Add("8");
        mychoices.Add("9");
        mychoices.Add("0");

        Grammar myGrammar = new Grammar(new GrammarBuilder(mychoices));

        //Create the engine.
        SpeechRecognitionEngine reco = new SpeechRecognitionEngine();

        //Read audio stream from wav file.
        reco.SetInputToWaveFile("3.wav");
        reco.LoadGrammar(myGrammar);

        //Get the recognized value.
        reco.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(reco_SpeechRecognized);

        reco.RecognizeAsync(RecognizeMode.Multiple);
    }

    void reco_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
    {
        MessageBox.Show(e.Result.Text); …
Run Code Online (Sandbox Code Playgroud)

c# speech-recognition sapi

3
推荐指数
1
解决办法
2526
查看次数

标签 统计

c# ×2

sapi ×2

speech-recognition ×2

sockets ×1

streaming ×1