Pythonista Blew My Mind Today: Clipboard to Google Text to Speech in Spanish
The linked gist takes whatever is in the clipboard and reads it out using google text-to-speech. The present form takes Spanish and reads it aloud. I am taking text from the immersion part of Duolingo to help my Spanish learning. It should be quite easy to modify for different purposes.
On a jail-broken device one can: copy to clipboard, use activator to launch the pythonista script, and have it start speaking! I simple gathered some python from the web, fit it together, debugged a bit, and I had a new tool. This blew my mind. Pythonista is fantastic.
After each line, it gives options to quit, read all lines without pause, read next line, or to write your translation. It's still rough around the edges (and deletes everything in the 'temporary' sub-directory without confirmation), but I thought I would share it as it is in case others can build on it or be inspired to change their workflow.
Have you seen the
speechmodule that comes with Pythonista 1.4? It allows you to do text-to-speech a bit more easily, and even without an internet connection.
import clipboard import speech text = clipboard.get() if not text: # Not sure if this translation is correct... text = 'No hay texto en el portapapeles.' speech.say(text, 'es-ES')
Yes, I listened to speech.say initially but liked the sound quality of the Google voice more (and also may expand the code using google translation as well). That said, I'll have another listen and potentially use it offline.
Thanks and thanks for your great software.