SpeechSynthesizer.State プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
SpeechSynthesizer オブジェクトの現在の読み上げ状態を取得します。
public:
property System::Speech::Synthesis::SynthesizerState State { System::Speech::Synthesis::SynthesizerState get(); };
public System.Speech.Synthesis.SynthesizerState State { get; }
member this.State : System.Speech.Synthesis.SynthesizerState
Public ReadOnly Property State As SynthesizerState
プロパティ値
SpeechSynthesizer オブジェクトの現在の読み上げ状態を返します。
例
次の例は、プロンプトを読み上げる前、実行中、および読み上げ後の SpeechSynthesizer の状態を示しています。
using System;
using System.Threading;
using System.Speech.Synthesis;
namespace SampleSynthesis
{
class Program
{
static void Main(string[] args)
{
// Initialize a new instance of the SpeechSynthesizer.
SpeechSynthesizer synth = new SpeechSynthesizer() ;
// Configure the audio output.
synth.SetOutputToDefaultAudioDevice();
// Subscribe to the SpeakProgress event.
synth.SpeakProgress += new EventHandler<SpeakProgressEventArgs>(synth_SpeakProgress);
// Write the state of the SpeechSynthesizer to the console.
Console.WriteLine("Current Synthesizer state: " + synth.State + "\n");
// Speak a string asynchronously.
synth.SpeakAsync("What is your favorite color?");
// Write the state of the SpeechSynthesizer to the console while it is speaking.
Thread.Sleep(1000);
Console.WriteLine("\n - Current Synthesizer state: " + synth.State + " - \n");
// Write the state of the SpeechSynthesizer to the console after it is done speaking.
Thread.Sleep(2000);
Console.WriteLine("\nCurrent Synthesizer state: " + synth.State);
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
static void synth_SpeakProgress(object sender, SpeakProgressEventArgs e)
{
Console.WriteLine(e.Text);
}
}
}
注釈
変更後のSpeechSynthesizerの新しい状態を取得するには、StateChangedEventArgs クラスの State プロパティを使用します。