Share via


Note

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

Prompt Constructor (String)

Creates a new instance of the Prompt class and specifies the text to be spoken.

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

Syntax

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

Dim instance As New Prompt(textToSpeak)
public Prompt(
    string textToSpeak
)

Parameters

Examples

The following example creates a Prompt object from a string, and passes the object as an argument to the Speak(Prompt) method.

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

        // Create a prompt from a string.
        Prompt color = new Prompt("What is your favorite color?");

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

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

See Also

Reference

Prompt Class

Prompt Members

Prompt Overload

Microsoft.Speech.Synthesis Namespace