SpeakProgressEventArgs 类   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从 SpeakProgress 事件返回数据。
public ref class SpeakProgressEventArgs : System::Speech::Synthesis::PromptEventArgspublic class SpeakProgressEventArgs : System.Speech.Synthesis.PromptEventArgstype SpeakProgressEventArgs = class
    inherit PromptEventArgsPublic Class SpeakProgressEventArgs
Inherits PromptEventArgs- 继承
示例
以下示例演示了 可从 SpeakProgressEventArgs获取的信息。 StartParagraph请注意 、EndParagraph、 StartSentence和 EndSentence 方法通过向生成的 SSML 添加 <p>、</p>、<s> 和 </s> 标记对 的影响CharacterCount。 此外,输出中还有两个“30%”条目,每个单词一个条目用于说出此数字字符串 (百分之三十) 。 CharacterCount每个条目的 和 CharacterPosition 都相同,表示字符“30%。 然而,这些 AudioPosition 变化反映了 “30” 和 “百分比” 的 SpeechSynthesizer话语。
using System;  
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.SetOutputToWaveFile(@"C:\test\weather.wav");  
        // Create a SoundPlayer instance to play the output audio file.  
        System.Media.SoundPlayer m_SoundPlayer =  
          new System.Media.SoundPlayer(@"C:\test\weather.wav");  
        // Build a prompt containing a paragraph and two sentences.  
        PromptBuilder builder = new PromptBuilder(  
          new System.Globalization.CultureInfo("en-US"));  
        builder.StartParagraph();  
        builder.StartSentence();  
        builder.AppendText(  
          "The weather forecast for today is partly cloudy with some sun breaks.");  
        builder.EndSentence();  
        builder.StartSentence();  
        builder.AppendText(  
          "Tonight's weather will be cloudy with a 30% chance of showers.");  
        builder.EndSentence();  
        builder.EndParagraph();  
        // 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);  
        m_SoundPlayer.Play();  
      }  
      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("CharPos: {0}   CharCount: {1}   AudioPos: {2}    \"{3}\"",  
        e.CharacterPosition, e.CharacterCount, e.AudioPosition, e.Text);  
    }  
  }  
}  
注解
当 对象引发 事件时SpeechSynthesizer,会创建 的SpeakProgress实例SpeakProgressEventArgs。 SpeechSynthesizer使用任何 Speak、SpeakAsync、 SpeakSsml或 SpeakSsmlAsync 方法,针对它在提示中说出的每个新单词引发此事件。
返回的数据基于代码生成的语音合成标记语言 (SSML) 。 为 CharacterCount 返回的值包括空格,以及代码生成的 SSML 标记的字符和内容。
属性
| AudioPosition | 获取事件的音频位置。 | 
| Cancelled | 获取一个值,该值指示异步操作是否已被取消。(继承自 AsyncCompletedEventArgs) | 
| CharacterCount | 获取事件引发之前刚刚说出的单词中的字符数。 | 
| CharacterPosition | 获取从提示开始到刚刚说出的单词的第一字母之前的位置的字符与空格数。 | 
| Error | 获取一个值,该值指示异步操作期间发生的错误。(继承自 AsyncCompletedEventArgs) | 
| Prompt | 获取与事件关联的提示。(继承自 PromptEventArgs) | 
| Text | 引发事件时只读的文本。 | 
| UserState | 获取异步任务的唯一标识符。(继承自 AsyncCompletedEventArgs) | 
方法
| Equals(Object) | 确定指定对象是否等于当前对象。(继承自 Object) | 
| GetHashCode() | 作为默认哈希函数。(继承自 Object) | 
| GetType() | 获取当前实例的 Type。(继承自 Object) | 
| MemberwiseClone() | 创建当前 Object 的浅表副本。(继承自 Object) | 
| RaiseExceptionIfNecessary() | 如果异步操作失败,则引发用户提供的异常。(继承自 AsyncCompletedEventArgs) | 
| ToString() | 返回表示当前对象的字符串。(继承自 Object) |