StartVoice Method (CultureInfo)

Microsoft Speech Platform SDK 11

Collapse imageExpand ImageCopy imageCopyHover image

Instructs the synthesizer to change the voice in the PromptBuilder object and specifies the culture of the voice to use.

Namespace:  Microsoft.Speech.Synthesis
Assembly:  Microsoft.Speech (in Microsoft.Speech.dll)

Syntax

Visual Basic (Declaration)
Public Sub StartVoice ( _
	culture As CultureInfo _
)
Visual Basic (Usage)
Dim instance As PromptBuilder
Dim culture As CultureInfo

instance.StartVoice(culture)
C#
public void StartVoice(
	CultureInfo culture
)

Parameters

culture
Type: System.Globalization..::..CultureInfo

Provides information about a specific culture, such as the language, the name of the culture, the writing system, the calendar used, and how to format dates and sort strings.

Remarks

If a voice with the specified culture is found, it will be used. If a voice with the specified culture cannot be found, the default voice will be used.

Use the GetInstalledVoices()()()() methods and VoiceInfo class to obtain the names and attributes of installed text-to-speech (TTS) voices that you can select.

For a given language code specified in the culture parameter, a speech synthesis engine that supports that language code must be installed to correctly pronounce words in the specified language.

The Microsoft Speech Platform Runtime 11 and Microsoft Speech Platform SDK 11 do not include any engines for speech synthesis in a specific language. You must download a language pack (an engine for speech synthesis in a specific language) for each language in which you want to generate synthesized speech. See InstalledVoice for more information.

The Speech Platform SDK 11 accepts all valid language-country codes as values for culture. See Language Identifier Constants and Strings for a comprehensive list of language codes.

NoteNote

Speech synthesis is often referred to as text-to-speech or TTS. An installed TTS engine is also referred to as a voice. A language pack for speech synthesis contains a TTS engine, or voice.

Examples

The following example creates a PromptBuilder object that presents menu options; beginning in English, then in French, and finishing in German. Correct pronunciation for each phrase will only be achieved if language packs for English, French, and German have been installed. The SpeechSynthesizer object automatically selects and uses the default voice for the language specified in the culture parameter of the StartVoice(CultureInfo) method.

 Copy imageCopy Code
using System;
using Microsoft.Speech.Synthesis;

namespace SampleSynthesis
{
  class Program
  {
    static void Main(string[] args)
    {

      // Initialize a new instance of the SpeechSynthesizer.
      using (SpeechSynthesizer synth = new SpeechSynthesizer())
      {

        // Configure the audio output. 
        synth.SetOutputToWaveFile(@"C:\test\cultures.wav");

        // Create a SoundPlayer instance to play the output audio file.
        System.Media.SoundPlayer m_SoundPlayer =
          new System.Media.SoundPlayer(@"C:\test\cultures.wav");

        PromptBuilder cultures = new PromptBuilder(
          new System.Globalization.CultureInfo("en-US"));

        // Present menu options in English, French, and German.
        cultures.AppendText("For English, press 1.");

        cultures.StartVoice(new System.Globalization.CultureInfo("fr-FR"));
        cultures.AppendText("Pour le français, appuyez sur 2");
        cultures.EndVoice();

        cultures.StartVoice(new System.Globalization.CultureInfo("de-DE"));
        cultures.AppendText("Für deutsche, drücken Sie 3");
        cultures.EndVoice();

        // Speak the prompt and play back the output file.
        synth.Speak(cultures);
        m_SoundPlayer.Play();
      }
      Console.WriteLine();
      Console.WriteLine("Press any key to exit...");
      Console.ReadKey();
    }
  }
}

See Also