次の方法で共有


Prompt Constructors

Definition

Creates a new instance of the Prompt class.

Overloads

Prompt(PromptBuilder)

Creates a new instance of the Prompt class from a PromptBuilder object.

Prompt(String)

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

Prompt(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.

Prompt(PromptBuilder)

Source:
Prompt.cs
Source:
Prompt.cs

Creates a new instance of the Prompt class from a PromptBuilder object.

public:
 Prompt(System::Speech::Synthesis::PromptBuilder ^ promptBuilder);
public Prompt (System.Speech.Synthesis.PromptBuilder promptBuilder);
new System.Speech.Synthesis.Prompt : System.Speech.Synthesis.PromptBuilder -> System.Speech.Synthesis.Prompt
Public Sub New (promptBuilder As PromptBuilder)

Parameters

promptBuilder
PromptBuilder

The content to be spoken.

Applies to

Prompt(String)

Source:
Prompt.cs
Source:
Prompt.cs

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

public:
 Prompt(System::String ^ textToSpeak);
public Prompt (string textToSpeak);
new System.Speech.Synthesis.Prompt : string -> System.Speech.Synthesis.Prompt
Public Sub New (textToSpeak As String)

Parameters

textToSpeak
String

The text to be spoken.

Examples

The following example creates a Prompt object from a string and passes the object as an argument to the Speak 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 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();  
    }  
  }  
}  

Applies to

Prompt(String, SynthesisTextFormat)

Source:
Prompt.cs
Source:
Prompt.cs

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.

public:
 Prompt(System::String ^ textToSpeak, System::Speech::Synthesis::SynthesisTextFormat media);
public Prompt (string textToSpeak, System.Speech.Synthesis.SynthesisTextFormat media);
new System.Speech.Synthesis.Prompt : string * System.Speech.Synthesis.SynthesisTextFormat -> System.Speech.Synthesis.Prompt
Public Sub New (textToSpeak As String, media As SynthesisTextFormat)

Parameters

textToSpeak
String

The text to be spoken.

media
SynthesisTextFormat

A value that specifies the format of the text.

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

Remarks

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.

Applies to