speech recognition

Hello, i am new to mac scripting so I am quite unexperienced with it. I am looking for a way for speech recognition to listen for keywords which would then play a random sound file from specific folder. For example, whenever speech rogonition heard the word “tree” it would then select and open a random aiff clip from a folder called “tree”. Likewise if it heard the word “monkey” it would pick a random file from the “monkey” folder. This process would continue to loop ad infinitum( or at least for a really long time). as of yet I can only get one specific sound file to trigger if only one word is spoken. If i say a whole sentence it doesnt work. Again i am new to scripting and am not even sure if this is possible. Thanks. brian Please respond to blove666@hotmail.com

I’m not exactly clear where you’re getting hung up if you’ve managed to get one sound file to work.
But in general speech recognition won’t work well picking up one word in the middle of a sentence. It responds best to isolated words or phrases.
That said, you simply need to name a script “monkey” or “tree” and put in in the right place, and then the script itself of course should do what you want, which is, basically (untested, off the top of my head):

tell app "finder" 
set theMonkeyFolder to "harddrive:stuff:monkeys:" as alias 
set the_files to every file of theMonkeyFolder whose file type is "AIFF" --not sure about the file type sytnax for aiff better check 
set n to random number from 1 to count the_files 
set theFile to item n of the_files as alias 
play theFile --not sure of the play syntax for audio files end tell