Bagikan melalui


BookmarkReachedEventArgs Kelas

Definisi

Mengembalikan data dari BookmarkReached peristiwa.

public ref class BookmarkReachedEventArgs : System::Speech::Synthesis::PromptEventArgs
public class BookmarkReachedEventArgs : System.Speech.Synthesis.PromptEventArgs
type BookmarkReachedEventArgs = class
    inherit PromptEventArgs
Public Class BookmarkReachedEventArgs
Inherits PromptEventArgs
Warisan

Contoh

Contoh berikut membuat perintah yang menyertakan dua marka buku dan mengirim output ke file WAV untuk diputar. Handler untuk BookmarkReached peristiwa menulis nama bookmark dan posisinya di aliran audio saat peristiwa dinaikkan ke konsol.

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);  
    }  
  }  
}  

Keterangan

Instans BookmarkReachedEventArgs dibuat saat SpeechSynthesizer objek menaikkan BookmarkReached peristiwa. meningkatkan peristiwa ketika menemukan bookmark saat memproses salah Speaksatu metode , , SpeakAsyncSpeakSsml, atau SpeakSsmlAsync .BookmarkReachedSpeechSynthesizer Untuk mendapatkan nama dan lokasi marka buku yang memicu peristiwa, akses Bookmark dan AudioPosition properti di handler untuk peristiwa tersebut.

Properti

AudioPosition

Mendapatkan offset waktu di mana marka buku tercapai.

Bookmark

Mendapatkan nama bookmark yang tercapai.

Cancelled

Mendapatkan nilai yang menunjukkan apakah operasi asinkron telah dibatalkan.

(Diperoleh dari AsyncCompletedEventArgs)
Error

Mendapatkan nilai yang menunjukkan kesalahan mana yang terjadi selama operasi asinkron.

(Diperoleh dari AsyncCompletedEventArgs)
Prompt

Mendapatkan perintah yang terkait dengan peristiwa.

(Diperoleh dari PromptEventArgs)
UserState

Mendapatkan pengidentifikasi unik untuk tugas asinkron.

(Diperoleh dari AsyncCompletedEventArgs)

Metode

Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetType()

Mendapatkan instans Type saat ini.

(Diperoleh dari Object)
MemberwiseClone()

Membuat salinan dangkal dari yang saat ini Object.

(Diperoleh dari Object)
RaiseExceptionIfNecessary()

Meningkatkan pengecualian yang disediakan pengguna jika operasi asinkron gagal.

(Diperoleh dari AsyncCompletedEventArgs)
ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Berlaku untuk

Lihat juga