SpeechSynthesizer.SpeakAsync 메서드

정의

문자열, Prompt 개체 또는 PromptBuilder 개체로부터 음성 출력을 비동기적으로 생성합니다.

오버로드

SpeakAsync(Prompt)

Prompt 개체의 내용을 비동기적으로 말합니다.

SpeakAsync(PromptBuilder)

PromptBuilder 개체의 내용을 비동기적으로 말합니다.

SpeakAsync(String)

문자열의 내용을 비동기적으로 말합니다.

설명

메서드는 SpeakAsync 음성을 비동기적으로 생성합니다. 메서드는 개체의 SpeakAsync 내용이 말하기를 마칠 때까지 기다리지 않고 즉시 반환됩니다. 사용 하 여 SpeakAsync 애플리케이션을 말하는 동안 작업을 수행, 예를 들어 텍스트 강조 표시 하는 경우 그리기 애니메이션, 모니터 컨트롤 또는 기타 작업.

이 메서드를 호출하는 동안 은 SpeechSynthesizer 다음 이벤트를 발생할 수 있습니다.

  • StateChanged. 신시사이저의 말하기 상태가 변경될 때 발생합니다.

  • SpeakStarted. 신시사이저가 음성 생성을 시작할 때 발생합니다.

  • PhonemeReached. 신시사이저가 언어의 신중한 음성 소리를 구성하는 문자 또는 문자 조합에 도달할 때마다 발생합니다.

  • SpeakProgress. 신시사이저가 단어를 말하기를 완료할 때마다 발생합니다.

  • VisemeReached. 음성 출력이 발생할 때마다 발생하려면 음성을 생성하는 데 사용되는 입이나 얼굴 근육의 위치를 변경해야 합니다.

  • BookmarkReached. 신시사이저가 프롬프트에서 책갈피를 발견하면 발생합니다.

  • VoiceChange. 신시사이저에 대한 말하기 음성이 변경될 때 발생합니다.

  • SpeakCompleted. 신시사이저가 작업을 완료할 때 발생합니다 SpeakAsync .

애플리케이션 말하는 동안 작업을 수행할 필요가 없습니다, 하는 경우 사용할 수 있습니다 합니다 Speak 메서드 또는 SpeakSsml 음성을 동기적으로 생성 하는 방법입니다.

SpeakAsync(Prompt)

Source:
SpeechSynthesizer.cs
Source:
SpeechSynthesizer.cs
Source:
SpeechSynthesizer.cs

Prompt 개체의 내용을 비동기적으로 말합니다.

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

매개 변수

prompt
Prompt

말할 콘텐츠입니다.

예제

다음 예제에서는 Prompt 개체를 문자열에서 개체를 인수로 전달 합니다 SpeakAsync 메서드.

using System;
using System.Speech.Synthesis;

namespace SampleSynthesis
{
  class Program
  {
    static void Main(string[] args)
    {

      // Initialize a new instance of the SpeechSynthesizer.
      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 asynchronously.
      synth.SpeakAsync(color);

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

설명

또는 메서드를 사용하여 프롬프트의 비동기 음성을 취소할 SpeakAsyncCancelSpeakAsyncCancelAll 수 있습니다.

개체의 Prompt 내용을 동기적으로 말하려면 를 사용합니다 Speak.

이 메서드는 메서드의 동기 대응에서 throw할 수 있는 모든 비사용 예외를 반환하는 태스크에 저장됩니다. 예외가 반환된 작업에 저장되면 작업이 대기될 때 해당 예외가 throw됩니다. 와 같은 ArgumentException사용 예외는 여전히 동기적으로 throw됩니다. 저장된 예외는 에서 throw Speak(Prompt)된 예외를 참조하세요.

적용 대상

SpeakAsync(PromptBuilder)

Source:
SpeechSynthesizer.cs
Source:
SpeechSynthesizer.cs
Source:
SpeechSynthesizer.cs

PromptBuilder 개체의 내용을 비동기적으로 말합니다.

public:
 System::Speech::Synthesis::Prompt ^ SpeakAsync(System::Speech::Synthesis::PromptBuilder ^ promptBuilder);
public System.Speech.Synthesis.Prompt SpeakAsync (System.Speech.Synthesis.PromptBuilder promptBuilder);
member this.SpeakAsync : System.Speech.Synthesis.PromptBuilder -> System.Speech.Synthesis.Prompt
Public Function SpeakAsync (promptBuilder As PromptBuilder) As Prompt

매개 변수

promptBuilder
PromptBuilder

말할 콘텐츠입니다.

반환

말할 내용이 들어 있는 개체입니다.

예제

다음 예제에서는 PromptBuilder 개체를 문자열에서 개체를 인수로 전달 합니다 SpeakAsync 메서드.

using System;
using System.Speech.Synthesis;

namespace SampleSynthesis
{
  class Program
  {
    static void Main(string[] args)
    {

      // Initialize a new instance of the SpeechSynthesizer.
      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 asynchronously.
      synth.SpeakAsync(song);

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

이 메서드는 메서드의 동기 대응에서 throw할 수 있는 모든 비사용 예외를 반환하는 태스크에 저장됩니다. 예외가 반환된 작업에 저장되면 작업이 대기될 때 해당 예외가 throw됩니다. 와 같은 ArgumentException사용 예외는 여전히 동기적으로 throw됩니다. 저장된 예외는 에서 throw Speak(PromptBuilder)된 예외를 참조하세요.

설명

개체의 PromptBuilder 내용을 동기적으로 말하려면 를 사용합니다 Speak.

적용 대상

SpeakAsync(String)

Source:
SpeechSynthesizer.cs
Source:
SpeechSynthesizer.cs
Source:
SpeechSynthesizer.cs

문자열의 내용을 비동기적으로 말합니다.

public:
 System::Speech::Synthesis::Prompt ^ SpeakAsync(System::String ^ textToSpeak);
public System.Speech.Synthesis.Prompt SpeakAsync (string textToSpeak);
member this.SpeakAsync : string -> System.Speech.Synthesis.Prompt
Public Function SpeakAsync (textToSpeak As String) As Prompt

매개 변수

textToSpeak
String

읽을 텍스트입니다.

반환

말할 내용이 들어 있는 개체입니다.

예제

다음 예제와 같이 메서드는 SpeakAsync 음성 출력을 비동기적으로 생성하는 가장 간단한 방법을 제공합니다.

using System;
using System.Speech.Synthesis;

namespace SampleSynthesis
{
  class Program
  {
    static void Main(string[] args)
    {

      // Initialize a new instance of the SpeechSynthesizer.
      SpeechSynthesizer synth = new SpeechSynthesizer();

      // Configure the audio output.
      synth.SetOutputToDefaultAudioDevice();

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

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

설명

SSML 태그가 포함된 문자열을 비동기적으로 말하려면 메서드를 SpeakSsmlAsync 사용합니다. 문자열의 내용을 동기적으로 말하려면 메서드를 Speak 사용합니다. 또는 메서드를 사용하여 프롬프트의 비동기 음성을 취소할 SpeakAsyncCancelSpeakAsyncCancelAll 수 있습니다.

이 메서드는 메서드의 동기 대응에서 throw할 수 있는 모든 비사용 예외를 반환하는 태스크에 저장됩니다. 예외가 반환된 작업에 저장되면 작업이 대기될 때 해당 예외가 throw됩니다. 와 같은 ArgumentException사용 예외는 여전히 동기적으로 throw됩니다. 저장된 예외는 에서 throw Speak(String)된 예외를 참조하세요.

추가 정보

적용 대상