import time as tm
import pyttsx3
tts = pyttsx3.init()
listener = speech.Recognizer()
def bl():
if command.lower() == "hello":
print("Bye lol")
tts.say("Bye lol.")
tts.runAndWait
try:
with speech.Microphone() as source:
print('Speak Mortal')
voice = listener.listen(source)
command = listener.recognize_google(voice)
print("You Said:", command)
tm.sleep(1)
print("Thinking")
tm.sleep(2)
if command.lower() == "hello":
print("Bye lol")
tts.say("Bye lol.")
tts.runAndWait
except:
pass
This works but tts doesn't play audio. But tts alone works if it's not paired with this code. I know it is my code problem as all other tests of pyttsx3 have worked. Tried replacing the whole if statement with bl():, but that didn't work either.