Export (0) Print
Expand All

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
)

Parameters

textToSpeak
Type: System.String

The text to be spoken.

media
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. 
        synth.SetOutputToDefaultAudioDevice();

        // Build an SSML prompt in a string.
        string fileName = "<speak version=\"1.0\" ";
        fileName += "xmlns=\"http://www.w3.org/2001/10/synthesis\" ";
        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.
        synth.Speak(ssmlFile);
      }

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

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft