My code for my personal assistant:
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voice')
engine.setProperty('voice', voices[0].id)
# text to speech
def speak(audio):
engine.say(audio)
print(audio)
engine.runAndWait()
Error shown:
Traceback (most recent call last):
File "c:\Users\Samarth S\OneDrive\Desktop\AI Projects\AIVVA\3\main.py", line 18, in <module>
engine.setProperty('voice', voices[0].id)
AttributeError: 'str' object has no attribute 'id'
This is my first python project and I am struck in the voices itself.