PlatformNotSupportedException using .NET Speech Recognition

So I am trying to recognize voices in C #, I am using System.Speech.Recognition and I have searched the internet trying a few snippets of code for some basic speech recognition, the best one I found 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;
        }

    }
}

      

Now I tried this and some others and they all resulted in the same error - PlatformNotSupportedException, in the error message: "No resolver installed".

Is there a way to get around this? I have Windows 7 64-bit.

+3


source to share


3 answers


Speech Runtime 11 and Speech SDK 11 do not include speech recognition or speech synthesis (TTS or text-to-speech) Runtime languages. You must install them separately. The Runtime Language includes the language model, acoustic model, and other data necessary to provide a speech engine to perform speech recognition or TTS in a particular language. 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 you set. You can download the Runtime Languages using this link .

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



I think you are using the version that comes with .NET, but several versions have been released since then. Microsoft Speech Services v11 is the current version as of today. If you install the SDK, add a link and change your namespace to Microsoft.Speech (instead of System.Speech), you should be updated.

+2


source


What version of Windows 7 are you using? What language?

Can you use the built-in dictation features of Windows 7? Are you using the Speech Recognition Control Panel app? See http://windows.microsoft.com/en-US/windows7/Setting-speech-options

I thought that all versions of Windows 7 should come with a recognizer preinstalled. However, if you are using an unsupported language, this may not be the case.



From fooobar.com/questions/83526 / ... :

You can use APIs to query and define your installed recongizers Desktop: System.Speech.Recognition.SpeechRecognitionEngine.InstalledRecognizers ()

I found that I can also see which recognizers are installed by looking at the registry keys: Desktop recognizers: HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Speech \ recognizers \ tokens

If you want to try a very simple program that might help, see fooobar.com/questions/639529 / ...

0


source


I had the same problem. I just started VisualStudio in x86 debug mode and System.Speech.dll was used for x64. In Release (x64) mode, it worked. You might have the same problem installing CPU architecture and System.Speech.dll.

0


source







All Articles