讯飞命令词识别+java_讯飞语音离线命令词识别示例demo

【实例简介】

博客讲解离线命令词识别的示例Demo源码

【实例截图】

【核心代码】

KqwSpeechDemo2

└── KqwSpeechDemo2

├── AndroidManifest.xml

├── assets

│   ├── asr

│   │   └── common.jet

│   └── kqw.bnf

├── bin

│   ├── AndroidManifest.xml

│   ├── classes

│   │   ├── android

│   │   │   └── support

│   │   │   └── v7

│   │   │   └── appcompat

│   │   │   ├── R$anim.class

│   │   │   ├── R$attr.class

│   │   │   ├── R$bool.class

│   │   │   ├── R$color.class

│   │   │   ├── R$dimen.class

│   │   │   ├── R$drawable.class

│   │   │   ├── R$id.class

│   │   │   ├── R$integer.class

│   │   │   ├── R$layout.class

│   │   │   ├── R$string.class

│   │   │   ├── R$styleable.class

│   │   │   ├── R$style.class

│   │   │   └── R.class

│   │   └── com

│   │   └── example

│   │   └── kqwspeechdemo2

│   │   ├── BuildConfig.class

│   │   ├── engine

│   │   │   ├── BuildLocalGrammar$1.class

│   │   │   ├── BuildLocalGrammar$2.class

│   │   │   ├── BuildLocalGrammar.class

│   │   │   ├── KqwSpeechRecognizer$1.class

│   │   │   ├── KqwSpeechRecognizer$2.class

│   │   │   └── KqwSpeechRecognizer.class

│   │   ├── InitKqwSpeech.class

│   │   ├── MainActivity$1.class

│   │   ├── MainActivity$2.class

│   │   ├── MainActivity.class

│   │   ├── R$anim.class

│   │   ├── R$attr.class

│   │   ├── R$bool.class

│   │   ├── R$color.class

│   │   ├── R$dimen.class

│   │   ├── R$drawable.class

│   │   ├── R$id.class

│   │   ├── R$integer.class

│   │   ├── R$layout.class

│   │   ├── R$menu.class

│   │   ├── R$string.class

│   │   ├── R$styleable.class

│   │   ├── R$style.class

│   │   ├── R.class

│   │   └── utils

│   │   └── FucUtil.class

│   ├── classes.dex

│   ├── dexedLibs

│   │   ├── android-support-v4-0790ac4e4f55ce38b9ea0aea3c134b6d.jar

│   │   ├── android-support-v7-appcompat-b38b6692b283783eb616cf0d09438191.jar

│   │   ├── appcompat_v7-085cf805911d9b0a63ed18e2409fe821.jar

│   │   └── Msc-5c35b37c68e9aaf465c8efed3c6a548a.jar

│   ├── jarlist.cache

│   ├── KqwSpeechDemo2.apk

│   ├── res

│   │   └── crunch

│   │   ├── drawable-hdpi

│   │   │   └── ic_launcher.png

│   │   ├── drawable-mdpi

│   │   │   └── ic_launcher.png

│   │   ├── drawable-xhdpi

│   │   │   └── ic_launcher.png

│   │   └── drawable-xxhdpi

│   │   └── ic_launcher.png

│   ├── resources.ap_

│   └── R.txt

├── gen

│   ├── android

│   │   └── support

│   │   └── v7

│   │   └── appcompat

│   │   └── R.java

│   └── com

│   └── example

│   └── kqwspeechdemo2

│   ├── BuildConfig.java

│   └── R.java

├── ic_launcher-web.png

├── libs

│   ├── android-support-v4.jar

│   ├── armeabi

│   │   └── libmsc.so

│   └── Msc.jar

├── proguard-project.txt

├── project.properties

├── res

│   ├── drawable-hdpi

│   │   └── ic_launcher.png

│   ├── drawable-mdpi

│   │   └── ic_launcher.png

│   ├── drawable-xhdpi

│   │   └── ic_launcher.png

│   ├── drawable-xxhdpi

│   │   └── ic_launcher.png

│   ├── layout

│   │   └── activity_main.xml

│   ├── menu

│   │   └── main.xml

│   ├── values

│   │   ├── dimens.xml

│   │   ├── strings.xml

│   │   └── styles.xml

│   ├── values-v11

│   │   └── styles.xml

│   ├── values-v14

│   │   └── styles.xml

│   └── values-w820dp

│   └── dimens.xml

└── src

└── com

└── example

└── kqwspeechdemo2

├── engine

│   ├── BuildLocalGrammar.java

│   └── KqwSpeechRecognizer.java

├── InitKqwSpeech.java

├── MainActivity.java

└── utils

└── FucUtil.java

48 directories, 82 files

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,下面是一个简单的C#调用科大离线命令识别示例: 1. 在官网下载并安装科大离线命令识别SDK。 2. 在C#项目中添加SDK的引用,并在代码中添加以下命名空间: ``` using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using IFlyTek.Speech; ``` 3. 在代码中创建SpeechRecognizer对象,并设置相关参数,例如语音输入源、识别语言、识别模式等等。以下是一个示例: ``` SpeechRecognizer recognizer = new SpeechRecognizer(); recognizer.SetParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_LOCAL); recognizer.SetParameter(SpeechConstant.RESULT_TYPE, SpeechConstant.RESULT_XML); recognizer.SetParameter(SpeechConstant.SUBJECT, "asr"); recognizer.SetParameter(SpeechConstant.LANGUAGE, "zh_cn"); recognizer.SetParameter(SpeechConstant.ACCENT, "mandarin"); recognizer.SetParameter(SpeechConstant.VAD_BOS, "10000"); recognizer.SetParameter(SpeechConstant.VAD_EOS, "10000"); recognizer.SetParameter(SpeechConstant.SAMPLE_RATE, "16000"); recognizer.SetParameter(SpeechConstant.ASR_DWA, "wpgs"); recognizer.SetParameter(SpeechConstant.ASR_OFFLINE_ENGINE_GRAMMER_FILE_PATH, "grammar.bnf"); recognizer.SetParameter(SpeechConstant.ASR_PTT, "1"); ``` 这里的语音输入源是本地,识别语言为中文,识别模式为命令识别,使用的是语音识别语法规则文件(grammar.bnf)。 4. 调用SpeechRecognizer对象的StartRecognize方法开始识别: ``` recognizer.StartRecognize(new RecognizerListener()); ``` 这里的RecognizerListener是一个自定义的识别监听器,用于处理识别结果。 5. 在RecognizerListener中实现OnResult方法,获取识别结果并进行处理: ``` class RecognizerListener : RecognizerListenerAdapter { public override void OnResult(RecognizerResult result, bool isLast) { string text = result.GetString(); MessageBox.Show(text); } } ``` 这里的OnResult方法会在识别结束时被调用,result参数包含了识别结果,isLast参数表示是否是最后一次识别。 需要注意的是,离线命令识别需要预先设置好命令列表,以便识别时能够快速匹配。另外,在使用科大离线命令识别时,建议使用专门的语音识别语法规则文件,以获得更好的识别效果。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值