-
-
Save imambungo/6a750f89a73e2afc47a6edcc18dd7661 to your computer and use it in GitHub Desktop.
Use Google Translate's Text to Speech without leaving the terminal.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Sample usage : tts "your text here" | |
# or : tts your text here (if there are no symbol) | |
tts() { | |
input="$@" | |
# https://stackoverflow.com/a/56321886/9157799 | |
query=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$input'))") | |
# https://stackoverflow.com/a/10054006/9157799 | |
curl -sH 'Referer: http://translate.google.com/' -H 'User-Agent: stagefright/1.2 (Linux;Android 5.0)' "https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q=$query" > ~/.tts.mp3 | |
# https://askubuntu.com/a/316048/356625 | |
ffplay -nodisp -autoexit ~/.tts.mp3 2> /dev/null | |
rm ~/.tts.mp3 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment