Wednesday, September 16, 2009

Read selection

And onto further adventures!

After making that zenspeak script I got told that it'd be more useful, if you could enter a whole lot of text into it. So then it dawned on me that maybe having a Gedit plugin like that could be useful.

So, if you got the External Tools plug-in installed in Gedit, you can put this script in there somewhere, tweak it a bit to use your favorite speech generator, voice, etc., and you're all set to never read a single word again.

One drawback: it won't be easy to stop it if you've let it run, so if you make it read a lot of text, it might be troublesome.

I suppose I don't have it in me to really write stuff here today.

The code:
 
1 #!/bin/bash
2 text=`xargs -0 echo`
3
4 SYSTEM=espeak
5
6 if [ -n "$text" ]
7 then
8 echo "Reading \"$text\" with $SYSTEM."
9
10 if [ $SYSTEM == espeak ]
11 then
12 padsp espeak "$text" -v en+f3
13 elif [ $SYSTEM == festival ]
14 then
15 echo "$text" | festival --tts
16 fi
17 fi


The code is also available at GitHub as gedit/gedit_read_selection.

No comments: