【问题标题】:Microsoft Speech Platform speech to textMicrosoft Speech Platform 语音转文本
【发布时间】:2014-12-16 22:17:25
【问题描述】:

我想写一个用户对文本说的演讲。我可以使用 Microsoft 语音平台执行此操作吗?也许我只是误解了它应该如何工作以及它的预期用例是什么。

我现在有了这个控制台应用程序:

static void Main(string[] args)
        {
            Choices words = new Choices();
            words.Add(new string[] { "test", "hello" ,"blah"});
            GrammarBuilder gb = new GrammarBuilder();
            gb.Append(words);
            Grammar g = new Grammar(gb);

            SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US"));
            sre.LoadGrammar(g);
            sre.SetInputToDefaultAudioDevice();

            //add listeners

            sre.Recognize();
            Console.ReadLine();
        }

而且它似乎只输出我在Choices 中指定的单词。

如果我想匹配(大部分)用户会说的话,我是否必须添加整个词典?

此外,它在匹配单个单词后立即停止。如果我想捕捉整个句子怎么办?

我正在寻找 A) 捕获大量单词和 B) 一次捕获多个单词的解决方案。

编辑:

我发现了这个:http://www.codeproject.com/Articles/483347/Speech-recognition-speech-to-text-text-to-speech-a#torecognizeallspeech

【问题讨论】:

    标签: c# microsoft-speech-platform


    【解决方案1】:

    如this page 中所见,DictationGrammar 类有一个基本的常用词库。

    为了一次捕捉多个单词,我做到了

     sre.RecognizeAsync(RecognizeMode.Multiple);
    

    所以我的代码现在是这样的:

        public static SpeechRecognitionEngine sre;
        static void Main(string[] args)
        {
            sre = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US"));
            sre.LoadGrammar(new Grammar(new GrammarBuilder("exit")));
            sre.LoadGrammar(new DictationGrammar());
            sre.SetInputToDefaultAudioDevice();
    
            sre.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
    
            Console.ReadLine();
        }
    
    
        private static void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            if (e.Result.Text == "exit")
            {
                sre.RecognizeAsyncStop();
            }
            Console.WriteLine("You said: " + e.Result.Text);
        }
    

    【讨论】:

      猜你喜欢
      • 2018-11-20
      • 2017-02-11
      • 2021-08-20
      • 2020-01-27
      • 2014-12-19
      • 1970-01-01
      • 1970-01-01
      • 2021-07-01
      • 2019-09-20
      相关资源
      最近更新 更多