启用语音识别复选框 [英] Speech Recognition to enable checkbox

查看:91
本文介绍了启用语音识别复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



无论如何,关于我发布的代码,我也遇到了另一个问题.当我使用麦克风讲话时它能够识别颜色,但是我发现即使我说其他单词时代码也会改变颜色,例如我说它将变为green.so无论如何我的问题是只认出我说例如红色"的单词,而拒绝我说例如你好"的任何其他单词?还是谢谢程序员

 私有  Sub  Form1_Load( ByVal 发​​件人 As 系统.对象 ByVal  e  As  System.EventArgs)句柄  MyBase .加载
         Dim  As   Recognition.SrgsGrammar. SrgsDocument
         Dim  colorRule  As   Recognition.SrgsGrammar. SrgsRule(" )
         Dim  colorsList  As   Recognition.SrgsGrammar. SrgsOneOf(" " 玫瑰色" 白色"" "  蓝色"  红色")
        colorRule.Add(colorsList)
        gram.Rules.Add(colorRule)
        gram.Root = colorRule
        reco.LoadGrammar( Recognition.Grammar(gram))
    结束 

私有  reco_SpeechRecognized( ByVal 发​​件人目标 对象 ByVal  e 句柄 reco.SpeechRecognized
       选择 案例 e.Result.Text
           案例 " 
               SetColor(Color.RosyBrown)
           案例 " 
               SetColor(颜色.绿色)
           案例 " 
               SetColor(颜色.白色)
           案例 " 
               SetColor(颜色.黄色)
           案例 " 
               SetColor(Color.Peru)
           案例 " 
               SetColor(颜色.蓝色)
           案例 " 
               SetColor(Color.Red)

解决方案

好吧,如果您不了解有关您的项目的任何信息或确切的意图,...选中一个带有以下代码的复选框:

Checkbox1.Checked = True

如果您要取消选中此复选框,则将如下所示:

Checkbox1.Checked = False

因此,如果您有多个复选框,则可能首先要取消选中所有复选框,然后根据说出并识别出的关键字选择相应的复选框.

如果您需要更多帮助,请更详细地说明您要完成的工作,例如表单上的复选框以及进行检查的确切条件.


Hi,

anyway regarding the code i post i also got another problem. it is able to recognised the color when i use the mic to speak however i found out that the code change color even when i am saying other word for example i say hi it will change to green.so my question is there anyway that i can only recognise the word i say for example "red" and reject any other word i say like example "hello"? thanks programmer anyway

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim gram As New Recognition.SrgsGrammar.SrgsDocument
        Dim colorRule As New Recognition.SrgsGrammar.SrgsRule("color")
        Dim colorsList As New Recognition.SrgsGrammar.SrgsOneOf("green", "rosy", "white", "yellow", "Peru", "Blue", "red")
        colorRule.Add(colorsList)
        gram.Rules.Add(colorRule)
        gram.Root = colorRule
        reco.LoadGrammar(New Recognition.Grammar(gram))
    End Sub

Private Sub reco_SpeechRecognized(ByVal sender As Object, ByVal e As System.Speech.Recognition.RecognitionEventArgs) Handles reco.SpeechRecognized
       Select Case e.Result.Text
           Case "rosy"
               SetColor(Color.RosyBrown)
           Case "green"
               SetColor(Color.Green)
           Case "white"
               SetColor(Color.White)
           Case "yellow"
               SetColor(Color.Yellow)
           Case "Peru"
               SetColor(Color.Peru)
           Case "Blue"
               SetColor(Color.Blue)
           Case "red"
               SetColor(Color.Red)

解决方案

Well, without knowing anything about your project or exactly what you are trying to do... if you want to check a checkbox it''s with code like this:

Checkbox1.Checked = True

and if you want to uncheck a checkbox it would be like this:

Checkbox1.Checked = False

So if you have multiple checkboxes you may first want to uncheck all of them, and then based on what keyword is spoken and recognized check the appropriate box.

If you need more help, please be a bit more specific about what you are trying to accomplish, like what checkboxes you have on your form and exactly what needs to happen in order to check them.


这篇关于启用语音识别复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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