diff --git a/extra/google/translate/translate.factor b/extra/google/translate/translate.factor index ed559d0c94..e515e749bd 100644 --- a/extra/google/translate/translate.factor +++ b/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"