使用.NET语音识别的PlatformNotSupportedException

编程入门 行业动态 更新时间:2024-10-23 18:32:39
本文介绍了使用.NET语音识别的PlatformNotSupportedException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

所以我正在尝试C#的语音识别,我正在使用System.Speech.Recognition,并且我在互联网上四处搜寻,尝试了一些代码来进行一些基本的语音识别,这是我能做到的最好的代码发现是这样的:

So I'm trying voice recognition for C#, I'm using System.Speech.Recognition, and, I was searching around on the internet, trying out several pieces of code for some basic speech recognition, the best one I could find was this:

using System; using System.Text; using System.Windows.Forms; using System.Speech.Recognition; namespace SpeechRecognition { public partial class MainForm : Form { SpeechRecognitionEngine recognitionEngine; public MainForm() { InitializeComponent(); Initialize(); } private void Initialize() { recognitionEngine = new SpeechRecognitionEngine(); recognitionEngine.SetInputToDefaultAudioDevice(); recognitionEngine.SpeechRecognized += (s, args) => { foreach (RecognizedWordUnit word in args.Result.Words) { // You can change the minimun confidence level here if (word.Confidence > 0.8f) freeTextBox.Text += word.Text + " "; } freeTextBox.Text += Environment.NewLine; }; } private void startButton_Click(object sender, EventArgs e) { try { recognitionEngine.UnloadAllGrammars(); recognitionEngine.LoadGrammar(new DictationGrammar()); RecognitionResult result = recognitionEngine.Recognize(new TimeSpan(0, 0, 20)); if (result != null) { foreach (RecognizedWordUnit word in result.Words) { freeTextBox.Text += word.Text + " "; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void startAsyncButton_Click(object sender, EventArgs e) { recognitionEngine.UnloadAllGrammars(); recognitionEngine.LoadGrammar(new DictationGrammar()); recognitionEngine.RecognizeAsync(RecognizeMode.Multiple); } private void stopButton_Click(object sender, EventArgs e) { recognitionEngine.RecognizeAsyncStop(); } private void startAsyncGrammarButton_Click(object sender, EventArgs e) { try { recognitionEngine.UnloadAllGrammars(); Grammar cg = CreateSampleGrammar(); recognitionEngine.LoadGrammar(cg); recognitionEngine.RecognizeAsync(RecognizeMode.Multiple); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private Grammar CreateSampleGrammar() { Choices commandChoices = new Choices("Calculator", "Notepad", "Internet Explorer", "Paint"); GrammarBuilder grammarBuilder = new GrammarBuilder("Start"); grammarBuilder.Append(commandChoices); Grammar g = new Grammar(grammarBuilder); g.Name = "Available programs"; return g; } } }

现在,我尝试了这种方法,以及其他一些方法,它们都导致了相同的错误,即PlatformNotSupportedException,错误内容为:未安装识别器".

Now, I tried this, and some others, and they all resulted in the same error, a PlatformNotSupportedException, in the error it says: "There is no recogniser installed".

有什么办法解决吗?我正在运行Windows 7 64位.

Is there any way around this? I'm running Windows 7 64 bits.

推荐答案

语音平台运行时11和语音平台SDK 11不包括用于语音识别或语音合成(TTS或文本到语音)的运行时语言.您必须单独安装它们.运行时语言包括语言模型,声学模型和其他提供语音引擎以特定语言执行语音识别或TTS所需的数据.有用于语音识别或语音合成的单独的运行时语言.您下载的运行时语言版本(例如11.0版)必须与已安装的语音平台运行时版本匹配.您可以使用此链接下载.

来自 msdn.microsoft/en-us/library/hh362873.aspx .

我认为您使用的是.NET附带的版本,但是此后已经发布了多个修订版本.Microsoft Speech Services v11是今天的最新版本.如果安装SDK,请添加引用,然后将名称空间更改为Microsoft.Speech(而不是System.Speech).

I think you're using the version that shipped with .NET, but there have been several revisions released out of band since then. Microsoft Speech Services v11 is the current release as of today. If you install the SDK, add a reference, and change your namespace to Microsoft.Speech (instead of System.Speech) you should be updated.

更多推荐

使用.NET语音识别的PlatformNotSupportedException

本文发布于:2023-11-14 00:47:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1585762.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语音识别   NET   PlatformNotSupportedException

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!