SpeechSynthesizer.Volume 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定 SpeechSynthesizer 物件的輸出音量。
public:
property int Volume { int get(); void set(int value); };
public int Volume { get; set; }
member this.Volume : int with get, set
Public Property Volume As Integer
屬性值
傳回 SpeechSynthesizer 的音量,從 0 到 100。
範例
下列範例會設定 SpeechSynthesizer 合成語音和 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.SetOutputToDefaultAudioDevice();
// Set the volume of the SpeechSynthesizer's ouput.
synth.Volume = 60;
// Build a prompt containing recorded audio and synthesized speech.
PromptBuilder builder = new PromptBuilder(
new System.Globalization.CultureInfo("en-US"));
builder.AppendAudio("C:\\Test\\WelcomeToContosoRadio.wav");
builder.AppendText(
"The weather forecast for today is partly cloudy with some sun breaks.");
// Speak the prompt.
synth.Speak(builder);
}
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}