C#语音识别多字在一起吗? (认识一个句子) [英] C# Speech Recognizing Multiple Words together? (Recognize a sentence)

查看:231
本文介绍了C#语音识别多字在一起吗? (认识一个句子)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立识别从用户多个单词的申请;因此放在一起使用公认的词的句子



下面是我有截至目前:

 命名空间SentenceRecognitionFramework__v1_ 
{
公共部分Form1类:表格
{

SpeechRecognitionEngine RECOG =新SpeechRecognitionEngine();
SpeechSynthesizer SP =新SpeechSynthesizer();

公共Form1中()
{
的InitializeComponent();
}

私人无效btnListen_Click(对象发件人,EventArgs五)
{
选择SLIST =新的选择();
sList.Add(新的String [] {是什么,是,A,汽车});

语法克=新的语法(新GrammarBuilder(SLIST));

recog.RequestRecognizerUpdate();
recog.LoadGrammar(克);
recog.SpeechRecognized + = sRecognize_SpeechRecognized;
recog.SetInputToDefaultAudioDevice();
recog.RecognizeAsync(RecognizeMode.Multiple);
recog.SpeechRecognitionRejected + = sRecognize_SpeechRecognitionRejected;
}

私人无效sRecognize_SpeechRecognitionRejected(对象发件人,SpeechRecognitionRejectedEventArgs E)
{
sentenceBox.Text =对不起,我不认识;
}

私人无效sRecognize_SpeechRecognized(对象发件人,SpeechRecognizedEventArgs E)
{
sentenceBox.Text = e.Result.Text.ToString();
}
}
}



然而,这代码只会在一次识别一个单词。即使修改我的代码来做到这一点:



 私人无效sRecognize_SpeechRecognized(对象发件人,SpeechRecognizedEventArgs E)
{
sentenceBox.Text = sentenceBox.Text ++ e.Result.Text.ToString();
}



应用程序不能连续识别的单词时,我叫不出词是什么车的连续无需休息的时候我讲出来。



我能做出什么样的变化,为了使节目认识到使用已定义的那些话,建一个完整的句子,而不必有的讲话插入说出这句话的时候



输出要求:





我说出了一句:什么是汽车



应用程序显示:什么是汽车





完美的例子:谷歌语音识别谷歌开发使用可用的话在他们的单词库句子



感谢您能:)


解决方案

它认识到一个词,因为你不正确地构建语法。既然您已经构建了包括一个关键词是什么,是,A,汽车,它准确地识别的词汇之一。

$ B $选择的语法b

您可能想阅读引入语法和相关文档。



http://msdn.microsoft.com/en-us/library/hh378438(v = office.14)的.aspx



如果你想构建语法描述句话你可以只使用GrammarBuilder这样的:

 语法克=新的语法(新GrammarBuilder(什么是汽车)); 

这文法将识别的短语。



要了解的选择是如何工作的,你可以阅读选择文档:



http://msdn.microsoft.com/en-us/library/microsoft.speech.recognition.choices(v =办公室。 14)的.aspx


I'm building an application that recognizes multiple words from a user; thus putting together a sentence using the words recognized.

Here's what I have as of now:

namespace SentenceRecognitionFramework__v1_
{
    public partial class Form1 : Form
    {

        SpeechRecognitionEngine recog = new SpeechRecognitionEngine();
        SpeechSynthesizer sp = new SpeechSynthesizer();

        public Form1()
        {
            InitializeComponent();
        }

        private void btnListen_Click(object sender, EventArgs e)
        {
            Choices sList = new Choices();
            sList.Add(new String[] { "what","is", "a", "car" });

            Grammar gr = new Grammar(new GrammarBuilder(sList));

            recog.RequestRecognizerUpdate();
            recog.LoadGrammar(gr);
            recog.SpeechRecognized += sRecognize_SpeechRecognized;
            recog.SetInputToDefaultAudioDevice();
            recog.RecognizeAsync(RecognizeMode.Multiple);
            recog.SpeechRecognitionRejected += sRecognize_SpeechRecognitionRejected;
        }

        private void sRecognize_SpeechRecognitionRejected(object sender, SpeechRecognitionRejectedEventArgs e)
        {
            sentenceBox.Text = "Sorry, I couldn't recognize";
        }

        private void sRecognize_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            sentenceBox.Text = e.Result.Text.ToString();
        }
    }
}

HOWEVER, this code will only recognize one word at a time. Even if I edit my code to do this:

private void sRecognize_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            sentenceBox.Text = sentenceBox.Text + " " + e.Result.Text.ToString();
        }

The application cannot continuously recognize words when I utter the words "What is a car" continuously without having breaks when I speak them out.

What changes can I make in order for the program to recognize an entire sentence built using those words defined, without having to have speech breaks when uttering the sentence?

Output required:

I utter the sentence: What is a car

Application displays: What is a car

PERFECT Example: Google Speech Recognition Google develops a sentence using the words available in their word library

Thank you kindly :)

解决方案

It recognizes one word because you incorrectly constructed the grammar. Since you constructed the grammar consisting of choice of one of the words "what", "is", "a", "car" it exactly recognizes one of the words.

You probably want to read introduction into grammars and related documentation.

http://msdn.microsoft.com/en-us/library/hh378438(v=office.14).aspx

If you want to construct the grammar describing the phrase you can just use GrammarBuilder like this:

  Grammar gr = new Grammar(new GrammarBuilder("what is a car"));

This grammar will recognize a phrase.

To understand how Choices work you can read documentation on Choices:

http://msdn.microsoft.com/en-us/library/microsoft.speech.recognition.choices(v=office.14).aspx

这篇关于C#语音识别多字在一起吗? (认识一个句子)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆