summaryrefslogtreecommitdiffstats
path: root/util/bin
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2014-12-28 11:52:40 +0100
committermakefu <github@syntax-fehler.de>2014-12-28 11:52:40 +0100
commit07a727bfb2ebb3cb0cc23df26bfc04e2768619bb (patch)
treefcc8628693d5fb5eaec6d73dfab8e0b80dcef99b /util/bin
parentc5843f1e06753b49471a9ee2ff0d048032a43846 (diff)
parentc89cdaaf2162e12d3f6c277e65054dfb0a893872 (diff)
Merge branch 'master' of ssh://github.com/krebscode/painload
Diffstat (limited to 'util/bin')
-rwxr-xr-xutil/bin/text2speech.google22
-rwxr-xr-xutil/bin/translate.google24
2 files changed, 37 insertions, 9 deletions
diff --git a/util/bin/text2speech.google b/util/bin/text2speech.google
index 41b4c172..b732f363 100755
--- a/util/bin/text2speech.google
+++ b/util/bin/text2speech.google
@@ -1,10 +1,24 @@
#!/bin/sh
set -euf
-tl=${TL:="en"}
+TL=${TL:="en"}
-text=$*
+usage(){
+ echo 'TL= can specifiy which language to use, default is "en"'
+ echo 'Example: TL="de" ./text2speech.google "whats up?" | mpv -)'
+ exit 0
+}
-url="http://translate.google.com/translate_tts?ie=UTF-8&tl=$tl"
+text2speech(){
+ text=$*
+ url="http://translate.google.com/translate_tts?ie=UTF-8&tl=$TL"
+
+ curl -A "Mozilla/5.0" -Ss "$url" --data-urlencode "q=$text"
+}
+
+if [ $# -eq 0 ]; then
+ usage
+fi
+
+text2speech $*
-curl -A "Mozilla/5.0" -Ss "$url" --data-urlencode "q=$text"
diff --git a/util/bin/translate.google b/util/bin/translate.google
index 2418dc37..cb69064a 100755
--- a/util/bin/translate.google
+++ b/util/bin/translate.google
@@ -4,10 +4,24 @@ set -euf
sl=${SL:="auto"}
tl=${TL:="en"}
-text=$*
+usage(){
+ echo 'TL= targetlanguage, valid strings are in the style of "en", "pl" or "de". default "en"'
+ echo 'SL= sourcelanguage, same TL, default is auto'
+ echo 'Example: TL="de" ./translate.google whats up?'
-url="http://translate.google.com/translate_a/t?client=t&sl=$sl&tl=$tl"
+ exit 0
+}
-curl -A "Mozilla/5.0" -Ss "$url" --data-urlencode "text=$text" |
- sed 's/\[\[\[\"//' |
- cut -d \" -f 1
+translate(){
+ text=$*
+ url="http://translate.google.com/translate_a/t?client=t&sl=$sl&tl=$tl"
+ curl -A "Mozilla/5.0" -Ss "$url" --data-urlencode "text=$text" |
+ sed 's/\[\[\[\"//' |
+ cut -d \" -f 1
+}
+
+if [ $# -eq 0 ]; then
+ usage
+fi
+
+translate $*