Lingua

SpeechSynthesizer.Speak Metodo

Definizione

Genera l'output vocale in modo sincrono da una stringa, un Prompt oggetto o un PromptBuilder oggetto .

Overload

Nome Descrizione
Speak(Prompt)

Parla in modo sincrono il contenuto di un Prompt oggetto .

Speak(PromptBuilder)

Parla in modo sincrono il contenuto di un PromptBuilder oggetto .

Speak(String)

Parla in modo sincrono il contenuto di una stringa.

Commenti

I Speak metodi generano il riconoscimento vocale in modo sincrono. I metodi non restituiscono finché il contenuto dell'istanza Speak non è stato pronunciato completamente. Questo è il modo più semplice per generare il parlato. Tuttavia, se l'applicazione deve eseguire attività durante la pronuncia, ad esempio evidenziare testo, disegnare animazione, monitorare controlli o altre attività, usare i SpeakAsync metodi o il SpeakSsmlAsync metodo per generare il parlato in modo asincrono.

Durante una chiamata a questo metodo, SpeechSynthesizer può generare gli eventi seguenti:

  • StateChanged. Generato quando lo stato di pronuncia del sintetizzatore cambia.

  • SpeakStarted. Generato quando il sintetizzatore inizia a generare il parlato.

  • PhonemeReached. Generato ogni volta che il sintetizzatore raggiunge una lettera o una combinazione di lettere che costituiscono un suono discreto del parlato in una lingua.

  • SpeakProgress. Generato ogni volta che il sintetizzatore completa la pronuncia di una parola.

  • VisemeReached. Generato ogni volta che l'output parlato richiede un cambiamento nella posizione della bocca o dei muscoli facciali usati per produrre il parlato.

  • BookmarkReached. Generato quando il sintetizzatore rileva un segnalibro in un prompt.

  • VoiceChange. Generato quando cambia la voce parlante per il sintetizzatore.

L'oggetto SpeechSynthesizer non genera l'evento durante l'elaborazione SpeakCompleted di uno dei Speak metodi .

Speak(Prompt)

Origine:
SpeechSynthesizer.cs
Origine:
SpeechSynthesizer.cs
Origine:
SpeechSynthesizer.cs
Origine:
SpeechSynthesizer.cs

Parla in modo sincrono il contenuto di un Prompt oggetto .

public:
 void Speak(System::Speech::Synthesis::Prompt ^ prompt);
public void Speak(System.Speech.Synthesis.Prompt prompt);
member this.Speak : System.Speech.Synthesis.Prompt -> unit
Public Sub Speak (prompt As Prompt)

Parametri

prompt
Prompt

Contenuto da pronunciare.

Esempio

Nell'esempio seguente viene creato un Prompt oggetto da una stringa e l'oggetto viene passato come argomento al Speak metodo .

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

Commenti

Per pronunciare in modo asincrono il contenuto di un Prompt oggetto , usare SpeakAsync.

Si applica a

Speak(PromptBuilder)

Origine:
SpeechSynthesizer.cs
Origine:
SpeechSynthesizer.cs
Origine:
SpeechSynthesizer.cs
Origine:
SpeechSynthesizer.cs

Parla in modo sincrono il contenuto di un PromptBuilder oggetto .

public:
 void Speak(System::Speech::Synthesis::PromptBuilder ^ promptBuilder);
public void Speak(System.Speech.Synthesis.PromptBuilder promptBuilder);
member this.Speak : System.Speech.Synthesis.PromptBuilder -> unit
Public Sub Speak (promptBuilder As PromptBuilder)

Parametri

promptBuilder
PromptBuilder

Contenuto da pronunciare.

Esempio

Nell'esempio seguente viene creato un PromptBuilder oggetto da una stringa e l'oggetto viene passato come argomento al Speak metodo .

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 PromptBuilder object and append a text string.
        PromptBuilder song = new PromptBuilder();
        song.AppendText("Say the name of the song you want to hear");

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

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

Commenti

Per pronunciare in modo asincrono il contenuto di un PromptBuilder oggetto , usare SpeakAsync.

Si applica a

Speak(String)

Origine:
SpeechSynthesizer.cs
Origine:
SpeechSynthesizer.cs
Origine:
SpeechSynthesizer.cs
Origine:
SpeechSynthesizer.cs

Parla in modo sincrono il contenuto di una stringa.

public:
 void Speak(System::String ^ textToSpeak);
public void Speak(string textToSpeak);
member this.Speak : string -> unit
Public Sub Speak (textToSpeak As String)

Parametri

textToSpeak
String

Testo da pronunciare.

Esempio

Come illustrato nell'esempio seguente, il Speak metodo fornisce i mezzi più semplici per generare l'output vocale in modo sincrono.

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

        // Speak a string synchronously.
        synth.Speak("What is your favorite color?");
      }

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

Commenti

Per pronunciare in modo sincrono una stringa che contiene markup SSML, usare il SpeakSsml metodo . Per pronunciare in modo asincrono il contenuto di una stringa, usare il SpeakAsync metodo .

Si applica a