SpeechSynthesizer.Voice プロパティ

定義

音声合成エンジン (音声) を取得または設定します。

public:
 property VoiceInformation ^ Voice { VoiceInformation ^ get(); void set(VoiceInformation ^ value); };
VoiceInformation Voice();

void Voice(VoiceInformation value);
public VoiceInformation Voice { get; set; }
var voiceInformation = speechSynthesizer.voice;
speechSynthesizer.voice = voiceInformation;
Public Property Voice As VoiceInformation

プロパティ値

音声合成エンジン (または音声)。 既定値は、現在のシステム音声です。

ここでは、見つかった最初の女性音声 (VoiceGender) または既定のシステム音声 (SpeechSynthesizer.DefaultVoice) を使用して、音声 (VoiceInformation.Gender) の性別を選択する方法を示します(女性音声が見つからない場合)。

using (SpeechSynthesizer synthesizer = new SpeechSynthesizer())
{
    VoiceInformation voiceInfo =
        (
            from voice in SpeechSynthesizer.AllVoices
            where voice.Gender == VoiceGender.Female
            select voice
        ).FirstOrDefault() ?? SpeechSynthesizer.DefaultVoice;

    synthesizer.Voice = voiceInfo;

    // Windows.Media.SpeechSynthesis.SpeechSynthesisStream
    stream = await synthesizer.SynthesizeTextToStreamAsync(text);
}

注釈

SpeechSynthesizer を使用して音声を生成するには、システムにインストールされている Microsoft 署名付き音声のみを使用できます。 各音声は、特定の国/地域で話されているように、1 つの言語で合成された音声を生成します。

既定では、新しい SpeechSynthesizer オブジェクトは現在のシステム音声を使用します ( DefaultVoice を呼び出して、既定の音声が何であるかを確認します)。

ユーザーのシステムにインストールされている他の音声合成 (テキスト読み上げ) 音声のいずれかを指定するには、Voice メソッドを使用します (システムにインストールされている 音声 を確認するには、 AllVoices を呼び出します)。

言語を指定しない場合は、[言語] コントロール パネルで選択した言語に最も近い音声が読み込まれます。

適用対象

こちらもご覧ください