Dead Code Preservation :: Archived AS3 works from wonderfl.net

Text speech by Google API

Text speech by Google API
* Google API を使った音声合成
* @author Yasu
* @see http://log.xingxx.com/2010/05/actionscript-30-6.html (KeadeAS)
Get Adobe Flash player
by clockmaker 23 May 2010
  • Related works: 2
  • Talk

    clockmaker at 23 May 2010 22:24
    FirefoxやIEだと問題ないのですが、SafariとChromeだとIO_ERRORが 発生して音声を読み込むことができません。Google側でリファラとかで判別しているのかも。 ※ヘッダーをカスタマイズするライブラリ使えばもしかしたら解決できるかも。 http://clockmaker.jp/blog/2009/12/as3-httpclientlib/
    makc3d at 24 May 2010 01:51
    still do not understand why it didnt work for me http://wonderfl.net/c/ba1I
    makc3d at 25 May 2010 03:49
    wait a minute, it still does not work :( Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error. at Main/onClick()
    Xeonix at 05 Jun 2010 19:12
    Wonderful class mate.

    Tags

    Embed
/**
 * Copyright clockmaker ( http://wonderfl.net/user/clockmaker )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/rgyc
 */

/**
 * Text speech by Google API
 * Google API を使った音声合成
 * @author Yasu
 * @see http://log.xingxx.com/2010/05/actionscript-30-6.html (KeadeAS)
 */
package {
    import com.bit101.components.*;
    import flash.display.*;
    import flash.events.*;
    import flash.media.*;
    import flash.net.*;

    public class Main extends Sprite {
        private var _input:InputText;

        public function Main() {
            // Title
            var label:Label = new Label(this, 50, 180, "Speech by Google API");
            label.scaleX = label.scaleY = 2;
            
            // Text Input
            _input = new InputText(this, 50, 232, "It's a wonderful world.", null);
            _input.width = 200;
            _input.maxChars = 90;
            
            // Button
            new PushButton(this, 270, 230, "Speech!", onClick);
        }

        private function onClick(e:Event):void {
            
            var req:URLRequest = new URLRequest(
                "http://translate.google.com/translate_tts"
                + "?tl=en"
                + "&q=" + encodeURI(_input.text)
            );
            
            var snd:Sound = new Sound(req);
            snd.play();
        }
    }
}