Permalink
Browse files

google.translate: adding translate-tts.

  • Loading branch information...
mrjbq7 committed Apr 26, 2013
1 parent 843d74d commit 065338aee35de3ce261c344bc3050c897874f012
Showing with 8 additions and 1 deletion.
  1. +8 −1 extra/google/translate/translate.factor
@@ -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"

0 comments on commit 065338a

Please sign in to comment.