none
Problem with Microsoft Speech

    Question

  • Hi at all,

    I installed Microsoft Speech Server Runtime, then Microsoft Speech SDK and then inside my application i installed Microsoft.Speech ddl

    I installed Italian Language (LUCIA)

    I write this code

      

    Dim tts As New Microsoft.Speech.Synthesis.SpeechSynthesizer 
     tts.Speak("Ciao")
    
    
    
    

     but i don't feel nothing

    Where is the problem ?

    I have vista ultimate 64bit

    If i make with System.Speech it's ok

    Wednesday, March 31, 2010 10:12 AM

Answers

  • (Thanks to Silvia and Zhao for the answer)

    Hi Massimo,

    You can use System.Media.SoundPlayer for this. Set TTS to write the audio to a MemoryStream in the SoundPlayer’s stream.  Once it finishes speaking, reset the stream position to the beginning and tell the player to play the audio.

    Note that SpeakCompleted will finish when TTS stops synthesizing the audio to the stream (which should be really quick), not when you stop hearing the actual audio (as in the behavior of the   SpeechSynthesizer in System.Speech.Synthesis. The player itself will handle the playback.

     

    Here’s some sample code I’ve been using for that:

     

     

    using Microsoft.Speech.Synthesis;

    using Microsoft.Speech.Recognition;

    using System.Media;

     

    namespace WindowsFormsApplication1

    {

        public partial class Form1 : Form

        {

            SpeechSynthesizer tts = new SpeechSynthesizer();

            SoundPlayer player = new SoundPlayer();

     

            private void Form1_Load(object sender, EventArgs e)

            {           

                tts.SpeakCompleted += new EventHandler <SpeakCompletedEventArgs>(tts_SpeakCompleted);

            }

     

            void tts_SpeakCompleted(object sender, SpeakCompletedEventArgs e)

            {

                player.Stream.Position = 0;

                player.Play();

            }

     

            public void Speak(string text)

            {

                player.Stream = new System.IO.MemoryStream ();

                tts.SetOutputToWaveStream(player.Stream);

                tts.SpeakAsync(text);

            }

        }

    }

    • Marked as answer by kio2008 Monday, November 22, 2010 5:59 PM
    Wednesday, July 28, 2010 9:11 PM

All replies

  • Hi all.

    However, when you speak text you get an Speak error.

    Is there a way to fix this error?

    Saturday, July 24, 2010 1:52 PM
  • Hello,

    On Windows 7 (x86) I installed the following software:

    1) Microsoft Speech Platform - Server Runtime 10.1
    2) Microsoft Speech Platform - Server Runtime Languages 10.1 ['en-US' and 'it-IT']
    3) Microsoft Speech Platform - Server SDK 10.1

    I can enumerate the voices, using the following code:

    using Microsoft.Speech.Synthesis;
    
    SpeechSynthesizer _synth = new SpeechSynthesizer();      
    foreach (InstalledVoice voice in _synth.GetInstalledVoices())
      Debug.Print(voice.VoiceInfo.Name.ToString()); 
    
              
    And I get:

    1) "Microsoft Helen Telecom"
    2) "Microsoft Lucia Telecom"

    Instead if i use the following namespace 'System.Speech.Synthesis' and the above code, i get:

    1) "Microsoft Anna"

    And up to here it's all right.

    Here the code i use for TTS:

    using System.Speech.Synthesis;
    
    SpeechSynthesizer _synth = new SpeechSynthesizer();
    _synth.SelectVoice("Microsoft Anna");
    _synth.SetOutputToDefaultAudioDevice();
    _synth.Speak("Hello World");
    

    And it works.
    The problem arise if i use the following namespace
    using Microsoft.Speech.Synthesis;
    
    SpeechSynthesizer _synth = new SpeechSynthesizer();
    _synth.SelectVoice("Microsoft Lucia Telecom");
    _synth.SetOutputToDefaultAudioDevice();
    _synth.Speak("Ciao Mondo");
    
    _synth.SelectVoice("Microsoft Helen Telecom");
    _synth.SetOutputToDefaultAudioDevice();
    _synth.Speak("Hello World");
    

    No audio at all, no sound, no speech, no error !!!

    However the speech recognizer in italian works great !!!
    Here the code i used:

    _sre = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("it-IT"));
    // Create a simple grammar that recognizes “red”, “green”, or “blue”.
    Choices colors = new Choices();
    
    colors.Add("rosso");
    colors.Add("verde");
    colors.Add("blue");
    
    GrammarBuilder gb = new GrammarBuilder();
    gb.Culture = new System.Globalization.CultureInfo("it-IT");
    gb.Append(colors);
    
    // Create the actual Grammar instance, and then load it into the speech recognizer.
    Grammar g = new Grammar(gb);
    _sre.LoadGrammar(g);
    
    // Register a handler for the SpeechRecognized event.
    _sre.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
    _sre.SetInputToDefaultAudioDevice();
    _sre.RecognizeAsync(RecognizeMode.Multiple);
    
    // Simple handler for the SpeechRecognized event.
    void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
    {
      listBox1.Items.Add(e.Result.Text);
    }
    

    What's wrong ?
    Why the TTS is mute when i use the 'Microsoft.Speech.Synthesis' namespace?
    Do i need to install something else?

    Any hints to solve the problem?

    Thanks.
    Auto.

    Tuesday, July 27, 2010 6:47 PM
  • (Thanks to Silvia and Zhao for the answer)

    Hi Massimo,

    You can use System.Media.SoundPlayer for this. Set TTS to write the audio to a MemoryStream in the SoundPlayer’s stream.  Once it finishes speaking, reset the stream position to the beginning and tell the player to play the audio.

    Note that SpeakCompleted will finish when TTS stops synthesizing the audio to the stream (which should be really quick), not when you stop hearing the actual audio (as in the behavior of the   SpeechSynthesizer in System.Speech.Synthesis. The player itself will handle the playback.

     

    Here’s some sample code I’ve been using for that:

     

     

    using Microsoft.Speech.Synthesis;

    using Microsoft.Speech.Recognition;

    using System.Media;

     

    namespace WindowsFormsApplication1

    {

        public partial class Form1 : Form

        {

            SpeechSynthesizer tts = new SpeechSynthesizer();

            SoundPlayer player = new SoundPlayer();

     

            private void Form1_Load(object sender, EventArgs e)

            {           

                tts.SpeakCompleted += new EventHandler <SpeakCompletedEventArgs>(tts_SpeakCompleted);

            }

     

            void tts_SpeakCompleted(object sender, SpeakCompletedEventArgs e)

            {

                player.Stream.Position = 0;

                player.Play();

            }

     

            public void Speak(string text)

            {

                player.Stream = new System.IO.MemoryStream ();

                tts.SetOutputToWaveStream(player.Stream);

                tts.SpeakAsync(text);

            }

        }

    }

    • Marked as answer by kio2008 Monday, November 22, 2010 5:59 PM
    Wednesday, July 28, 2010 9:11 PM
  • Is this method different than what is done by Speak (to the audio device) in terms of responsiveness?

    --- 

    http://blogs.msdn.com/b/speak/archive/2010/07/29/faq-about-the-server-speech-platform.aspx

    ·     Why SpeechSynthesizer Speak doesn't produce sound on my sound card?

    Currently the server voice doesn’t speak to sound card because it is primarily designed for server usage. It is a difference against System.Speech.Synthesizer.

    There are serveral ways for you to play the audio from SpeechSynthesizer.

    1.  You can speak to wave file first and play that wave file. See SetOutputToWavefile method of SpeechSynthesizer

    2.  Use a custom output stream to send the audio bytes to your target device (could be audio device or network socket). See SetOutputAudioStream method.

    3.  Speak to a memory stream, and then play the stream with System.Media.SoundPlayer

    • Edited by tofutim Thursday, October 14, 2010 6:48 AM New info
    Wednesday, October 13, 2010 8:09 PM