Google Text-to-speech from the comfort of your command line.
Wow very cool!
git clone https://github.com/BelkaDev/GoogleTts.git ~/Tts && cd ~/Tts
chmod +x *
copy both scripts to your $PATH directory
- Cli text to speech or textual translations
- Language selection and automatic detection
- Real-time translation and cross-language speech
- Patterns filtering
- Read current selection
Text-to-speech
-a, --auto
for auto-detection mode.
-a "こにちわ"
will read in Japanese-a "hola"
will read in Spanish
-t, --translate <lang>
to translate and read
-t "こにちわ"
will translate to preferred language and read.-t de "こにちわ"
will translate to German and read.
-l, --language <lang>
to change the language
-l es "hi"
reads input in Spanish voice
Notes
All options can be specified at runtime or set up
by default in the settings, accepted values are `true` , `false`
for boolean attributes, for language codes
use one of valid language tags supported by Google.
The complete list can be found here
Stack order follows this order: language>auto>translate
Meaning the highest will always neglect the others.
-l en -t こにちわ
will not perform translation.
If no text input is given, current selection (highlighted text),
is processed, this requires an X environement.
When run on terminal, double quotes must wrap the input.
Translation
the translation script can be used independently, but not the other way around
most broad syntax is as follows:
translate [from <source> to <target> <text>]
Each parameter can be ommited, in that case automatic values are considered.
examples:
translate to ko "hello"
: detects language and translates to Korean
translate from fr "bonjour"
: translates from French to preferred language
translate
: translate selection from detected language to preferred language
Output format contains synonyms and examples and is made easy to parse using pipes.
- parse translation:
| grep -w "translation" | cut -f2 -d ":"
- parse source language:
| grep -w "source_lang" | cut -f2 -d ":"
-
A set of patterns can be configured to ignore undesirable/irrelevant words or replace specific sequences. As all options it can be changed at the top of the file, it follows this structure
{ "sequence" ; "alternative", ...}
Setting up an empty string will ignore the corresponding sequence. (option is disabled by default.) -
Audio files can be stored in the directory of your choice.
Todo: feed files or web urls to the script
All parameters should be interchangeable, but this can lead to unexpected results if they get mixed up.
Encoding erros: some characters may cause the script to fail.