语言

SpeechAudioFormatInfo 构造函数

定义

初始化 SpeechAudioFormatInfo 类的新实例。

重载

名称 说明
SpeechAudioFormatInfo(Int32, AudioBitsPerSample, AudioChannel)

初始化类的新实例 SpeechAudioFormatInfo ,并指定每秒样本、每个样本的位数和通道数。

SpeechAudioFormatInfo(EncodingFormat, Int32, Int32, Int32, Int32, Int32, Byte[])

初始化类的新实例 SpeechAudioFormatInfo ,并指定编码格式、每秒样本样本数、通道数、每秒平均字节数、块对齐值以及包含格式特定数据的数组。

SpeechAudioFormatInfo(Int32, AudioBitsPerSample, AudioChannel)

Source:
SpeechAudioFormatInfo.cs
Source:
SpeechAudioFormatInfo.cs
Source:
SpeechAudioFormatInfo.cs
Source:
SpeechAudioFormatInfo.cs

初始化类的新实例 SpeechAudioFormatInfo ,并指定每秒样本、每个样本的位数和通道数。

public:
 SpeechAudioFormatInfo(int samplesPerSecond, System::Speech::AudioFormat::AudioBitsPerSample bitsPerSample, System::Speech::AudioFormat::AudioChannel channel);
public SpeechAudioFormatInfo(int samplesPerSecond, System.Speech.AudioFormat.AudioBitsPerSample bitsPerSample, System.Speech.AudioFormat.AudioChannel channel);
new System.Speech.AudioFormat.SpeechAudioFormatInfo : int * System.Speech.AudioFormat.AudioBitsPerSample * System.Speech.AudioFormat.AudioChannel -> System.Speech.AudioFormat.SpeechAudioFormatInfo
Public Sub New (samplesPerSecond As Integer, bitsPerSample As AudioBitsPerSample, channel As AudioChannel)

参数

samplesPerSecond
Int32

每秒样本的值。

bitsPerSample
AudioBitsPerSample

每个样本的位的值。

channel
AudioChannel

枚举的成员 AudioChannel (指示 Mono 或 Stereo)。

示例

下面的示例演示如何指定要输出到 WAV 文件的音频格式的典型用法 SpeechAudioFormatInfo 。 实例 SpeechAudioFormatInfo 是方法的参数 SetOutputToWaveFile 。

using System;
using System.IO;
using System.Speech.Synthesis;
using System.Speech.AudioFormat;

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:\temp\test.wav",
          new SpeechAudioFormatInfo(32000, AudioBitsPerSample.Sixteen, AudioChannel.Mono));

        // Create a SoundPlayer instance to play output audio file.
        System.Media.SoundPlayer m_SoundPlayer =
          new System.Media.SoundPlayer(@"C:\temp\test.wav");

        // Build a prompt.
        PromptBuilder builder = new PromptBuilder();
        builder.AppendText("This is sample output to a WAVE file.");

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

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

适用于

SpeechAudioFormatInfo(EncodingFormat, Int32, Int32, Int32, Int32, Int32, Byte[])

Source:
SpeechAudioFormatInfo.cs
Source:
SpeechAudioFormatInfo.cs
Source:
SpeechAudioFormatInfo.cs
Source:
SpeechAudioFormatInfo.cs

初始化类的新实例 SpeechAudioFormatInfo ,并指定编码格式、每秒样本样本数、通道数、每秒平均字节数、块对齐值以及包含格式特定数据的数组。

public:
 SpeechAudioFormatInfo(System::Speech::AudioFormat::EncodingFormat encodingFormat, int samplesPerSecond, int bitsPerSample, int channelCount, int averageBytesPerSecond, int blockAlign, cli::array <System::Byte> ^ formatSpecificData);
public SpeechAudioFormatInfo(System.Speech.AudioFormat.EncodingFormat encodingFormat, int samplesPerSecond, int bitsPerSample, int channelCount, int averageBytesPerSecond, int blockAlign, byte[]? formatSpecificData);
public SpeechAudioFormatInfo(System.Speech.AudioFormat.EncodingFormat encodingFormat, int samplesPerSecond, int bitsPerSample, int channelCount, int averageBytesPerSecond, int blockAlign, byte[] formatSpecificData);
new System.Speech.AudioFormat.SpeechAudioFormatInfo : System.Speech.AudioFormat.EncodingFormat * int * int * int * int * int * byte[] -> System.Speech.AudioFormat.SpeechAudioFormatInfo
Public Sub New (encodingFormat As EncodingFormat, samplesPerSecond As Integer, bitsPerSample As Integer, channelCount As Integer, averageBytesPerSecond As Integer, blockAlign As Integer, formatSpecificData As Byte())

参数

encodingFormat
EncodingFormat

编码格式。

samplesPerSecond
Int32

每秒样本的值。

bitsPerSample
Int32

每个样本的位的值。

channelCount
Int32

通道计数的值。

averageBytesPerSecond
Int32

每秒平均字节数的值。

blockAlign
Int32

BlockAlign 的值。

formatSpecificData
Byte[]

包含格式特定数据的字节数组。

适用于