2

我想要我的 pyttsx3 模块的 Microsoft David Voice。我写了以下代码。有了voices[0].id它给 Zira(女声),当我使用 voices[1].id它时显示错误list is out of index。请帮忙。我如何获得大卫之声?

import pyttsx3
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id) #changing index changes voices but ony 0 and 1 are working here
engine.say('Hello World')
engine.runAndWait()
Traceback (most recent call last):
  File "C:/Users/admin/Desktop/delet.py", line 4, in <module>
    engine.setProperty('voice', voices[1].id) #changing index changes voices but ony 0 and 1 are working here
IndexError: list index out of range
4

0 回答 0