Partager via


PromptBuilder.StartSentence Method

Definition

Specifies the start of a sentence in the PromptBuilder object, and optionally specifies a language.

Overloads

StartSentence()

Specifies the start of a sentence in the PromptBuilder object.

StartSentence(CultureInfo)

Specifies the start of a sentence in the specified culture in the PromptBuilder object.

Remarks

Long prompts can be rendered more like human speech if they are broken into sentences and paragraphs.

StartSentence()

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs

Specifies the start of a sentence in the PromptBuilder object.

public:
 void StartSentence();
public void StartSentence ();
member this.StartSentence : unit -> unit
Public Sub StartSentence ()

Examples

The following example creates a PromptBuilder object, appends content, and organizes the content into paragraphs and sentences.

using System;  
using System.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.SetOutputToDefaultAudioDevice();  

        // Create a PromptBuilder object and add content as paragraphs and sentences.  
        PromptBuilder parSent = new PromptBuilder();  
        parSent.StartParagraph();  
        parSent.StartSentence();  
        parSent.AppendText("Introducing the sentence element.");  
        parSent.EndSentence();  
        parSent.StartSentence();  
        parSent.AppendText("You can use it to mark individual sentences.");  
        parSent.EndSentence();  
        parSent.EndParagraph();  
        parSent.StartParagraph();  
        parSent.AppendText("Another simple paragraph. Sentence structure in this paragraph" +  
          "is not explicitly marked.");  
        parSent.EndParagraph();  

        // Speak the contents of the SSML prompt.  
        synth.Speak(parSent);  
      }  

      Console.WriteLine();  
      Console.WriteLine("Press any key to exit...");  
      Console.ReadKey();  
    }  
  }  
}  

Remarks

Long prompts can be rendered more like human speech if they are broken into sentences and paragraphs.

Applies to

StartSentence(CultureInfo)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs

Specifies the start of a sentence in the specified culture in the PromptBuilder object.

public:
 void StartSentence(System::Globalization::CultureInfo ^ culture);
public void StartSentence (System.Globalization.CultureInfo culture);
member this.StartSentence : System.Globalization.CultureInfo -> unit
Public Sub StartSentence (culture As CultureInfo)

Parameters

culture
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, call EndSentence.

To correctly pronounce words in the language specified by the culture parameter, a speech synthesis (text-to-speech or TTS) engine that supports the language must be installed. An installed TTS engine is called a voice. To get information about which voices are installed for a specific culture, use the GetInstalledVoices method.

Microsoft Windows and the System.Speech API accept all valid language-country codes as values for culture. The TTS engines that shipped with Windows 7 support the following language-country codes:

  • en-US. English (United States)

  • zh-CN. Chinese (China)

  • zh-TW. Chinese (Taiwan)

Two-letter language codes such as "en" are also permitted.

Applies to