SpeechSynthesizer.Speak メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
文字列、Prompt オブジェクト、または PromptBuilder オブジェクトから同期で出力される音声を生成します。
オーバーロード
Speak(Prompt) |
非同期的に Prompt オブジェクトのコンテンツを指示します。 |
Speak(PromptBuilder) |
非同期的に PromptBuilder オブジェクトのコンテンツを指示します。 |
Speak(String) |
同期的に文字列のコンテンツを指示します。 |
注釈
メソッドは、 Speak 音声を同期的に生成します。 メソッドは、インスタンスの内容が完全に話されるまでは戻りません Speak 。 これは、音声を生成する最も簡単な方法です。 ただし、アプリケーションで読み上げ中にタスクを実行する必要がある場合は (テキストの強調表示、アニメーションの表示、コントロールの監視などのタスク)、メソッドまたはメソッドを使用して、 SpeakAsync SpeakSsmlAsync 音声を非同期に生成します。
このメソッドの呼び出し中に、は SpeechSynthesizer 次のイベントを発生させることができます。
StateChanged. シンセサイザーの読み上げの状態が変化したときに発生します。
SpeakStarted. シンセサイザーが音声の生成を開始するときに発生します。
PhonemeReached. シンセサイザーが1つの文字または文字の組み合わせに到達するたびに発生し、言語の音声を個別に発音します。
SpeakProgress. シンセサイザーが単語の読み上げを完了するたびに発生します。
VisemeReached. 音声の生成に使用される口の位置または顔の筋肉を変更する必要があるたびに発生します。
BookmarkReached. シンセサイザーがプロンプトでブックマークを検出したときに発生します。
VoiceChange. シンセサイザーの読み上げ音声が変化したときに発生します。
は、 SpeechSynthesizer SpeakCompleted メソッドの処理中にイベントを発生させません Speak 。
Speak(Prompt)
非同期的に Prompt オブジェクトのコンテンツを指示します。
public:
void Speak(System::Speech::Synthesis::Prompt ^ prompt);
public void Speak (System.Speech.Synthesis.Prompt prompt);
member this.Speak : System.Speech.Synthesis.Prompt -> unit
Public Sub Speak (prompt As Prompt)
パラメーター
- prompt
- Prompt
話すコンテンツ。
例
次の例では、 Prompt 文字列からオブジェクトを作成し、そのオブジェクトを引数としてメソッドに渡し Speak ます。
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();
// Create a prompt from a string.
Prompt color = new Prompt("What is your favorite color?");
// Speak the contents of the prompt synchronously.
synth.Speak(color);
}
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}
注釈
オブジェクトの内容を非同期に読み上げるには Prompt 、を使用し SpeakAsync ます。
適用対象
Speak(PromptBuilder)
非同期的に PromptBuilder オブジェクトのコンテンツを指示します。
public:
void Speak(System::Speech::Synthesis::PromptBuilder ^ promptBuilder);
public void Speak (System.Speech.Synthesis.PromptBuilder promptBuilder);
member this.Speak : System.Speech.Synthesis.PromptBuilder -> unit
Public Sub Speak (promptBuilder As PromptBuilder)
パラメーター
- promptBuilder
- PromptBuilder
話すコンテンツ。
例
次の例では、 PromptBuilder 文字列からオブジェクトを作成し、そのオブジェクトを引数としてメソッドに渡し Speak ます。
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();
// Create a PromptBuilder object and append a text string.
PromptBuilder song = new PromptBuilder();
song.AppendText("Say the name of the song you want to hear");
// Speak the contents of the prompt synchronously.
synth.Speak(song);
}
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}
注釈
オブジェクトの内容を非同期に読み上げるには PromptBuilder 、を使用し SpeakAsync ます。
適用対象
Speak(String)
同期的に文字列のコンテンツを指示します。
public:
void Speak(System::String ^ textToSpeak);
public void Speak (string textToSpeak);
member this.Speak : string -> unit
Public Sub Speak (textToSpeak As String)
パラメーター
- textToSpeak
- String
読み上げるテキスト。
例
次の例に示すように、 Speak メソッドは、音声出力を同期的に生成する最も簡単な方法を提供します。
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();
// Speak a string synchronously.
synth.Speak("What is your favorite color?");
}
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}
注釈
SSML マークアップを含む文字列を同期的に読み上げるには、メソッドを使用し SpeakSsml ます。 文字列の内容を非同期に読み上げるには、メソッドを使用し SpeakAsync ます。