PromptBuilder.AppendBookmark(String) 메서드

정의

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)

매개 변수

bookmarkName
String

추가된 책갈피의 이름을 포함하는 문자열입니다.A string containing the name of the appended bookmark.

예제

다음 예제에서는 두 개의 책갈피를 포함 하 고 WAV 파일 재생에 출력을 전송 하는 프롬프트를 만듭니다.The following example creates a prompt that includes two bookmarks and sends the output to a WAV file for playback. 에 대 한 처리기를 BookmarkReached 콘솔로 이벤트가 발생 하는 경우 이벤트에 책갈피 및 오디오 스트림에서 위치 이름을 씁니다.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);  
    }  
  }  
}  
  

설명

음성 합성 엔진이 생성을 BookmarkReached 중 하나를 사용 하 여 프롬프트를 말하기 하는 동안 책갈피를 발견할 경우 이벤트를 Speak, SpeakAsync, SpeakSsml, 또는 SpeakSsmlAsync 메서드.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.

적용 대상