Windowsで喋らせるのって大変ってイメージがあるんだけど、Windows8以上なら簡単だよと聞いて試してみる事にした。
- VS Express 2013 for Desktopをゲット。
- デスクトップアプリのプロジェクトを新規で開く。
- 参照を追加。
- んで、以下のように書く。
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using SpeechLib; namespace WindowsFormsApplication1 { public partial class Form1 : Form { SpVoice h = new SpVoice(); public Form1() { InitializeComponent(); } private void b1click(object sender, EventArgs e) { string dx = textBox1.Text; if (dx != "") { h.Speak(dx); } } } }
なんだこれ、めちゃめちゃ簡単じゃないか! XD
すばらしい。作業PCもWindows8.1にすっかな?
ああでも、これCOMだ。Windows縛りになっちゃうのか……。
ちゃんと.NETなAPIで喋らせる方法も調べてみよう。