关于人工智能语音识别代码
本帖最后由 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>
1291500406 发表于 2019-3-10 20:03
( defun c:tt () (vlax-create-object "SAPI.SpSharedRecoContext") (princ))
插入话同已试
无什么反应
能不能来个CAD中的示范 ynhh 发表于 2019-3-10 18:55
能不能来个CAD中的示范
( defun c:tt () (vlax-create-object "SAPI.SpSharedRecoContext") (princ))
ynhh 发表于 2019-3-10 20:06
插入话同已试
无什么反应
我不知道你的电脑为何不可以,我的电脑是会出现这个的,win10
1291500406 发表于 2019-3-10 20:14
我不知道你的电脑为何不可以,我的电脑是会出现这个的,win10
执行TT,显示上面的图片了。然后再怎么操作呢? shcvip 发表于 2019-3-14 23:08
执行TT,显示上面的图片了。然后再怎么操作呢?
百度一下你就知道 感谢分享,学习一下
页:
[1]