I am using a speech recognition library to create a Siri like program. I hope that in the future I can use the code with an Arduino to control things around my room. Here is my problem:
I have the basic speech recognition code worked out but for the program to understand certain commands I would have to run the speech through a very long list of if-elif-elif-elif-else commands and that might be slow. As most of the time it will be resulting at else as the command will not be recognized I need a faster alternative to a long chain of if-elif-else statements. I am also using a tts engine to talk back to you.
here is my code so far
import pyttsx
import time
engine = pyttsx.init()
voices = engine.getProperty("voices")
spch = "There is nothing for me to say"
userSaid = "NULL"
engine.setProperty("rate", 130)
engine.setProperty("voice", voices[0].id)
def speak():
    engine.say(spch)
    engine.runAndWait()
def command():
    **IF STATEMENT HERE**
r = sr.Recognizer()
with sr.Microphone() as source:
    r.adjust_for_ambient_noise(source) 
    print("CaSPAR is calibrated")
    audio = r.listen(source)
try:
    userSaid = r.recognize_google(audio)
except sr.UnknownValueError:
    spch = "Sorry, I did'nt hear that properly"
except sr.RequestError as e:
    spch = "I cannot reach the speech recognition service"
speak()
print "Done"
 
     
    