Sep-30-2020, 10:42 AM
here is my code what i am trying to do is
when in text noting or something else than mentioned in my code do noting and continue till in text something has been mentioned
like if in text aloha do noting and continue running till how are you in text also i dont want the program close at all . i couldnt find out how to do it tnx for help in advance
when in text noting or something else than mentioned in my code do noting and continue till in text something has been mentioned
like if in text aloha do noting and continue running till how are you in text also i dont want the program close at all . i couldnt find out how to do it tnx for help in advance
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
def speak(text): tts = gTTS(text = text, lang = "en" ) filename = "voice.mp3" tts.save(filename) playsound.playsound(filename) 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 ( "Expection:" + str (e)) return said text = get_audio() if "DC" in text: if "how are you" in text: speak( "I am fine " ) |