Created
August 10, 2011 18:06
-
-
Save gre/1137659 to your computer and use it in GitHub Desktop.
Play framework + Scala : a text to speech in 2 line of code using google translate - this is an action, put it in any controller ;)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def speech(text:String) = { | |
val audio = WS.url("http://translate.google.com/translate_tts?tl=en").setParameter("q", text).get() | |
response.contentType = audio.getContentType() | |
audio.getStream() | |
} | |
/* | |
This is a Play! framework controller's action. | |
Put it in any scala controller. | |
Don't forget to import play.libs.WS | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment