PromptBuilder.AppendText Method (String)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Specifies text to append to the PromptBuilder object.

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

public void AppendText(
	string textToSpeak
)

Parameters

textToSpeak
Type: System.String

A string containing the text to be spoken.

To append text that is formatted as SSML markup language, use AppendSsmlMarkup.

The example that follows creates a PromptBuilder object and appends a text string using the AppendText method.

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 append a text string.
        PromptBuilder speakText = new PromptBuilder();
        speakText.AppendText("Say the name of the song you want to hear");

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

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

.NET Framework
Available since 3.0
Return to top
Show: