#-- FILE: #-- vocab.sh #-- DESCRIPTION: #-- This script allows the user to practice his/her #-- aural comprehension of Spanish. It plays the sound #-- files of spanish words and phrases. #-- The script loops infinitely (until the user quits) #-- playing a random sound file from a directory. #-- #-- The script assumes that the sound files are named #-- in accordance with the spanish word or phrase which #-- is spoken within them. #-- #-- In other words, if the sound file contains the #-- spoken spanish word 'bocadillo' then the file will #-- be named 'bocadillo.wav' #-- AUTHOR: #-- mj bishop #-- DATES: may 02 echo 'starting script ... ' ls *wav > fileList.txt iFileCount=$(cat fileList.txt | wc -l | sed 's/^ *//g') # echo "fc="$iFileCount echo ' WELCOME TO THE SPANISH AURAL PRACTICE SCRIPT ============================================ please press... h or ? to see a help message listing commands q to quit the script to play the next spanish word (sound file) [ press the letter then press ] ' while [ 1 -eq 1 ] do file=$(cat fileList.txt | awk "BEGIN{srand();n=int(rand()*$iFileCount);} NR==n") # echo "file="$file ./WAV.EXE $file /Q echo '>' read line #-- Loop for while the user enters commands while [ "$line" != "" ] do if [ "$line" = "q" ] then exit 0 fi if [ "$line" = "h" -o "$line" = "?" ] then echo ' SOME HELP INFORMATION This Spanish Practice script accepts the following commands: q .......ends the script e .......looks up the text of the english equivalent of the spanish word which you just heard (requires an internet connection) s .......displays the text of the spanish word which you just heard r .......allows the user to rename the sound file of the word which was just played. This is useful when the name of the file does not correspond to the word(s) spoken in it. l .......allows the user to lookup the english translation (equivalent or reversal) of any given spanish word. (requires an internet connection) ? or h ..display this help message .plays the next spanish word (sound file) ' echo '>' fi if [ "$line" = "e" ] then echo '(looking up www.wordreference.com/es/en/ ...):' word=$(echo $file | sed 's/\..*$//g') # echo 'word=' $word #-- The line below looks up the word #-- on a spanish dictionary site and returns the #-- English equivalents by extracting the answer from #-- the html of the returned web-page. #-- This assumes that the file name of the sound file #-- (without the extension) is the written spanish version #-- of the word being said. #-- wget -o temp.txt -O - -nd http://www.spanishdict.com/AS.cfm?e=$word | grep -A1 'ED.cfm' | sed -e '/ED\.cfm/d' -e 's/<\/a>//g' lynx --dump http://www.wordreference.com/es/en/translation.asp?spen=$word | sed -n '/\[3\]/,/\[4\]/p' | sed '1d' | head -20 echo "Spanish: " $word echo '>' fi if [ "$line" = "s" ] then echo "Spanish: " $file | sed 's/\..*$//g' echo '>' fi if [ "$line" = "r" ] then echo "Rename the file $file to what? (c=cancel)" read sNewFileName if [ "$sNewFileName" != "c" ] then mv $file $sNewFileName echo "File $file renamed to $sNewFileName" else echo "File $file not renamed" fi fi if [ "$line" = "l" ] then echo 'What word do you want to find the english translation for ?' echo '(c=cancel) ' read sLookupWord if [ "$sLookupWord" != "c" ] then echo '(looking up www.wordreference.com/es/en/ ...):' #-- spanishdict.com hasn't as many words as wordreference.com #-- wget -o temp.txt -O - -nd http://www.spanishdict.com/AS.cfm?e=$sLookupWord | grep -A1 'ED.cfm' | sed -e '/ED\.cfm/d' -e 's/<\/a>//g' lynx --dump http://www.wordreference.com/es/en/translation.asp?spen=$sLookupWord | sed -n '/\[3\]/,/\[4\]/p' | sed '1d' | head -20 fi fi #-- if $line=l read line done #-- user command loop echo '-----------' echo '> ' done # # wget -o temp.txt -O - -nd http://www.spanishdict.com/AS.cfm?e=abuelo | grep -A1 'ED.cfm' | sed -e '/ED\.cfm/d' -e 's/<\/a>//g' # # 524 ls *wav | nl | awk 'BEGIN{srand();n=int(rand()*502);} NR==n' # 543 lynx --dump http://www.wordreference.com/es/en/translation.asp?spen=adios | sed -n '/\[3\]/,/\[4\]/p'