こちらの「文字音声変換API "TEXT2VOICE」をFlashから使ってみた。
文字列をgetで送信すると、それを読み上げたMP3のURLが返ってくるので、それを読み込んで再生してるだけ。
ActionScript3.0 Text2Speech
http://labs.un-q.net/as3/sound/text2speech/01/
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.media.Sound;
import flash.media.SoundChannel;
public class Text2speech01 extends Sprite {
private const API_URL:String = "http://api.satoru.net/text2voice/";
function Text2speech01() {
init();
}
private function init():void {
var urlReq:URLRequest = new URLRequest(API_URL);
var urll:URLLoader = new URLLoader();
var v:URLVariables = new URLVariables();
v.text = "休み明けで仕事する気になりません。今日も名古屋は暑い。";
urlReq.method = URLRequestMethod.GET;
urlReq.data = v;
urll.load(urlReq);
urll.addEventListener(Event.COMPLETE, function(e:Event):void {
trace("API COMPLETE : " + urll.data);
var sreq:URLRequest = new URLRequest(urll.data);
var sf:Sound = new Sound();
sf.addEventListener(Event.COMPLETE, function(e:Event):void {
trace("Sound load COMPLETE");
});
sf.load(sreq);
var sc:SoundChannel = sf.play();
sc.addEventListener(Event.SOUND_COMPLETE, function(e:Event):void {
trace("Sound play COMPLETE");
});
});
}
}
}



