Export (0) Print
Expand All

PromptBuilder.StartSentence Method

Specifies the start of a sentence in the PromptBuilder object.

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

public void StartSentence()

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

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();
    }
  }
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4
Show:
© 2015 Microsoft