Skip to content

Instantly share code, notes, and snippets.

@alivesay
Created July 8, 2013 20:33
Show Gist options
  • Save alivesay/5952244 to your computer and use it in GitHub Desktop.
Save alivesay/5952244 to your computer and use it in GitHub Desktop.
#!/bin/bash
GOOGLE_SL="ru"
GOOGLE_TL="en"
GOOGLE_TRANSLATE_URL="http://translate.google.com/translate_a/t?client=t&hl=en&sl=$GOOGLE_SL&tl=$GOOGLE_TL&ie=UTF-8&oe=UTF-8&multires=1&prev=btn&ssel=0&tsel=0&sc=1"
TESSERACT_LANG="rus"
TEMPFILE=$(mktemp)
tesseract $1 $TEMPFILE -l $TESSERACT_LANG > /dev/null 2>&1
TEXT_IN=$(tr '\n.' ' ' < ${TEMPFILE}.txt)
TEXT_OUT=$(curl -s -A "Mozilla/5.0" -G --data-urlencode "text=$TEXT_IN" $GOOGLE_TRANSLATE_URL | sed 's/\[\[\["\([^"]*\).*/\1/')
echo "$TEXT_OUT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment