EventParameterType Enumeração
Definição
Enumera os tipos de ponteiros de dados passados para eventos de síntese de fala.Enumerates the types of data pointers passed to speech synthesis events.
public enum class EventParameterType
public enum EventParameterType
type EventParameterType =
Public Enum EventParameterType
- Herança
Campos
| Object | 2 | Não há suporte no momento.Currently not supported. |
| Pointer | 3 | Não há suporte no momento.Currently not supported. |
| String | 4 | Indica que o argumento |
| Token | 1 | Indica que o argumento |
| Undefined | 0 | Indica que o argumento |
Exemplos
O exemplo a seguir faz parte de uma implementação de síntese de fala personalizada herdada de TtsEngineSsml e usando o uso de TextFragment , SpeechEventInfo , FragmentState e TtsEventId .The following example is part of a custom speech synthesis implementation inheriting from TtsEngineSsml, and using the use of TextFragment, SpeechEventInfo, FragmentState, and TtsEventId.
A implementação deSpeakThe implementation of Speak
Recebe uma matriz de TextFragment instâncias e cria uma nova matriz de TextFragment instâncias a ser passada para o
Speakmétodo em um mecanismo de síntese subjacente.Receives an array of TextFragment instances and creates a new array of TextFragment instances to be passed to theSpeakmethod on an underlying synthesis engine.Se o TtsEngineAction valor de enumeração encontrado na Action propriedade no FragmentState retornado pela State propriedade de cada TextFragment instância for Speak , a implementaçãoIf 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
Traduz o American Britishisms no texto a ser falado.Translates Americanism to Britishisms in the text to be spoken.
Se a EventInterest Propriedade nas ITtsEngineSite interfaces fornecidas para a implementação oferecer suporte ao WordBoundary tipo de evento, uma SpeechEventInfo instância será usada para criar um evento para gerar um medidor de progresso do sintetizador criado.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.
Os parâmetros on SpeechEventInfo , incluindo o EventParameterType valor do membro retornado por ParameterType , são usados para registrar o evento gerado por meio do
LogSpeechEventmétodo.The parameters on SpeechEventInfo, including the EventParameterType member value returned by ParameterType, are used to log the event generated through theLogSpeechEventmethod.
Um mecanismo de renderização de fala é chamado com a TextFragment matriz modificada.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);
}
Comentários
A EventParameterType enumeração é usada ao construir um SpeechEventInfo objeto.The EventParameterType enumeration is used when constructing a SpeechEventInfo object. Um EventParameterType membro de enumeração passado como o parameterType argumento para o construtor SpeechEventInfo especifica como o param2 argumento do Construtor (que deve ser um IntPtr ) é interpretado.An EventParameterType enumeration member passed as the parameterType argument to the constructor for SpeechEventInfo specifies how the param2 argument of the constructor (which must be an IntPtr) is interpreted.
A escolha de EventParameterType é ditada pelo tipo de evento que está sendo solicitado, conforme especificado por um membro de System.Speech.Synthesis.TtsEngine.TtsEventId .The choice of EventParameterType is dictated by the type of event being requested, as specified by a member of System.Speech.Synthesis.TtsEngine.TtsEventId.
Para obter informações detalhadas sobre como usar EventParameterType o, consulte a documentação doEventIdFor detailed information on how use EventParameterType, see the documentation for EventId
Observação
Atualmente, as instâncias de mecanismos de fala sintéticos gerenciados escritos usando os membros do System.Speech.Synthesis namespace não podem alterar os recursos após a construção.Currently, instances of a managed synthetic speech engines written using the members of the System.Speech.Synthesis namespace cannot change resources after construction.