語言

PromptBuilder.AppendBreak 方法

定義

在物件內容 PromptBuilder 中插入一個中斷(暫停)。

多載

名稱 Description
AppendBreak()

在物件上附加一個斷裂 PromptBuilder 點。

AppendBreak(PromptBreak)

在物件上附加一個斷裂 PromptBuilder 點,並指定其強度(持續時間)。

AppendBreak(TimeSpan)

附加指定時長的中斷點給 PromptBuilder 物件。

AppendBreak()

來源:
PromptBuilder.cs
來源:
PromptBuilder.cs
來源:
PromptBuilder.cs
來源:
PromptBuilder.cs

在物件上附加一個斷裂 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.cs
來源:
PromptBuilder.cs
來源:
PromptBuilder.cs
來源:
PromptBuilder.cs

在物件上附加一個斷裂 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.cs
來源:
PromptBuilder.cs
來源:
PromptBuilder.cs
來源:
PromptBuilder.cs

附加指定時長的中斷點給 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奈秒。

範例

以下範例建立一個包含兩句句子、間隔為 15,000,000 tick(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();
    }
  }
}

備註

斷開可以用來控制單字之間的停頓或其他韻律上的界線。 休息是可選的。 若不存在中斷,合成器會根據語言語境決定詞間的中斷。

適用於