SpeechAudioFormatInfo 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 SpeechAudioFormatInfo 類別的新執行個體。
多載
| 名稱 | Description |
|---|---|
| SpeechAudioFormatInfo(Int32, AudioBitsPerSample, AudioChannel) |
初始化該類別的新實例 SpeechAudioFormatInfo ,並指定每秒取樣點數、每個取樣點數及通道數。 |
| SpeechAudioFormatInfo(EncodingFormat, Int32, Int32, Int32, Int32, Int32, Byte[]) |
初始化類別的新實例 SpeechAudioFormatInfo ,並指定編碼格式、每秒取樣數、每個取樣位元數、通道數、平均位元組每秒、區塊對齊值,以及包含特定格式資料的陣列。 |
SpeechAudioFormatInfo(Int32, AudioBitsPerSample, AudioChannel)
初始化該類別的新實例 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)。
範例
以下範例展示了 的 SpeechAudioFormatInfo 典型用途,用以指定輸出為 WAV 檔案的音訊格式。 實 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[])
初始化類別的新實例 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[]
一個包含特定格式資料的位元組陣列。