SpeakProgressEventArgs.Text Proprietà

Definizione

Il testo appena pronunciata quando è stato generato l'evento.

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

Valore della proprietà

Restituisce il testo appena pronunciato quando è stato generato l'evento.

Esempio

Nell'esempio seguente viene illustrato il modo in cui l'evento SpeakProgress segnala le CharacterPosition proprietà e Text per le stringhe che contengono numeri.

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);  
    }  
  }  
}  

Commenti

I SpeechSynthesizer numeri normalizzano le parole che corrispondono al modo in cui verrà parlato il numero. Ad esempio, il sintetizzatore parla il numero "4003" come "quattromila tre". Genera un SpeakProgress evento per ognuna delle parole pronunciate. Tuttavia, la Text proprietà per ognuna delle tre parole è la stessa. È il testo "4003" dal prompt.

Si applica a