Partager via


SpeakProgressEventArgs.Text Propriété

Définition

Texte qui vient d’être parlé lorsque l’événement a été déclenché.

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

Valeur de propriété

Retourne le texte qui vient d’être parlé lorsque l’événement a été déclenché.

Exemples

L’exemple suivant illustre la façon dont l’événement SpeakProgress signale les propriétés et Text les CharacterPosition propriétés des chaînes qui contiennent des nombres.

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

Remarques

Le SpeechSynthesizer nombre normalise les mots qui correspondent à la façon dont le nombre sera prononcé. Par exemple, le synthétiseur parle le nombre « 4003 » comme « quatre mille trois ». Il déclenche un SpeakProgress événement pour chacun des mots prononcés. Toutefois, la Text propriété pour chacun des trois mots est la même. Il s’agit du texte « 4003 » de l’invite.

S’applique à