import pyttsx3
engine = pyttsx3.init()
engine.say("")
engine.runAndWait()
import speech_recognition as sr
import pyttsx3
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
# print(voices[1].id)
engine.setProperty('voice', voices[0].id)
def speak(audio):
engine.say(audio)
engine.runAndWait()
r = sr.Recognizer()
with sr.Microphone() as source:
print("Speak anything")
speak("Speak anything")
audio = r.listen(source)
try:
text = r.recognize_google(audio)
print("you said : {}".format(text))
speak("you said : {}".format(text))
except:
print("Sorry could not recognize your voice")
speak("Sorry could not recognize your voice")