明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1319|回复: 7

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

[复制链接]
发表于 2019-3-9 11:42:09 | 显示全部楼层 |阅读模式
本帖最后由 1291500406 于 2019-3-9 14:23 编辑

Dim CommandDictionary

Dim 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, 1

MsgBox "你好,主人,请吩咐。"

Do

WScript.Sleep 1000
Loop Until ScriptComplete

MsgBox "欢迎再跟我说话,再见!"

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>








"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2019-3-10 20:06:57 | 显示全部楼层
1291500406 发表于 2019-3-10 20:03
( defun c:tt () (vlax-create-object "SAPI.SpSharedRecoContext") (princ))

插入话同已试
无什么反应
回复 支持 1 反对 0

使用道具 举报

发表于 2019-3-10 18:55:30 | 显示全部楼层

能不能来个CAD中的示范
 楼主| 发表于 2019-3-10 20:03:28 | 显示全部楼层
ynhh 发表于 2019-3-10 18:55
能不能来个CAD中的示范

( defun c:tt () (vlax-create-object "SAPI.SpSharedRecoContext") (princ))
 楼主| 发表于 2019-3-10 20:14:18 | 显示全部楼层
ynhh 发表于 2019-3-10 20:06
插入话同已试
无什么反应

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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2019-3-14 23:08:14 | 显示全部楼层
1291500406 发表于 2019-3-10 20:14
我不知道你的电脑为何不可以,我的电脑是会出现这个的,win10

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

百度一下你就知道
发表于 2019-4-9 21:38:55 | 显示全部楼层
感谢分享,学习一下
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-5-19 03:20 , Processed in 0.215361 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表