Freigeben über


Prompt Konstruktoren

Definition

Erstellt eine neue Instanz der Prompt Klasse.

Überlädt

Name Beschreibung
Prompt(PromptBuilder)

Erstellt eine neue Instanz der Prompt Klasse aus einem PromptBuilder Objekt.

Prompt(String)

Erstellt eine neue Instanz der Prompt Klasse und gibt den zu sprechenden Text an.

Prompt(String, SynthesisTextFormat)

Erstellt eine neue Instanz der Prompt Klasse und gibt den zu sprechenden Text an und gibt an, ob es sich bei dem Format um Nur-Text oder Markupsprache handelt.

Prompt(PromptBuilder)

Quelle:
Prompt.cs
Quelle:
Prompt.cs
Quelle:
Prompt.cs
Quelle:
Prompt.cs

Erstellt eine neue Instanz der Prompt Klasse aus einem PromptBuilder Objekt.

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)

Parameter

promptBuilder
PromptBuilder

Der zu sprechende Inhalt.

Gilt für:

Prompt(String)

Quelle:
Prompt.cs
Quelle:
Prompt.cs
Quelle:
Prompt.cs
Quelle:
Prompt.cs

Erstellt eine neue Instanz der Prompt Klasse und gibt den zu sprechenden Text an.

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)

Parameter

textToSpeak
String

Der wiederzugebende Text.

Beispiele

Im folgenden Beispiel wird ein Prompt Objekt aus einer Zeichenfolge erstellt und das Objekt als Argument an die Speak Methode übergeben.

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

Gilt für:

Prompt(String, SynthesisTextFormat)

Quelle:
Prompt.cs
Quelle:
Prompt.cs
Quelle:
Prompt.cs
Quelle:
Prompt.cs

Erstellt eine neue Instanz der Prompt Klasse und gibt den zu sprechenden Text an und gibt an, ob es sich bei dem Format um Nur-Text oder Markupsprache handelt.

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)

Parameter

textToSpeak
String

Der wiederzugebende Text.

media
SynthesisTextFormat

Ein Wert, der das Format des Texts angibt.

Beispiele

Im folgenden Beispiel wird eine Zeichenfolge erstellt, die SSML-Markup enthält, ein Prompt Objekt aus der Zeichenfolge erstellt und die Eingabeaufforderung spricht.

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

Hinweise

Der Inhalt des textToSpeak Parameters muss ein speak Element enthalten und muss der Speech Synthesis Markup Language (SSML) Version 1.0 entsprechen.

Gilt für: