Note
Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.
PromptBuilder.StartSentence Method (CultureInfo)
Specifies the start of a sentence in the specified culture in the PromptBuilder object.
Namespace: Microsoft.Speech.Synthesis
Assembly: Microsoft.Speech (in Microsoft.Speech.dll)
Syntax
'Declaration
Public Sub StartSentence ( _
culture As CultureInfo _
)
'Usage
Dim instance As PromptBuilder
Dim culture As CultureInfo
instance.StartSentence(culture)
public void StartSentence(
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
Long prompts can be rendered more like human speech if they are broken into sentences and paragraphs.
The culture parameter for a sentence can be different than the culture parameter for the paragraph that contains the sentence or the Culture property of the PromptBuilder object that contains them.
While in effect, the value of the culture parameter will override the Culture property and the culture parameter for the paragraph that contains the sentence. The SpeechSynthesizer will attempt to select an installed voice that supports the language specified by the culture parameter to speak the sentence. 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. To stop using the voice specified by StartSentence(CultureInfo), call EndSentence().
A voice is an installed Runtime Language for speech synthesis (TTS, or text-to-speech). The Microsoft Speech Platform Runtime 11 and Microsoft Speech Platform SDK 11 do not include any Runtime Languages for speech synthesis. You must download and install a Runtime Language for each language in which you want to generate synthesized speech. A Runtime Language includes the language model, acoustic model, and other data necessary to provision a speech engine to perform speech synthesis in a particular language. See InstalledVoice for more information.
To correctly pronounce words in the language specified by the culture parameter, a Runtime Language for speech synthesis that supports that language code must be installed. To get information about which voices are installed for a specific culture, use the GetInstalledVoices(CultureInfo) method.
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.
Examples
The following example creates a PromptBuilder object that counts to ten; beginning in English, then in French, and finishing in German. Correct pronunciation of all the numbers will only be achieved if Runtime Languages 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 StartParagraph(CultureInfo) and StartSentence(CultureInfo) constructors. If no language is specified in a prompt, or if the specified language is not installed, SpeechSynthesizer object uses the default language for the host system.
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();
// Count in English.
cultures.StartParagraph(
new System.Globalization.CultureInfo("en-US"));
cultures.AppendText("one, two, three");
// Count in French.
cultures.StartSentence(
new System.Globalization.CultureInfo("fr-FR"));
cultures.AppendText("quatre, cinq, six");
cultures.EndSentence();
// Count in German.
cultures.StartSentence(
new System.Globalization.CultureInfo("de-DE"));
cultures.AppendText("sieben, acht, neun, zehn");
cultures.EndSentence();
cultures.EndParagraph();
// 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();
}
}
}