System.Speech.Synthesis
思いつきでWinFXのSpeech系クラスを弄ってみました。まず、Speech SDK 5.1が必要なのでダウンロードしておきます。で、
using System; using System.Globalization; using System.Speech.Synthesis; static class Program { static void Main () { SpeechSynthesizer speak = new SpeechSynthesizer (); // 米国人女性 speak.SelectVoice (VoiceGender.Female); speak.SpeakText ("Hello"); // 米国人男性 speak.SelectVoice (VoiceGender.Male, VoiceAge.Adult); speak.SpeakText ("Hello"); } }
WinFXのライブラリは明示的に指定します。
$ csc /lib:"%windir%\Microsoft.NET\Windows\v6.0.5070" /r:System.Speech.dll speech.cs
英語の他に中国語も喋らすことが出来ましたが、ニーハオが文字化けするのでサンプルコードからは削除しました。あと、日本語は音声認識は出来るけど喋らすことは出来ないようです。(SAPI5だと)