简体   繁体   English

PlatformNotSupportedException使用.NET语音识别

[英]PlatformNotSupportedException Using .NET 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: 所以我正在为C#尝试语音识别,我正在使用System.Speech.Recognition,而且,我在互联网上搜索,尝试了一些基本语音识别的代码,我能找到的最好的是这个:

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;
        }

    }
}

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". 现在,我尝试了这个,以及其他一些,并且它们都导致了同样的错误,一个PlatformNotSupportedException,它在错误中说:“没有安装识别器”。

Is there any way around this? 有没有办法解决? I'm running Windows 7 64 bits. 我正在运行Windows 7 64位。

The Speech Platform Runtime 11 and the Speech Platform SDK 11 do not include Runtime Languages for speech recognition or for speech synthesis (TTS or text-to-speech). 语音平台运行时11和语音平台SDK 11不包括用于语音识别或语音合成(TTS或文本到语音)的运行时语言。 You must install them separately. 您必须单独安装它们。 A Runtime Language includes the language model, acoustic model, and other data necessary to provision a speech engine to perform speech recognition or TTS in a particular language. 运行时语言包括语言模型,声学模型以及提供语音引擎以执行特定语言的语音识别或TTS所需的其他数据。 There are separate Runtime Languages for speech recognition or speech synthesis. 语音识别或语音合成有单独的运行时语言。 The version of Runtime Languages that you download (for example, version 11.0) must match the version of the Speech Platform Runtime that you have installed. 您下载的Runtime Languages版本(例如,版本11.0)必须与您安装的Speech Platform Runtime的版本相匹配。 You can download Runtime Languages using this link . 您可以使用此链接下载Runtime Languages。

From http://msdn.microsoft.com/en-us/library/hh362873.aspx . 来自http://msdn.microsoft.com/en-us/library/hh362873.aspx

I think you're using the version that shipped with .NET, but there have been several revisions released out of band since then. 我认为你正在使用.NET附带的版本,但从那时起已经有一些带外版本的版本。 Microsoft Speech Services v11 is the current release as of today. Microsoft Speech Services v11是截至今天的当前版本。 If you install the SDK, add a reference, and change your namespace to Microsoft.Speech (instead of System.Speech) you should be updated. 如果您安装SDK,添加引用,并将命名空间更改为Microsoft.Speech(而不是System.Speech),您应该更新。

I had same problem. 我有同样的问题。 I just started VisualStudio in x86 Debug mode and the System.Speech.dll was used for x64. 我刚刚在x86调试模式下启动了VisualStudio,而System.Speech.dll用于x64。 In Release mode (x64) it worked. 在发布模式(x64)中,它可以工作。 Perhaps you have same issue with CPU Architecture and System.Speech.dll setup. 也许您在CPU架构和System.Speech.dll设置方面遇到了同样的问题。

Which version of Windows 7 are you running? 您运行的是哪个版本的Windows 7? Which language? 哪种语言?

Can you use the built in Windows 7 dictation features? 你能使用内置的Windows 7听写功能吗? Is the speech recognition control panel app working for you? 语音识别控制面板应用程序是否适合您? See http://windows.microsoft.com/en-US/windows7/Setting-speech-options 请参见http://windows.microsoft.com/en-US/windows7/Setting-speech-options

I thought all Windows 7 versions should come with recognizer preinstalled. 我认为所有Windows 7版本都应该预装了识别器。 However, if you are using an unsupported language, it may not. 但是,如果您使用的是不受支持的语言,则可能不会。

From https://stackoverflow.com/a/2998963/90236 : 来自https://stackoverflow.com/a/2998963/90236

You can use use the APIs to query and determine your installed recongizers Desktop: System.Speech.Recognition.SpeechRecognitionEngine.InstalledRecognizers() 您可以使用API​​查询并确定已安装的recongizers桌面:System.Speech.Recognition.SpeechRecognitionEngine.InstalledRecognizers()

I found that I can also see what recognizers are installed by looking at the registry keys: Desktop recognizers: HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\Recognizers\\Tokens 我发现通过查看注册表项,我还可以看到安装了哪些识别器:桌面识别器:HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Microsoft \\ Speech \\ Recognizers \\ Tokens

If you want to try a very simple program that might help, see https://stackoverflow.com/a/4737003/90236 如果您想尝试一个可能有用的非常简单的程序,请参阅https://stackoverflow.com/a/4737003/90236

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 语音识别PlatformNotSupportedException - Speech Recognition PlatformNotSupportedException 使用Microsoft System.Speech.Recognition时出现PlatformNotSupportedException - PlatformNotSupportedException while using Microsoft System.Speech.Recognition 使用.NET Frameworks作为Web服务的语音识别 - Speech recognition using .NET Frameworks as a web service System.PlatformNotSupportedException:此系统上不提供语音识别。 无法找到SAPI和语音识别引擎 - System.PlatformNotSupportedException: Speech Recognition is not available on this system. SAPI and Speech Recognition engines cannot be found 使用语音识别的命令 - Commands using speech recognition .Net Framework 4语音识别 - 使用小语法时的误报 - .Net Framework 4 speech recognition – false positives when using small grammar .NET中有关语音识别类的问题 - Question on Speech Recognition classes in .NET 使用EntityFramework和.NET Native时的PlatformNotSupportedException - PlatformNotSupportedException when using EntityFramework and .NET Native 使用语音命令启用和禁用语音识别 - Enable and Disable Speech Recognition using speech Commands 使用 System.Speech.Recognition 打开 Windows 语音识别 - Using System.Speech.Recognition opens Windows Speech Recognition
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM