#-- 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 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 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. h ....... ? .......both display this help message .plays the next spanish word (sound file) ' echo '>' read line fi if [ "$line" = "e" ] then echo 'English (looking up ...):' 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' echo "Spanish: " $word echo '>' read line fi if [ "$line" = "s" ] then echo "Spanish: " $file | sed 's/\..*$//g' echo '>' read line 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 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'