您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

使用python中的PYTTSX模块更改语音

使用python中的PYTTSX模块更改语音

嗯,您应该按照该示例中的建议使用engine.setProperty('voice', voice_id)voice_id作为系统中语音的ID;您可以从中获取可用语音的列表engine.getProperty('voices')):

engine = pyttsx.init()
voices = engine.getProperty('voices')
for voice in voices:
   engine.setProperty('voice', voice.id)  # changes the voice
   engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()

您不必循环,可以设置语音ID而无需for循环。 像这样做:

engine = pyttsx.init()
engine.setProperty('voice', voice_id)  # use whatever voice_id you'd like
engine.say('The quick brown fox jumped over the lazy dog.')
python 2022/1/1 18:32:56 有205人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶