SpeechEventInfo.EventId SpeechEventInfo.EventId SpeechEventInfo.EventId SpeechEventInfo.EventId Property

Definizione

Ottiene e imposta l'evento della piattaforma di riconoscimento vocale richiesto da un'istanza di 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

Valore della proprietà

Restituisce un membro di TtsEventId come short indicante il tipo di evento che verrà generato dall'oggetto SpeechEventInfo.Returns a member of TtsEventId as a short, indicating the event type the SpeechEventInfo object is to generate.

Esempi

L'esempio seguente fa parte di un'implementazione di sintesi vocale personalizzata che eredita TtsEngineSsmlda e usando l'uso di TextFragment, SpeechEventInfo FragmentState, eTtsEventIdThe example below is part of a custom speech synthesis implementation inheriting from TtsEngineSsml, and using the use of TextFragment, SpeechEventInfo, FragmentState, and TtsEventId

Implementazione diSpeakThe implementation of Speak

  1. Riceve una matrice di TextFragment istanze e crea una nuova matrice di TextFragment istanze Speak da passare al metodo su un motore di sintesi sottostante.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. Se il TtsEngineAction valore di enumerazione trovato Action dalla proprietà nell'oggetto FragmentState restituito dalla State proprietà di ogni TextFragment istanza è Speak, l'implementazione diIf 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

    • Converte l'americano in Britishisms nel testo da pronunciare.Translates Americanism to Britishisms in the text to be spoken.

    • Se la EventInterest proprietà ITtsEngineSite nelle interfacce fornite all'implementazione di supporta il WordBoundary tipo di evento, viene SpeechEventInfo utilizzata un'istanza per creare un evento per la creazione di un indicatore di stato del sintetizzatore.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.

      I parametri in SpeechEventInfo, inclusi EventId vengono usati per registrare l'evento generato tramite il LogSpeechEvent metodo.The parameters on SpeechEventInfo, including EventId are used to log the event generated through the LogSpeechEvent method.

  3. Viene quindi chiamato un motore di rendering vocale con la TextFragment matrice modificata.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);  
  
}  

Si applica a