PromptBuilder.AppendBookmark(String) PromptBuilder.AppendBookmark(String) PromptBuilder.AppendBookmark(String) PromptBuilder.AppendBookmark(String) Method

Definición

Anexa un marcador al objeto PromptBuilder.Appends a bookmark to the PromptBuilder object.

public:
 void AppendBookmark(System::String ^ bookmarkName);
public void AppendBookmark (string bookmarkName);
member this.AppendBookmark : string -> unit
Public Sub AppendBookmark (bookmarkName As String)

Parámetros

bookmarkName
String String String String

Cadena que contiene el nombre del marcador anexado.A string containing the name of the appended bookmark.

Ejemplos

En el ejemplo siguiente se crea un mensaje que incluye dos marcadores y envía la salida a un archivo WAV para su reproducción.The following example creates a prompt that includes two bookmarks and sends the output to a WAV file for playback. El controlador BookmarkReached del evento escribe el nombre del marcador y su posición en la secuencia de audio cuando el evento se generó en la consola.The handler for the BookmarkReached event writes the name of the bookmark and its position in the audio stream when the event was raised to the console.

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 and append bookmarks.  
        PromptBuilder builder = new PromptBuilder(  
          new System.Globalization.CultureInfo("en-US"));  
        builder.AppendText(  
          "The weather forecast for today is partly cloudy with some sun breaks.");  
        builder.AppendBookmark("Daytime forecast");  
        builder.AppendText(  
          "Tonight's weather will be cloudy with a 30% chance of showers.");  
        builder.AppendBookmark("Nighttime forecast");  

        // Add a handler for the BookmarkReached event.  
        synth.BookmarkReached +=  
          new EventHandler<BookmarkReachedEventArgs>(synth_BookmarkReached);  

        // 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 the name and position of the bookmark to the console.  
    static void synth_BookmarkReached(object sender, BookmarkReachedEventArgs e)  
    {  
      Console.WriteLine("Bookmark ({0}) reached at: {1} ",  
        e.Bookmark, e.AudioPosition);  
    }  
  }  
}  

Comentarios

Un motor de síntesis BookmarkReached de voz generará un evento si encuentra un marcador mientras habla un símbolo del sistema con cualquiera de los SpeakAsync Speakmétodos SpeakSsml,, SpeakSsmlAsync o.A speech synthesis engine will generate a BookmarkReached event if it encounters a bookmark while speaking a prompt using any of the Speak, SpeakAsync, SpeakSsml, or SpeakSsmlAsync methods.

Se aplica a