Advertisement
voyeg3r

eng2audio

Nov 24th, 2013
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.08 KB | None | 0 0
  1. eng2audio () {
  2. # see this: https://gist.github.com/michalfapso/3110049/raw
  3. # http://michalfapso.blogspot.com.br/2012/01/using-google-text-to-speech.html
  4. # http://mostovenko.blogspot.com.br/2012/04/voicing-messages-in-python-or-fun-with.html
  5. # versão no snipt: https://snipt.net/voyeg3r/
  6.  
  7. # how truncate string  --> echo ${var:start:end}
  8. # removendo o último caractere de uma variável   ${var:0:-1}
  9. #   vou precisar truncar a string::::: echo "Sua string contém "${#var}" caracteres"
  10. if   ping -q -c2 www.google.com >/dev/null ; then
  11.         FILENAME="${@:?Usage: $0 give me some words to speech}"
  12.         FILENAME=`awk '{print tolower($0)}' <<< "$FILENAME"`
  13.         url="http://translate.google.com/translate_tts?ie=UTF-8&tl=en&q="
  14.         wget -q -U Mozilla -O "${FILENAME// /_}.mp3" "${url}${FILENAME// /+}+' '"
  15.         [ -f "${FILENAME// /_}.mp3" -a ! -s "${FILENAME// /_}.mp3" ] && { rm -f "${FILENAME// /_}.mp3" ; echo 'error!'; }
  16.         command -v mpg321 > /dev/null && mpg321 -q "${FILENAME// /_}.mp3"
  17.         echo "[sound:${FILENAME// /_}.mp3]" | xclip -selection c
  18. fi
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement