My wife has extreme dry eye condition, so she want to avoid looking at the screen as much as possible. She asked me for a solution for Text-to-Speech on linux desktop.
Basically her requirement is to press a key and read out what she selects. I check jovie, but that’s somehow discontinued and the only speech-dispatcher backend available on my distro is espeak, whose voice quality is poor comparing to any modern solution on the desktop.
So I decided to check if there’s any available solution on internet and see if there’s a solution that using Google translate’s TTS service.
So far I found a script from http://elinux.org/RPi_Text_to_Speech_(Speech_Synthesis)#Google_Text_to_Speech
Which I adjusted a little for my usecase:
#!/bin/bash TEXT=$(xsel) say() { local IFS=+;/usr/bin/mplayer -really-quiet -noconsolecontrols "http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q=$*&tl=en"; } say $TEXT
I added xsel for reading string from primary selection, which is exactly what she’s asking for. And then I use plasma’s convenient custom global shortcut to bind a key to this script. Then you can enjoy the google tts with a single key press.
Nice solution.
Check gTTS, a Python script to do the same thing https://github.com/pndurette/gTTS