我下载了 pyttsx,除了声音列表只有一个声音(Microsoft Anna)之外,它似乎工作正常。我希望能够将其更改为男性声音,但我没有尝试或研究过!这是我当前的测试代码:
import pyttsx
engine = pyttsx.init()
engine.setProperty('rate', 100)
voices = engine.getProperty('voices')
for voice in voices:
print "Using voice:", repr(voice.name)
engine.setProperty('voice', voice.id)
engine.setProperty('gender', 'male') #this doesn't raise an error, but also won't do anything
engine.say("Hi there, how's you ?")
engine.say("A B C D E F G H I J K L M")
engine.say("N O P Q R S T U V W X Y Z")
engine.say("0 1 2 3 4 5 6 7 8 9")
engine.say("Sunday Monday Tuesday Wednesday Thursday Friday Saturday")
engine.say("Violet Indigo Blue Green Yellow Orange Red")
engine.say("Apple Banana Cherry Date Guava")
engine.runAndWait()
这只运行一个循环。如果我说 print(voices),它会打印一个列表,其中只有一个项目。有什么建议么?