Search code examples
c#speech-recognitionspeech-synthesissystem.speech.recognition

How to work with System.Speech


So I have:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Profile\Client\ System.Speech.dll

...and I can add the reference to Visual Studio but using System.Speech etc won't register with the console, and therefore speech synthesis and recognition does not work.

Would appreciate any and all help, thanks!


Solution

  • You need to add a reference to the System.Speech assembly, then you are free to use speech like so:

    using System;
    using System.Speech; // <-- sounds like what you are using, not necessary for this example
    using System.Speech.Recognition; // <--- you need this
    
    namespace ConsoleApplication2
    {
        class Program
        {
            static void Main(string[] args)
            {
                using (SpeechRecognizer recognizer = new SpeechRecognizer())
                {
                    // do something
                }
            }
        }
    }
    

    Adding reference

    Just in case, here is the reference I am using (via project.References.Add Reference...):

    enter image description here

    It is not necessary to use the Browse function. I'm assuming you are not using COM too.

    Tell me more