语音识别,包括带c#的数字 [英] speech recognition including numbers with c#

查看:85
本文介绍了语音识别,包括带c#的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,祝贺这个伟大的网站!我正在构建一个将执行语音识别和数字识别的应用程序。我需要让我的程序理解数字在
0.0 - 10范围内以及0-99范围内的数字。

例如,如果我对计算机说34,52我需要在一个文本框中写下这个数字。

我知道如何让一个程序理解语音,我知道如何制作语法,但我不知道怎么做到了解十进制数....如果你能给出任何想法或任何建议我将不胜感激!

Hello guys and congrats for the great site! I am building an application that will perform speech recognition and number recognition . I need to make my program understand numbers in the range of
0.0 - 10 and also numbers in the range of 0-99.
for example if i say to the computer 34,52 i need to write the number in a text box.
I know how to make a program understand speech , i know how to make grammars , but i don't know how to make it to understand decimal numbers.... if you can give any ideas or any suggestions i would be grateful!

推荐答案

我不记得识别引擎是否可以识别带有数字的单词,例如99,从未尝试过。你能试试自己并告诉我们它是否有效吗?



如果它不起作用,解决方法很简单。在你的语法中添加用英语写的句子,如:一,两,......六十七,......九十九。微软免费提供的引擎虽然可以与大词典一起使用,但这应该可行。您可以自动生成这些句子。例如,请参阅:将数字转换为英语和亚洲语言格式 [ ^ ]。








以上所有内容均不再适用。我测试了在文本形式中添加数字,如1,2,...10,11,...99语法,使用 System.Speech.Recognition .SpeechRecognitionEngine 。它确实有效!你不需要做什么特别的事情。要创建这样的字符串,只需使用 int.ToString();事件的事件处理程序 SpeechRecognitionEngine.SpeechRecognized 将为您提供可以解析为整数的已识别文本:
I don't remember if recognition engine can recognize words with digits, such as "99", never tried. Would you please try yourself and tell us if it works?

If it does not work, the workaround is simple. Add to your grammar the sentences written in English, like this: "one", "two", ... "sixty seven", ... "ninety nine". The engine available free of charge from Microsoft purely work with big dictionaries though, but this should work. You can automatically generate those sentences. See for example: Convert numbers to words in English and Asian format[^].




All of the above is no longer applicable. I tested adding numbers in the text form like "1", "2", ... "10", "11", ... "99" to the grammar, using System.Speech.Recognition.SpeechRecognitionEngine. It does work! There is nothing special you need to do. To create strings like that, use just int.ToString(); the event handler of the event SpeechRecognitionEngine.SpeechRecognized will give you the recognized text which you can parse back into an integer:
string[] phrases = new string[] { "10", "11", "12", "Quit", /*...*/ };
// of course, in real code create array of strings with those number strings
// using the loop

//...

Choices choiceSet = new Choices(phrases);
GrammarBuilder grammarBuilder = new GrammarBuilder(choiceSet);
SpeechRecognitionEngine engine = new SpeechRecognitionEngine();

//...

engine.SpeechRecognized += (source, eventInfo) => {
    string recognizedText = eventInfo.Result.Text;
    int numericCommand;
    if (int.TryParse(recognizedText, out numericCommand)) {
        // numericCommand contains text recognized as number
    } else {
        // something else
    }
    //...
};





请记住,此识别器类型需要 [System.MTAThread] System.Speech.Recognition.SpeechRecognizer 需要[System.STAThread]。



我没有打扰到尝试 System.Speech.Recognition.SpeechRecognizer 。我认为它将支持我刚才描述的功能。您可以自己试试。



-SA



Remember that this recognizer type requires [System.MTAThread] while System.Speech.Recognition.SpeechRecognizer requires [System.STAThread].

I did not bother to try System.Speech.Recognition.SpeechRecognizer. I think it will support the functionality I just described. You can try it yourself.

—SA


语音识别API的一些实验 [ ^ ]应该给你一个想法。
A little experimentation with the speech recognition API[^] should give you an idea.


这篇关于语音识别,包括带c#的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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