Prompt Constructor (String, SynthesisTextFormat)


Creates a new instance of the Prompt class and specifies the text to be spoken and whether its format is plain text or markup language.

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

public Prompt(
	string textToSpeak,
	SynthesisTextFormat media


Type: System.String

The text to be spoken.

Type: System.Speech.Synthesis.SynthesisTextFormat

A value that specifies the format of the text.

The contents of the textToSpeak parameter must include a speak element and must conform to the Speech Synthesis Markup Language (SSML) Version 1.0. For more information, see Speech Synthesis Markup Language Reference.

The following example builds a string that contains SSML markup, creates a Prompt object from the string, and speaks the prompt.

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. 

        // Build an SSML prompt in a string.
        string fileName = "<speak version=\"1.0\" ";
        fileName += "xmlns=\"\" ";
        fileName += "xml:lang=\"en-US\">";
        fileName += "Say a name for the new file <mark name=\"fileName\" />.";
        fileName += "</speak>";

        // Create a Prompt object from the string.
        Prompt ssmlFile = new Prompt(fileName, SynthesisTextFormat.Ssml);

        // Speak the contents of the SSML prompt.

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

.NET Framework
Available since 3.0
Return to top