TtsEngineSsml.Speak(TextFragment[], IntPtr, ITtsEngineSite) TtsEngineSsml.Speak(TextFragment[], IntPtr, ITtsEngineSite) TtsEngineSsml.Speak(TextFragment[], IntPtr, ITtsEngineSite) TtsEngineSsml.Speak(TextFragment[], IntPtr, ITtsEngineSite) Method

Definición

Presenta la matriz TextFragment indicada en el formato de salida especificado.Renders specified TextFragment array in the specified output format.

public:
 abstract void Speak(cli::array <System::Speech::Synthesis::TtsEngine::TextFragment ^> ^ fragment, IntPtr waveHeader, System::Speech::Synthesis::TtsEngine::ITtsEngineSite ^ site);
public abstract void Speak (System.Speech.Synthesis.TtsEngine.TextFragment[] fragment, IntPtr waveHeader, System.Speech.Synthesis.TtsEngine.ITtsEngineSite site);
abstract member Speak : System.Speech.Synthesis.TtsEngine.TextFragment[] * nativeint * System.Speech.Synthesis.TtsEngine.ITtsEngineSite -> unit
Public MustOverride Sub Speak (fragment As TextFragment(), waveHeader As IntPtr, site As ITtsEngineSite)

Parámetros

fragment
TextFragment[]

Una matriz de instancias de TextFragment que contienen el texto que se convertirá en voz.An array of TextFragment instances containing the text to be rendered into speech.

waveHeader
IntPtr IntPtr IntPtr IntPtr

IntPtr que señala a una estructura que contiene formato de salida de audio.An IntPtr pointing to a structure containing audio output format.

site
ITtsEngineSite ITtsEngineSite ITtsEngineSite ITtsEngineSite

Una referencia a una interfaz ITtsEngineSite pasada por la infraestructura de la plataforma para permitir el acceso a los recursos de la infraestructura.A reference to an ITtsEngineSite interface passed in by the platform infrastructure to allow access to the infrastructure resources.

Ejemplos

El ejemplo siguiente es parte de una implementación de síntesis de voz personalizado hereda de TtsEngineSsmly el uso de la utilización de TextFragment, SpeechEventInfo, FragmentState, y TtsEventIdThe example below is part of a custom speech synthesis implementation inheriting from TtsEngineSsml, and using the use of TextFragment, SpeechEventInfo, FragmentState, and TtsEventId

La implementación de SpeakThe implementation of Speak

  1. Recibe una matriz de TextFragment instancias y crea una nueva matriz de TextFragment instancias que se pasarán a la Speak método en un motor de síntesis subyacente.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. Si el TtsEngineAction por se encuentra el valor de enumeración de la Action propiedad en el FragmentState devuelto por la State propiedad de cada uno TextFragment instancia es Speak, la implementaciónIf 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 a Britishisms se traduce en el texto que se hablará.Translates Americanism to Britishisms in the text to be spoken.

    • Si el EventInterest propiedad en el ITtsEngineSite interfaces proporcionadas con el soporte técnico de implementación el WordBoundary tipo de evento, un SpeechEventInfo instancia se utiliza para crear un evento a la unidad que se crea un indicador de progreso de sintetizador.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.

  3. A continuación, se llama a un motor de representación de voz con modificado TextFragment matriz.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));  
        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);  

}  

Comentarios

La estructura utilizada como waveHeader y devuelto por el método debe compatible con la WAVEFORMATEX disponible en SAPI.The structure used as waveHeader and returned by the method should compatible with the WAVEFORMATEX available under SAPI.

El struct debe proporcionar la funcionalidad equivalente para:The struct must provide functionality equivalent to:

internal struct WaveFormat  
{  
    public Int16 FormatTag;  
    public Int16 Channels;  
    public int SamplesPerSec;  
    public int AvgBytesPerSec;  
    public Int16 BlockAlign;  
    public Int16 BitsPerSample;  
    public Int16 Size;  
}  

Notas a los desarrolladores de herederos

Implementa la sintetizador de voz personalizados con TtsEngineSsml y Speak(TextFragment[], IntPtr, ITtsEngineSite) profesional como filtros o intermediarios entre aplicaciones sintetizador construidos con la infraestructura de plataforma a través de los miembros de la System.Speech.Synthesis espacio de nombres y motores de síntesis de voz de sistema subyacente.Custom speech synthesizer implements using TtsEngineSsml and Speak(TextFragment[], IntPtr, ITtsEngineSite) work as filters or intermediaries between synthesizer applications constructed using the platform infrastructure through the members of the System.Speech.Synthesis namespace and underlying system speech synthesis engines.

Un Speak(TextFragment[], IntPtr, ITtsEngineSite) implementación:A Speak(TextFragment[], IntPtr, ITtsEngineSite) implementation: 1.1. Intercepta o modificar aspectos del entrante TextFragment objetosTraps or modify aspects of the incoming TextFragment objects 2.2. Genera los eventos necesarios mediante la referencia del sitio para un ITtsEngineSite instanciaGenerates any necessary events using the site reference to a ITtsEngineSite instance 3.3. Genera la voz sintetizada real.Generates the actual synthesized speech.

Generación de voz más normalmente se realiza mediante una llamada a Speak en uno de la proporcionados por el sistema operativo de los motores de representación de voz.Generation of speech is most typically done by calling Speak on one of the speech rendering engines provided by the operating system.

Si uno de los motores de procesamiento de voz disponibles no se usa, un objeto que herede de TtsEngineSsml debe crear su propio motor de procesamiento de voz.If one of the available speech rendering engines is not used, a object inheriting from TtsEngineSsml must create its own speech rendering engine.

El acceso a la Speak método sobre el uso de obtenida del registro y la reflexión.Access to the Speak method on obtained using the registry and reflection. ..

Al heredar de TtsEngineSsml, debe reemplazar los miembros siguientes: TtsEngineSsml(String), AddLexicon(Uri, String, ITtsEngineSite), RemoveLexicon(Uri, ITtsEngineSite), GetOutputFormat(SpeakOutputFormat, IntPtr), y Speak(TextFragment[], IntPtr, ITtsEngineSite).When you inherit from TtsEngineSsml, you must override the following members: TtsEngineSsml(String), AddLexicon(Uri, String, ITtsEngineSite), RemoveLexicon(Uri, ITtsEngineSite), GetOutputFormat(SpeakOutputFormat, IntPtr), and Speak(TextFragment[], IntPtr, ITtsEngineSite).

Se aplica a