TextFragment.TextToSpeak Propiedad

Definición

Obtiene o establece el texto de voz del fragmento.Sets or gets the speech text of the fragment.

public:
 property System::String ^ TextToSpeak { System::String ^ get(); void set(System::String ^ value); };
public string TextToSpeak { get; set; }
member this.TextToSpeak : string with get, set
Public Property TextToSpeak As String

Valor de propiedad

System.String se devuelve o se puede usar para establecer el texto de voz que se usará en un motor de síntesis de voz para generar la salida de sonido.A System.String is returned or can be used to set the speech text to be used by a speech synthesis engine to generate audio output.

Ejemplos

El ejemplo siguiente forma parte de una implementación de síntesis de voz personalizada que TtsEngineSsmlhereda de y usa el uso TextFragmentde SpeechEventInfo, FragmentState, y TtsEventId.The 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 deSpeakThe implementation of Speak

  1. Recibe una matriz de TextFragment instancias de y crea una nueva matriz TextFragment de instancias de Speak que se van a pasar al 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.

    La atención especial se usa para respetar TextOffsetel TextLength , en TextToSpeak el TextFragment original al crear en las nuevas TextFragment instancias.Particular care is used to respect the TextOffset, TextLength on the original TextFragment when creating the TextToSpeak on the new TextFragment instances.

  2. Si el TtsEngineAction valor de enumeración que se Action encuentra en la FragmentState propiedad en la State devuelta por TextFragment la propiedad Speakde cada instancia es, 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

    • Traduce el Americanism a Britishisms en el texto que se va a hablar.Translates Americanism to Britishisms in the text to be spoken.

    • Si la EventInterest propiedad de las ITtsEngineSite interfaces proporcionadas a la implementación admite WordBoundary el tipo de evento SpeechEventInfo , se usa una instancia de para crear un evento para impulsar la creación de 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 TextFragment voz con la 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));  
        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

El valor predeterminado de esta propiedad es System.String.Empty.The default value of this property is System.String.Empty.

Las aplicaciones pueden cambiar completamente el valor de TextToSpeak.Applications are free to completely change the value of TextToSpeak.

Al restablecer el valor de TextToSpeak , no se cambiará el TextOffset valor TextLengthde y.Resetting the value of TextToSpeak will not change the value of TextOffset and TextLength.

Se aplica a