Search code examples
c#speech-synthesis

C# and Microsoft Speech.Recognition and Speech.Synthesis


I'm new to C# and I'm new to Speech.Recognition. I searched very long for tutorials but didn't find that much, I'm even not quiet sure whether I included everything correctly.

I downloaded:

I'm programming local, I have Windows XP, .net framework 3.5.

Now I just want to get started with some simple lines of code, like to say "hello world" or say one or two words as input.

I tried following, and of course it doesn't work :> error:

"The Typ- or Namespacename "SpeechSynthesizer" couldn't be found (Is a Using-Direktive or a Assemblyverweis missing?)"

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Speech.Recognition;
using System.Speech.Synthesis;

namespace System.Speech.Recognition { }
namespace System.Speech.AudioFormat {}
namespace System.Speech.Recognition.SrgsGrammar{}
namespace System.Speech.Synthesis { }
namespace System.Speech.Synthesis.TtsEngine { }

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            SpeechSynthesizer foo = new SpeechSynthesizer();
            foo.Speak("Test");  
        }
    }
}

edit:

hello, i tried you code,but using SpeechLib; couldn't be found :>

well now i wrote:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Speech.Recognition;
using System.Speech.Synthesis;
using System.SpeechLib;

namespace System.SpeechLib { }
namespace System.Speech.Recognition { }
namespace System.Speech.AudioFormat {}
namespace System.Speech.Recognition.SrgsGrammar{}
namespace System.Speech.Synthesis { }
namespace System.Speech.Synthesis.TtsEngine { }

but I get an error with:

numericUpDown1,SpVoice,SpeechVoiceSpeakFlags,textBox1 and Timeout


Solution

  • Project + Add Reference, .NET tab, select "System.Speech".

    A project template pre-selects several .NET assemblies. But only common ones, like System.dll, System.Core.dll, etcetera. You have to add the 'unusual' ones yourself.