日本語環境で流暢に英語を喋る

SpeechSynthesizerクラスで「Thank you for the mail.」を喋らせてみると、 片言の発音になってしまいます。 「Thank you for the mail.」

MainPage.xaml

<MediaElement x:Name="Media"/>
<Button Content="Speech!" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="Button_Click"/>

MainPage.xaml.cs

private async void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
    SpeechSynthesisStream stream;
    using (var ss = new SpeechSynthesizer())
    {
        stream = await ss.SynthesizeTextToStreamAsync("Thank you for the mail.");
    }
    Media.SetSource(stream, stream.ContentType);
    Media.Play();
}

話し手を英語にすると良いみたいですが、日本語Windows10にはデフォルトでインストールされていない模様。

foreach (var voice in SpeechSynthesizer.AllVoices)
{
    Debug.WriteLine($"{voice.Description},{voice.Gender},{voice.Language}");
}
Microsoft Ayumi Mobile - Japanese (Japan),Female,ja-JP
Microsoft Haruka Mobile - Japanese (Japan),Female,ja-JP
Microsoft Ichiro Mobile - Japanese (Japan),Male,ja-JP

ココに追加方法が書いてありました。

stackoverflow.com

すべての設定 > 時刻と言語 にある、地域と言語 を選んだ画面で、English(United States)を追加します。

f:id:matsujirushix:20170210235822p:plain

f:id:matsujirushix:20170210235848p:plain

さらに、オプションで言語パックと音声認識をダウンロードします。

f:id:matsujirushix:20170210235953p:plain

f:id:matsujirushix:20170211000001p:plain

すると、英語の話し手が追加されます。

Microsoft Ayumi Mobile - Japanese (Japan)
Microsoft Haruka Mobile - Japanese (Japan)
Microsoft Ichiro Mobile - Japanese (Japan)
Microsoft David Mobile - English (United States)
Microsoft Zira Mobile - English (United States)
Microsoft Mark Mobile - English (United States)

コードに、話し手の指定を追記します。

SpeechSynthesisStream stream;
using (var ss = new SpeechSynthesizer())
{
    ss.Voice = (SpeechSynthesizer.AllVoices.First(x => x.Gender == VoiceGender.Female && x.Language == "en-US"));
    stream = await ss.SynthesizeTextToStreamAsync("Thank you for the mail.");
}
Media.SetSource(stream, stream.ContentType);
Media.Play();

「Thank you for the mail.」

コード

github.com

環境