How can i make the python to wait till i complete speaking?
问题 I am writing a program to recognise the speech from a microphone and the code will process accordingly. The code I wrote for this purpose is below. import speech_recognition as sr import webbrowser import pyttsx from time import sleep engine = pyttsx.init() engine.setProperty('rate', 70) r = sr.Recognizer() def recognize(audio): try: return r.recognize(audio) except LookupError, e: print e return '' with sr.Microphone() as source: while True: engine.say("Hi How can i help you ?") sleep(0.15)