SpeakProgressEventArgs Clase

Definición

Devuelve datos del evento SpeakProgress.

public ref class SpeakProgressEventArgs : System::Speech::Synthesis::PromptEventArgs
public class SpeakProgressEventArgs : System.Speech.Synthesis.PromptEventArgs
type SpeakProgressEventArgs = class
    inherit PromptEventArgs
Public Class SpeakProgressEventArgs
Inherits PromptEventArgs
Herencia

Ejemplos

En el ejemplo siguiente se muestra la información disponible en SpeakProgressEventArgs. Observe cómo afectan los StartParagraphmétodos CharacterCount , StartSentenceEndParagraph, y EndSentence mediante su adición de <etiquetas p>, </p>, <s> y </s> al SSML generado. Además, hay dos entradas en la salida para "30%", una para cada palabra para hablar esta cadena numérica (treinta por ciento). y CharacterCountCharacterPosition son los mismos para cada entrada y representan los caracteres "30%. Sin embargo, los AudioPosition cambios para reflejar el habla de las palabras "treinta" y "porcentaje" por .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);  
    }  
  }  
}  

Comentarios

Se crea una instancia de SpeakProgressEventArgs cuando el SpeechSynthesizer objeto genera el SpeakProgress evento . SpeechSynthesizer genera este evento para cada nueva palabra que habla en un símbolo del sistema mediante cualquiera de los Speakmétodos , SpeakAsync, SpeakSsmlo SpeakSsmlAsync .

Los datos devueltos se basan en el lenguaje de marcado de síntesis de voz (SSML) que genera el código. Los valores devueltos para CharacterCount incluyen espacios y los caracteres y el contenido de las etiquetas SSML generadas por el código.

Propiedades

AudioPosition

Obtiene la posición del sonido del evento.

Cancelled

Obtiene un valor que indica si se ha cancelado una operación asincrónica.

(Heredado de AsyncCompletedEventArgs)
CharacterCount

Obtiene el número de caracteres de la palabra que se acaba de pronunciar justo antes de que el evento se haya generado.

CharacterPosition

Obtiene el número de caracteres y espacios desde el inicio del indicador hasta la posición delante de la primera letra de la palabra que acaba de pronunciarse.

Error

Obtiene un valor que indica el error que se produjo durante una operación asincrónica.

(Heredado de AsyncCompletedEventArgs)
Prompt

Obtiene la petición asociada al evento.

(Heredado de PromptEventArgs)
Text

El texto que acaba de pronunciarse cuando se generó el evento.

UserState

Obtiene el identificador único de la tarea asincrónica.

(Heredado de AsyncCompletedEventArgs)

Métodos

Equals(Object)

Determina si el objeto especificado es igual que el objeto actual.

(Heredado de Object)
GetHashCode()

Sirve como la función hash predeterminada.

(Heredado de Object)
GetType()

Obtiene el Type de la instancia actual.

(Heredado de Object)
MemberwiseClone()

Crea una copia superficial del Object actual.

(Heredado de Object)
RaiseExceptionIfNecessary()

Genera una excepción proporcionada por el usuario si se ha producido un error en una operación asincrónica.

(Heredado de AsyncCompletedEventArgs)
ToString()

Devuelve una cadena que representa el objeto actual.

(Heredado de Object)

Se aplica a