首页 > 代码库 > Kinect 2.0&Speech 11 中文语音控制
Kinect 2.0&Speech 11 中文语音控制
Kinect 2.0&Speech 11 中文语音控制相关代码
?
下载 Speech 11 中文语言包
Microsoft Speech Platform - Runtime Languages (Version 11)
?
查找中文语言的RecognizerInfo
- private static RecognizerInfo TryGetKinectRecognizer()
- ????????{
- ????????????IEnumerable<RecognizerInfo> recognizers;
- ????????????// This is required to catch the case when an expected recognizer is not installed.
- ????????????// By default - the x86 Speech Runtime is always expected.
- ????????????try
- ????????????{
- ????????????????recognizers = SpeechRecognitionEngine.InstalledRecognizers();
- ????????????}
- ????????????catch (COMException)
- ????????????{
- ????????????????return null;
- ????????????}
- ????????????foreach (RecognizerInfo recognizer in recognizers)
- ????????????{
- ????????????????string value;
- ????????????????recognizer.AdditionalInfo.TryGetValue("Kinect", out value);
- ????????????????if ("True".Equals(value, StringComparison.OrdinalIgnoreCase) && "en-US".Equals(recognizer.Culture.Name, StringComparison.OrdinalIgnoreCase))
- ????????????????{
- ???????????????????//return recognizer;
- ????????????????}
- ????????????????if ("zh-CN".Equals(recognizer.Culture.Name, StringComparison.OrdinalIgnoreCase))
- ????????????????{
- ????????????????????return recognizer;
- ????????????????}
- ????????????}
- ????????????return null;
- ????????}
构建中文指令
- RecognizerInfo ri = TryGetKinectRecognizer();
- this.speechEngine = new SpeechRecognitionEngine(ri.Id);
- var directions = new Choices();
- directions.Add(new SemanticResultValue("前", "FORWARD"));
- directions.Add(new SemanticResultValue("前进", "FORWARD"));
- ?directions.Add(new SemanticResultValue("前移", "FORWARD"));
- ?directions.Add(new SemanticResultValue("后", "BACKWARD"));
- ?directions.Add(new SemanticResultValue("后退", "BACKWARD"));
- ??directions.Add(new SemanticResultValue("后移", "BACKWARD"));
- ??directions.Add(new SemanticResultValue("左", "LEFT"));
- ??directions.Add(new SemanticResultValue("右", "RIGHT"));
- ?var gb = new GrammarBuilder { Culture = ri.Culture };
- gb.Append(directions);
- var g = new Grammar(gb);
- ? this.speechEngine.LoadGrammar(g);
?
官方Demo下载
Kinect 2.0&Speech 11 中文语音控制
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。