fredag den 30. marts 2012

Microsoft Speech with non-english languages

I had a horrid time trying to get the Microsoft text-to-speech to work with my native Danish language. So here's how I made it work. Hope it'll help you save a few hours.

The target is a C# .net 3.5 console application. Later I'll work out how to use it from a web-server.

Key is using the same version numbers for all components. Download and install the following, in the same order as below:

- Microsoft Speech platform runtime 11.0 - http://www.microsoft.com/download/en/details.aspx?id=27225 (select the x86 og x64 platform according to your OS)
- Microsoft Speech platform SDK 11.0 - http://www.microsoft.com/download/en/details.aspx?id=27226 (again, select the x86 og x64 platform according to your OS)

Having downloaded and installed the above, now's the time to select your language of choice from the language  download section: http://www.microsoft.com/download/en/details.aspx?id=27224

Download one or more of the language files with the "TTS" in the filenames (short for 'text-to-speech'). The other runtime languages are for speech recognition, not text-to-speech.

Now, in your Visual Studio, create a new console application.

Important steps:

- Set the deployment target CPU architecture to the same version of the microsoft components you downloaded. So if your OS is x86, and you thus downloaded the x86 microsoft speech components, set the deployment target as 'x86'.
- Reference the Microsoft.speech DLL from the C:\Program Files\Microsoft SDKs\Speech\v11.0\Assembly-folder.

All set, then. Here's a sample Main()-method:


 static void Main(string[] args)
        {
            // Initialize a new instance of the SpeechSynthesizer.
            SpeechSynthesizer synth = new SpeechSynthesizer();
            // select your installed voice
            synth.SelectVoiceByHints(VoiceGender.NotSet, VoiceAge.NotSet, 0, new CultureInfo("da-dk"));
            // important to set the output to the default device, or no sound will be heard.
            synth.SetOutputToDefaultAudioDevice();
            // speak a phrase
            synth.Speak("patter der batter");
        }




2 kommentarer:

  1. I can't find arabic TTS! where can I find it?

    jrahma@hotmail.com

    SvarSlet
    Svar
    1. There's no official MS arabic TTS, but this may be helpful to you:

      http://social.msdn.microsoft.com/Forums/en/winforms/thread/a49621ad-c828-4a26-b595-9bbc09293ba6

      Slet