【问题标题】:How to recognize words which are not in the grammar如何识别语法中没有的单词
【发布时间】:2016-01-29 07:12:29
【问题描述】:

我正在尝试使用 c#(windows form) 制作语音识别应用程序。

这是我正在使用的代码

//recognizing speech
SpeechRecognitionEngine r = new SpeechRecognitionEngine();
//then load the grammar
r.LoadGrammar(new Grammar(new GrammarBuilder
        (new Choices("hello","how are you","nice to meet you")))
        { Name = "speechGrammar" });

r.SetInputToDefaultAudioDevice(); // set the input of the speech recognizer to the default audio device
r.RecognizeAsync(RecognizeMode.Multiple); // recognize speech asynchronous

//adding a event handler
r.SpeechRecognized += r_SpeechRecognized;
//then create a method for that

void r_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
    if (e.Result.Text == "test") // e.Result.Text contains the recognized text
    {
        SpeechSynthesizer s = new SpeechSynthesizer();
        s.Speak("hello");
        MessageBox.Show("Hi User");
        s.Dispose();
    } 
} 

所以我希望程序将文本框的文本更改为说出但不在语法中的单词/短语。

send a mail to xyz 该句子不在语法列表中 所以当它被说出来时,我想要

textbox1.text = spokenword;

我应该对此结果的代码进行哪些更改。

【问题讨论】:

  • 如果您特别想要无法识别的文本,那么SpeechRecognized 事件不是您所需要的。其他活动可用..?
  • @stuartd 我想要计算机听到但语法列表中不存在的文本。那我应该使用哪个事件
  • @stuard 我应该使用哪个事件??

标签: c# winforms speech-recognition


【解决方案1】:

您无法识别语法中没有的单词。你只需要制作更大的语法。如果您想识别任意文本,您可以使用 DictationGrammar,它应该涵盖大部分单词。

识别出文本后,您可以将其分配给文本框:

 textbox1.text = e.Result.Text;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-28
    • 1970-01-01
    • 2012-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多