共用方式為


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」。

適用於