Поделиться через


SpeakProgressEventArgs.Text Свойство

Определение

текст, который был только что произнесен, когда было создано событие.

public:
 property System::String ^ Text { System::String ^ get(); };
public string Text { get; }
member this.Text : string
Public ReadOnly Property Text As String

Значение свойства

Возвращает текст, который был только что произнесен, когда было создано событие.

Примеры

В следующем примере показано, как SpeakProgress событие сообщает CharacterPosition свойства и Text для строк, содержащих числа.

using System;  
using System.Xml;  
using System.IO;  
using System.Speech.Synthesis;  

namespace SampleSynthesis  
{  
  class Program  
  {  
    static void Main(string[] args)  
    {  

      // Initialize a new instance of the SpeechSynthesizer.  
      using (SpeechSynthesizer synth = new SpeechSynthesizer())  
      {  

        // Configure the audio output.   
        synth.SetOutputToDefaultAudioDevice();  

        // Create an XML Reader from the file, create a PromptBuilder and   
        // append the XmlReader.  
        PromptBuilder builder = new PromptBuilder();  
        builder.AppendText("4003");  

        // Add a handler for the SpeakProgress event.  
        synth.SpeakProgress +=  
          new EventHandler<SpeakProgressEventArgs>(synth_SpeakProgress);  

        // Speak the prompt and play back the output file.  
        synth.Speak(builder);  
      }  

      Console.WriteLine();  
      Console.WriteLine("Press any key to exit...");  
      Console.ReadKey();  
    }  

    // Write each word and its character position to the console.  
    static void synth_SpeakProgress(object sender, SpeakProgressEventArgs e)  
    {  
      Console.WriteLine("Speak progress -    Character position:  {0}    Text:  {1}",  
        e.CharacterPosition, e.Text);  
    }  
  }  
}  

Комментарии

Нормализует SpeechSynthesizer числа для слов, соответствующих тому, как будет произносится число. Например, синтезатор произносит число "4003" как "четыре тысячи три". Он вызывает SpeakProgress событие для каждого из произносимых слов. Однако Text свойство для каждого из трех слов одинаково. Это текст "4003" из командной строки.

Применяется к