I'm creating a google search chatbot with voice recognition. I created a text file with the key words being,
search, who is, what is, where is,
The idea is that if the user says any of those phrases it'll know to do a google search but, the user will say 'who is john lennon' and my program won't recognise that command, even though it has 'who is'. How would i be able to make it handle the object that they are searching? This is my code:
#MODULES AND LIBARYS USED
import win32com.client as wincl #AI VOICE
import speech_recognition as sr #SPEECH RECGN
from datetime import datetime #DATE AND TIME
import time #TIME MODULE
from aicomm import *
from aifunc import *
#STATIC OBJECTS
s = wincl.Dispatch("SAPI.SpVoice") #INITS VOICE
r = sr.Recognizer() #INITS RECOGNIZER
done = False
#FUNCTIONS
def Main(comm):
while True:
done = input("\nPress key to talk..")
with sr.Microphone() as source:
audio = r.listen(source)
comm = r.recognize_google(audio)
comm = comm.lower()
print(comm) #for debugging
if comm in open("search_triggers.txt").read():
print("working") #if key word found, program prints 'working'
if __name__ == "__main__":
Main('x')