Share via


Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

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:  Microsoft.Speech.Synthesis
Assembly:  Microsoft.Speech (in Microsoft.Speech.dll)

Syntax

'Declaration
Public Sub New ( _
    textToSpeak As String, _
    media As SynthesisTextFormat _
)
'Usage
Dim textToSpeak As String
Dim media As SynthesisTextFormat

Dim instance As New Prompt(textToSpeak, _
    media)
public Prompt(
    string textToSpeak,
    SynthesisTextFormat media
)

Parameters

Examples

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

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

See Also

Reference

Prompt Class

Prompt Members

Prompt Overload

Microsoft.Speech.Synthesis Namespace