google.translate: adding translate-tts.

db4
John Benediktsson 2013-04-26 10:42:50 -07:00
parent 8d209ace8a
commit bb9abd6926
1 changed files with 8 additions and 1 deletions

View File

@ -1,7 +1,8 @@
! Copyright (C) 2010 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: assocs combinators fry grouping http.client io
json.reader kernel locals make namespaces sequences ;
io.encodings.binary io.files io.files.unique json.reader kernel
locals make namespaces sequences urls ;
IN: google.translate
CONSTANT: google-translate-url "http://ajax.googleapis.com/ajax/services/language/translate"
@ -50,6 +51,12 @@ ERROR: response-error response error ;
swap dupd = not
] loop drop ;
: translate-tts ( text -- file )
"http://translate.google.com/translate_tts?tl=en" >url
swap "q" set-query-param http-get nip
temporary-file ".mp3" append
[ binary set-file-contents ] keep ;
! Example:
! "dog" "en" "de" translate .
! "Hund"