日本語環境で流暢に英語を喋る
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
ココに追加方法が書いてありました。
すべての設定 > 時刻と言語 にある、地域と言語 を選んだ画面で、English(United States)を追加します。
さらに、オプションで言語パックと音声認識をダウンロードします。
すると、英語の話し手が追加されます。
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();
コード
環境
- Surface Pro 2
- Windows 10 1607(14393.693)
- Visual Studio 2015 Update 3