PromptBuilder.AppendBookmark(String) メソッド

定義

PromptBuilder オブジェクトにブックマークを追加します。

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

パラメーター

bookmarkName
String

追加されるブックマークの名前を含む文字列。

次の例では、2 つのブックマークを含むプロンプトを作成し、出力を WAV ファイルに送信して再生します。 イベントのハンドラーは、 BookmarkReached ブックマークの名前と、イベントが発生したときのオーディオ ストリーム内の位置をコンソールに書き込みます。

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

注釈

、または のいずれかのメソッドをBookmarkReached使用してプロンプトを読み上げるときにブックマークが見つかった場合、音声合成エンジンはイベントをSpeakSsmlSpeakSpeakAsync生成します。SpeakSsmlAsync

適用対象