SpeechEventInfo.EventId 속성

정의

요청하기 위해 SpeechEventInfo의 인스턴스를 사용하는 음성 플랫폼 이벤트를 가져와 설정합니다.Gets and set the Speech platform event which an instance of SpeechEventInfo is used to request.

public:
 property short EventId { short get(); };
public short EventId { get; }
member this.EventId : int16
Public ReadOnly Property EventId As Short

속성 값

Int16

TtsEventId 개체 가 생성되는 이벤트 형식을 나타내는 SpeechEventInfo의 멤버를 short로 반환합니다.Returns a member of TtsEventId as a short, indicating the event type the SpeechEventInfo object is to generate.

예제

아래 예제에서 상속 하는 사용자 지정 음성 합성 구현의 일부인 TtsEngineSsml, 및을 사용 하 여 TextFragment, SpeechEventInfo, FragmentState, 및 TtsEventIdThe example below is part of a custom speech synthesis implementation inheriting from TtsEngineSsml, and using the use of TextFragment, SpeechEventInfo, FragmentState, and TtsEventId

구현 SpeakThe implementation of Speak

  1. 배열을 받습니다 TextFragment 인스턴스 및 새 배열을 만듭니다 TextFragment 전달 되는 인스턴스는 Speak 기본 합성 엔진에서 메서드.Receives an array of TextFragment instances and creates a new array of TextFragment instances to be passed to the Speak method on an underlying synthesis engine.

  2. 경우는 TtsEngineAction 에서 열거형 값에서 찾을 Action 속성에는 FragmentState 반환한를 State 의 각 속성 TextFragment 인스턴스가 Speak, 구현If the TtsEngineAction enumeration value by found from the Action property on the FragmentState returned by the State property of each TextFragment instance is Speak, the implementation

    • 읽을 텍스트의 Americanism Britishisms 변환 합니다.Translates Americanism to Britishisms in the text to be spoken.

    • 경우는 EventInterest 속성에는 ITtsEngineSite 구현 지원 제공 하는 인터페이스를 WordBoundary 이벤트 유형는 SpeechEventInfo 인스턴스 이벤트 신시사이저 진행률 표시기가 만든 드라이브를 만드는 데 사용 됩니다.If the EventInterest property on the ITtsEngineSite interfaces provided to the implementation support the WordBoundary event type, a SpeechEventInfo instance is used to create an event to drive a synthesizer progress meter is created.

      을 포함 하 여의 매개 변수는 SpeechEventInfo EventId 메서드를 통해 생성 된 이벤트를 기록 하는 데 사용 됩니다 LogSpeechEvent .The parameters on SpeechEventInfo, including EventId are used to log the event generated through the LogSpeechEvent method.

  3. 이라고 하는 음성 렌더링 엔진이 수정 된 TextFragment 배열입니다.A speech rendering engine is then called with the modified TextFragment array.

private const int WordBoundaryFlag = 1 << (int)TtsEventId.WordBoundary;  
private readonly char[] spaces = new char[] { ' ', '\t', '\r', '\n' };  
internal struct UsVsUk  
{  
  internal string UK;  
  internal string US;  
}  

override public void Speak (TextFragment [] frags, IntPtr wfx, ITtsEngineSite site)  
{  
  TextFragment [] newFrags=new TextFragment[frags.Length];  

  for (int i=0;i<frags.Length;i++){  
    newFrags[i].State=frags[i].State;  
    //truncate  
    newFrags[i].TextToSpeak = frags[i].TextToSpeak.Substring(frags[i].TextOffset,  
                               frags[i].TextLength);  
    newFrags[i].TextLength = newFrags[i].TextToSpeak.Length;  
    newFrags[i].TextOffset = 0;  
    if (newFrags[i].State.Action == TtsEngineAction.Speak) {  
      //Us to UK conversion  
      foreach (UsVsUk term in TransList) {  
      newFrags[i].TextToSpeak.Replace(term.US, term.UK);  
      }  
      //Generate progress meter events if supported  
      if ((site.EventInterest & WordBoundaryFlag) != 0) {  
      string[] subs = newFrags[i].TextToSpeak.Split(spaces);  

      foreach (string s in subs) {  
        int offset = newFrags[i].TextOffset;  
        SpeechEventInfo spEvent = new SpeechEventInfo((Int16)TtsEventId.WordBoundary,   
                (Int16)EventParameterType.Undefined,   
                 s.Length, new IntPtr(offset));  
         LogSpeechEvent(spEvent.EventId,   
                        spEvent.ParameterType,   
                        spEvent.Param1,  
                        spEvent.Param2);  
        offset += s.Length;  
        if (s.Trim().Length > 0) {  
          SpeechEventInfo[] events = new SpeechEventInfo[1];  
          events[0] = spEvent;  
          site.AddEvents(events, 1);  
        }  
      }  
      }  
    }  
  }  

  _baseSynthesize.Speak(newFrags, wfx, site);  

}  

적용 대상