help need to code . when user speaks "hey kumar" statements within this condition is not working | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

help need to code . when user speaks "hey kumar" statements within this condition is not working

import os import time import speech_recognition as sr import playsound from gtts import gTTS def speak(text): tts = gTTS(text=text, lang='en') fn = "voice.mp3" tts.save(fn) playsound.playsound(fn) def get_audio(): r = sr.Recognizer() with sr.Microphone() as source: audio = r.listen(source) said ="" try: said = r.recognize_google(audio) print(said) except Exception as e: print("Exception:"+str(e)) speak("speak again") get_audio() return str(said) x = get_audio() if "hey kumar" in x: speak("i am waiting for your command") f = 0 while f == 0: text=get_audio() if ("hi" or "hello") in text: speak("hi, how can i help you") if "what is your name" in text : speak("i am virtual assistant") if "bye" in text : speak("bye, call me back when you need my assist") f = 1 """ computer doesnot responding to statements within the if condition help needed. """

16th Jan 2020, 3:36 PM
MANOJ KUMAR S
MANOJ KUMAR S - avatar
1 Réponse
0
do you get the expected output via “print(said)”?
18th Jan 2020, 8:02 AM
phil