Dec-18-2018, 06:57 PM
(This post was last modified: Dec-18-2018, 06:57 PM by DrNerdly118.)
in this particular module, after successfully installing the pip files for the required input, the Google Text to Speech element is non responsive and disallows my module from running. I was wondering if I could get some help on this issue, in order for me to continue working towards the modules completion
from gtts import gTTS import speech_recognition as sr import os import webbrowser import smtplib def talkToMe(audio): print(audio) tts = gTTS(text=audio, lang='en') tts.save('audio.mp3') os.system('mpg123 audio.mp3') #listens for users commands def myCommand(): r = sr.recognizer() with sr.Microphone() as source: print('Hello Pavan, How can I help you today') #Asks for the users command r_pause_threshold = 1 r.ajust_for_ambient_noise(source, duration = 1) audio = r.listen(source) try: command = r.recognize_google(audio) #sets microphone as source (general microphone procedure) print('your reply was:' + command +'/n') #tester during excecution (from variable) #continual listening for commands except sr.UnknownValueError: #any noise thatn is unrecogniswed will trigger this command assistant(myCommand()) return command #returns the comand to the AI #if statementas after excecution: def assistant(command): if 'what\'s up' or 'hi' or 'how is it going' or 'hello' or 'hey kara' in command: talkToMe('Everythings going great Pavan') #tester (if statement command)