Share via


SpeakProgressEventArgs 클래스

정의

SpeakProgress 이벤트에서 데이터를 반환합니다.

public ref class SpeakProgressEventArgs : System::Speech::Synthesis::PromptEventArgs
public class SpeakProgressEventArgs : System.Speech.Synthesis.PromptEventArgs
type SpeakProgressEventArgs = class
    inherit PromptEventArgs
Public Class SpeakProgressEventArgs
Inherits PromptEventArgs
상속

예제

다음 예제에서는 에서 SpeakProgressEventArgs사용할 수 있는 정보를 보여 줍니다. 생성된 SSML에 StartParagraphp>, /p, s 및 /s 태그를 추가하여< , EndParagraph, 및< 메서드가 에 미치는 영향을 확인>합니다. ><CharacterCount<>StartSentenceEndSentence 또한 출력에는 "30%"에 대한 두 개의 항목이 있으며, 각 단어마다 이 숫자 문자열(30%)을 말하는 항목이 하나 있습니다. 및 CharacterPositionCharacterCount 각 항목에 대해 동일하며 문자 "30%를 나타냅니다. 그러나 AudioPosition 의 "30" 및 "percent"라는 단어의 말하기를 반영하도록 변경됩니다 SpeechSynthesizer.

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.SetOutputToWaveFile(@"C:\test\weather.wav");  

        // Create a SoundPlayer instance to play the output audio file.  
        System.Media.SoundPlayer m_SoundPlayer =  
          new System.Media.SoundPlayer(@"C:\test\weather.wav");  

        // Build a prompt containing a paragraph and two sentences.  
        PromptBuilder builder = new PromptBuilder(  
          new System.Globalization.CultureInfo("en-US"));  
        builder.StartParagraph();  
        builder.StartSentence();  
        builder.AppendText(  
          "The weather forecast for today is partly cloudy with some sun breaks.");  
        builder.EndSentence();  
        builder.StartSentence();  
        builder.AppendText(  
          "Tonight's weather will be cloudy with a 30% chance of showers.");  
        builder.EndSentence();  
        builder.EndParagraph();  

        // Add a handler for the SpeakProgress event.  
        synth.SpeakProgress +=  
          new EventHandler<SpeakProgressEventArgs>(synth_SpeakProgress);  

        // Speak the prompt and play back the output file.  
        synth.Speak(builder);  
        m_SoundPlayer.Play();  
      }  

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

    // Write each word and its character position to the console.  
    static void synth_SpeakProgress(object sender, SpeakProgressEventArgs e)  
    {  
      Console.WriteLine("CharPos: {0}   CharCount: {1}   AudioPos: {2}    \"{3}\"",  
        e.CharacterPosition, e.CharacterCount, e.AudioPosition, e.Text);  
    }  
  }  
}  

설명

인스턴스의 SpeakProgressEventArgs 때 생성 되는 SpeechSynthesizer 발생 시키는 개체를 SpeakProgress 이벤트입니다. 는 SpeechSynthesizer , , SpeakAsyncSpeakSsml또는 SpeakSsmlAsync 메서드를 사용하여 프롬프트에서 말하는 각 새 단어에 Speak대해 이 이벤트를 발생합니다.

반환된 데이터는 코드에서 생성하는 SSML(Speech Synthesis Markup Language)을 기반으로 합니다. 에 대해 CharacterCount 반환되는 값에는 공백과 코드에서 생성된 SSML 태그의 문자와 내용이 포함됩니다.

속성

AudioPosition

이벤트의 오디오 위치를 가져옵니다.

Cancelled

비동기 작업이 취소되었는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 AsyncCompletedEventArgs)
CharacterCount

이벤트가 발생하기 직전에 음성으로 변환 된 단어의 문자 수를 가져옵니다.

CharacterPosition

프롬프트의 처음부터 방금 읽은 단어의 첫 번째 문자 바로 앞의 위치까지 문자 및 공백의 수를 가져옵니다.

Error

비동기 작업 중 발생한 오류를 나타내는 값을 가져옵니다.

(다음에서 상속됨 AsyncCompletedEventArgs)
Prompt

이벤트와 관련된 프롬프트를 가져옵니다.

(다음에서 상속됨 PromptEventArgs)
Text

이벤트가 발생할 때 호출된 텍스트입니다.

UserState

비동기 작업의 고유 식별자를 가져옵니다.

(다음에서 상속됨 AsyncCompletedEventArgs)

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
RaiseExceptionIfNecessary()

비동기 작업에 실패한 경우 사용자가 제공한 예외를 발생시킵니다.

(다음에서 상속됨 AsyncCompletedEventArgs)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상