PromptBuilder.AppendBreak 方法

定義

PromptBuilder 物件的內容中插入中斷 (暫停)。

多載

AppendBreak()

將中斷附加至 PromptBuilder 物件。

AppendBreak(PromptBreak)

將中斷附加至 PromptBuilder 物件,並指定其強度 (持續時間)。

AppendBreak(TimeSpan)

將指定持續時間的中斷附加至 PromptBuilder 物件。

AppendBreak()

將中斷附加至 PromptBuilder 物件。

public:
 void AppendBreak();
public void AppendBreak ();
member this.AppendBreak : unit -> unit
Public Sub AppendBreak ()

範例

下列範例會建立一個提示,其中包含兩個以斷路分隔的句子,並將提示輸入電腦上的預設音訊裝置。

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.SetOutputToDefaultAudioDevice();  

        // Build a prompt with two sentences separated by a break.  
        PromptBuilder builder = new PromptBuilder(  
          new System.Globalization.CultureInfo("en-US"));  
        builder.AppendText(  
          "Tonight's movie showings in theater A are at 5:45, 7:15, and 8:45.");  
        builder.AppendBreak();  
        builder.AppendText(  
          "Tonight's movie showings in theater B are at 5:15, 7:30, and 9:15.");  

        // Speak the prompt.  
        synth.Speak(builder);  
      }  

      Console.WriteLine();  
      Console.WriteLine("Press any key to exit...");  
      Console.ReadKey();  
    }  
  }  
}  

備註

這個方法不會指定中斷的持續時間。 SpeechSynthesizer會根據語言內容來決定持續時間值。

適用於

AppendBreak(PromptBreak)

將中斷附加至 PromptBuilder 物件,並指定其強度 (持續時間)。

public:
 void AppendBreak(System::Speech::Synthesis::PromptBreak strength);
public void AppendBreak (System.Speech.Synthesis.PromptBreak strength);
member this.AppendBreak : System.Speech.Synthesis.PromptBreak -> unit
Public Sub AppendBreak (strength As PromptBreak)

參數

strength
PromptBreak

指出中斷的持續時間。

範例

下列範例會建立包含兩個句子的提示,並以中斷區隔,並將輸出傳送至 WAV 檔案進行播放。

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 with two sentences separated by a break.  
        PromptBuilder builder = new PromptBuilder(  
          new System.Globalization.CultureInfo("en-US"));  
        builder.AppendText(  
          "Tonight's movie showings in theater A are at 5:45, 7:15, and 8:45");  
        builder.AppendBreak(PromptBreak.Medium);  
        builder.AppendText(  
          "Tonight's movie showings in theater B are at 5:15, 7:15, and 9:15");  

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

備註

列舉中的值 PromptBreak 代表分隔間隔範圍 (在單字界限之間暫停) 。 語音合成引擎會決定間隔的確切持續時間。 要求中斷時,會將下列其中一個值傳遞至文字轉換語音 (TTS) 引擎,其中包含這些值與對應之毫秒中斷值之間的對應。

適用於

AppendBreak(TimeSpan)

將指定持續時間的中斷附加至 PromptBuilder 物件。

public:
 void AppendBreak(TimeSpan duration);
public void AppendBreak (TimeSpan duration);
member this.AppendBreak : TimeSpan -> unit
Public Sub AppendBreak (duration As TimeSpan)

參數

duration
TimeSpan

以刻度為單位的時間,一個刻度等於 100 奈秒。

範例

下列範例會建立包含兩個句子的提示,並以15000000刻度的分隔分隔 (1.5 秒) ,並在電腦上將提示輸入至預設音訊裝置。

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.SetOutputToDefaultAudioDevice();  

        // Build a prompt with two sentences separated by a break.  
        PromptBuilder builder = new PromptBuilder(  
          new System.Globalization.CultureInfo("en-US"));  
        builder.AppendText(  
          "Tonight's movie showings in theater A are at 5:45, 7:15, and 8:45");  
        builder.AppendBreak(new TimeSpan(15000000));  
        builder.AppendText(  
          "Tonight's movie showings in theater B are at 5:15, 7:15, and 9:15");  

        // Speak the prompt.  
        synth.Speak(builder);  
      }  

      Console.WriteLine();  
      Console.WriteLine("Press any key to exit...");  
      Console.ReadKey();  
    }  
  }  
}  

備註

Break 可以用來控制單字之間的暫停或其他韻律界限。 Break 是選擇性的。 如果不存在中斷,合成器會根據語言內容來決定單字之間的分隔。

適用於