All Tutorials / Cardboard Hacker / Randomizing Answers in Speech Recognition

Randomizing Answers in Speech Recognition

How it Works

This system works by taking a phrase from a text file. If I say:


You look nice today

The computer, using the FileReadRandom() command, opens the complements.txt text file and reads a random line from that file. That file is full of complements, one on each line. Because the script sets a variable as what the computer read, you then use either the "Sayezb()" or "say()" commands to read that variable, which in turn responds to your statement with a complement.

The same process occurs if you greet the robot, but uses a different text file and a different variable.