In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

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

forked from: 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)
日本語の読み上げもできるか試してみた。
/**
 * Copyright ffffine ( http://wonderfl.net/user/ffffine )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/fos0
 */

// forked from clockmaker's 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)
 * 日本語の読み上げもできるか試してみた。
 */
package {
    import com.bit101.components.*;
    import flash.display.*;
    import flash.events.*;
    import flash.media.*;
    import flash.net.*;
    import flash.text.*;    

    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, "ダンカン、この野郎!", null);
            _input.textField.embedFonts = false;
            _input.textField.defaultTextFormat = new TextFormat("_ゴシック", 9, 0xff0000);
            _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=ja"
                + "&q=" + encodeURI(_input.text)
            );
            
            var snd:Sound = new Sound(req);
            snd.play();
        }
    }
}