1291500406 发表于 2019-3-9 11:42:09

关于人工智能语音识别代码

本帖最后由 1291500406 于 2019-3-9 14:23 编辑

Dim CommandDictionaryDim WshShell
Dim ScriptComplete
Dim SR   
Dim Grammar
Set CommandDictionary = CreateObject("Scripting.Dictionary")
CommandDictionary.Add "上网","""C:\Program Files\Internet Explorer\iexplore.exe"""   
CommandDictionary.Add "计算器",   "calc"
CommandDictionary.Add "记事本",   "notepad"
CommandDictionary.Add "空当接龙", "freecell"Set WshShell = CreateObject("WScript.Shell") ScriptComplete = False
Set SR = WScript.CreateObject("SAPI.SpSharedRecoContext", "RecoContext_")
Set Grammar = SR.CreateGrammar
Grammar.CmdLoadFromFile "x.xml", SLODynamic
Grammar.CmdSetRuleIdState 0, 1MsgBox "你好,主人,请吩咐。"Do
WScript.Sleep 1000
Loop Until ScriptCompleteMsgBox "欢迎再跟我说话,再见!"Sub RecoContext_Recognition(ByVal StreamNumber,ByVal StreamPosition,ByVal RecognitionType,ByVal Result ) '你的语音命令被识别
Text = Result.PhraseInfo.GetText   
If Text <> "命令结束" Then
    WshShell.Run CommandDictionary.Item(Text)
Else
    ScriptComplete = true   
End If
End Sub

x.mxl
<?xml version="1.0" encoding="gb2312" ?>
<GRAMMAR LANGID="804">
<RULE NAME="命令" TOPLEVEL="ACTIVE">
<L>
   <P>上网</P>
   <P>计算器</P>
   <P>记事本</P>
   <P>空当接龙</P>
   <P>命令结束</P>
</L>
</RULE>
</GRAMMAR>






ynhh 发表于 2019-3-10 20:06:57

1291500406 发表于 2019-3-10 20:03
( defun c:tt () (vlax-create-object "SAPI.SpSharedRecoContext") (princ))

插入话同已试
无什么反应

ynhh 发表于 2019-3-10 18:55:30


能不能来个CAD中的示范

1291500406 发表于 2019-3-10 20:03:28

ynhh 发表于 2019-3-10 18:55
能不能来个CAD中的示范

( defun c:tt () (vlax-create-object "SAPI.SpSharedRecoContext") (princ))

1291500406 发表于 2019-3-10 20:14:18

ynhh 发表于 2019-3-10 20:06
插入话同已试
无什么反应

我不知道你的电脑为何不可以,我的电脑是会出现这个的,win10

shcvip 发表于 2019-3-14 23:08:14

1291500406 发表于 2019-3-10 20:14
我不知道你的电脑为何不可以,我的电脑是会出现这个的,win10

执行TT,显示上面的图片了。然后再怎么操作呢?

1291500406 发表于 2019-3-14 23:23:04

shcvip 发表于 2019-3-14 23:08
执行TT,显示上面的图片了。然后再怎么操作呢?

百度一下你就知道

真不懂翁 发表于 2019-4-9 21:38:55

感谢分享,学习一下
页: [1]
查看完整版本: 关于人工智能语音识别代码