04 October 2009

English text reader.


The script below is a bash function. Just paste and you will be able to use it.

Once you call it it will speak any piece of text to paste/write until you press Ctrl+D

If you press enter without entering anything new it will repeat the last entry . This is useful if you want to hear a sentence/word many times until you get the correct pronunciation.

I added some tricks to make it work even if the sound card is already in use (it will use ALSA mixer).



#### Console reader
# If after entering a word/text you press enter it will repeat the last input
# Finish with Ctr-C or Ctrl-D
function myreader () {
in2=""
while read in; do

        if [ "$in" = ""  ] ; then
                #espeak --stdout "$in2" | artscat -b 16 -c 1 -r 22000;
                espeak --stdout "$in2" | aplay -q;
                echo " $in2"
                espeak -qx "$in2"
        else
                #espeak --stdout "$in" | artscat -b 16 -c 1 -r 22000;
                espeak --stdout "$in" | aplay -q;
                espeak -qx "$in"
                in2="$in";
        fi;

        #echo "$in2"
done; }
#------------------------------



2 Comments:

Blogger Sangorrin said...

welcome back to the blogsphere :P

12:47 am  
Blogger Ruben }:o) said...

Ha ha... I feel being monitored. :o|

I still have things to share whether they are good or not :o)

9:49 pm  

Post a Comment

<< Home

Too Cool for Internet Explorer