语言

PromptBuilder.AppendBreak 方法

定义

在对象的内容中插入一个 PromptBuilder 中断(暂停)。

重载

名称 说明
AppendBreak()

向对象追加一个中断 PromptBuilder 。

AppendBreak(PromptBreak)

向对象追加一个分隔符 PromptBuilder 并指定其强度(持续时间)。

AppendBreak(TimeSpan)

将指定持续时间的中断追加到 PromptBuilder 对象。

AppendBreak()

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
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)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
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)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
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 个时钟周期(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();
    }
  }
}

注解

断点可用于控制单词之间的暂停或其他职业边界。 中断是可选的。 如果中断不存在,合成器将根据语言上下文确定单词之间的断点。

适用于