SpeakProgressEventArgs SpeakProgressEventArgs SpeakProgressEventArgs SpeakProgressEventArgs Class

Definición

Devuelve datos del evento SpeakProgress.Returns data from the SpeakProgress event.

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 que está disponible en SpeakProgressEventArgs.The following example demonstrates the information that is available from SpeakProgressEventArgs. Tenga en cuenta cómo el StartParagraph, EndParagraph, StartSentence, y EndSentence métodos afectan a la CharacterCount mediante la adición de <p >, </p >, <s >, y </s > etiquetas para el SSML generado.Note how the StartParagraph, EndParagraph, StartSentence, and EndSentence methods affect the CharacterCount by their addition of <p>, </p>, <s>, and </s> tags to the generated SSML. Además, hay dos entradas en la salida de "30%", uno para cada palabra hablar de esta cadena numérica (treinta por ciento).Also, there are two entries in the output for "30%", one for each word to speak this number string (thirty percent). El CharacterCount y CharacterPosition son los mismos para cada entrada y representar los caracteres "30%.The CharacterCount and CharacterPosition are the same for each entry and represent the characters "30%. Sin embargo, el AudioPosition cambia para reflejar el habla de las palabras "treinta" y "porcentaje" por el SpeechSynthesizer.However, the AudioPosition changes to reflect the speaking of the words "thirty" and "percent" by the 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

Una instancia de SpeakProgressEventArgs se crea cuando el SpeechSynthesizer objeto genera el SpeakProgress eventos.An instance of SpeakProgressEventArgs is created when the SpeechSynthesizer object raises the SpeakProgress event. El SpeechSynthesizer genera este evento para cada palabra nueva que habla en un símbolo del sistema mediante cualquiera de los Speak, SpeakAsync, SpeakSsml, o SpeakSsmlAsync métodos.The SpeechSynthesizer raises this event for each new word that it speaks in a prompt using any of the Speak, SpeakAsync, SpeakSsml, or SpeakSsmlAsync methods.

Los datos devueltos se basan en el lenguaje de marcado de síntesis del voz (SSML) que genera el código.The returned data is based on the Speech Synthesis Markup Language (SSML) that the code generates. Los valores devueltos para CharacterCount incluir espacios y los caracteres y el contenido de las etiquetas SSML generadas por el código.The values returned for CharacterCount include spaces and the characters and contents of the SSML tags generated by the code.

Propiedades

AudioPosition AudioPosition AudioPosition AudioPosition

Obtiene la posición del sonido del evento.Gets the audio position of the event.

Cancelled Cancelled Cancelled Cancelled

Obtiene un valor que indica si se ha cancelado una operación asincrónica.Gets a value indicating whether an asynchronous operation has been canceled.

(Inherited from AsyncCompletedEventArgs)
CharacterCount CharacterCount CharacterCount CharacterCount

Obtiene el número de caracteres de la palabra que se acaba de pronunciar justo antes de que el evento se haya generado.Gets the number of characters in the word that was spoken just before the event was raised.

CharacterPosition CharacterPosition CharacterPosition 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.Gets the number of characters and spaces from the beginning of the prompt to the position before the first letter of the word that was just spoken.

Error Error Error Error

Obtiene un valor que indica el error que se produjo durante una operación asincrónica.Gets a value indicating which error occurred during an asynchronous operation.

(Inherited from AsyncCompletedEventArgs)
Prompt Prompt Prompt Prompt

Obtiene la petición asociada al evento.Gets the prompt associated with the event.

(Inherited from PromptEventArgs)
Text Text Text Text

El texto que acaba de pronunciarse cuando se generó el evento.The text that was just spoken when the event was raised.

UserState UserState UserState UserState

Obtiene el identificador único de la tarea asincrónica.Gets the unique identifier for the asynchronous task.

(Inherited from AsyncCompletedEventArgs)

Métodos

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina si el objeto especificado es igual al objeto actual.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Sirve como la función hash predeterminada.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficial del objeto Object actual.Creates a shallow copy of the current Object.

(Inherited from Object)
RaiseExceptionIfNecessary() RaiseExceptionIfNecessary() RaiseExceptionIfNecessary() RaiseExceptionIfNecessary()

Genera una excepción proporcionada por el usuario si se ha producido un error en una operación asincrónica.Raises a user-supplied exception if an asynchronous operation failed.

(Inherited from AsyncCompletedEventArgs)
ToString() ToString() ToString() ToString()

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

(Inherited from Object)

Se aplica a