みかづきの色々

デバイス(スマホからキャンプ用品まで)とかプログラミングとか中心のいろいろ試験的なブログ。

感動したので書いてみた。

Windowsで喋らせるのって大変ってイメージがあるんだけど、Windows8以上なら簡単だよと聞いて試してみる事にした。


  • VS Express 2013 for Desktopをゲット。
  • デスクトップアプリのプロジェクトを新規で開く。
  • 参照を追加。

f:id:mikaduki99:20150305011117p:plain

  • んで、以下のように書く。
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で喋らせる方法も調べてみよう。