its*_*esh 3 python text-to-speech speech-synthesis python-3.x pyttsx
这段代码正在运行,但我只能在Microsoft Windows中预先安装的声音之间切换.这些声音是"Microsoft David Mobile"和"Microsoft Zira Mobile".
后来我安装了"Microsoft Kalpana Mobile"并将其设置为默认的Windows语音.但我仍然无法切换到"Microsoft Kalpana Mobile".代码是 -
import pyttsx3
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id) #changing index changes voices but ony 0 and 1 are working here
engine.say('Hello World')
engine.runAndWait()
Run Code Online (Sandbox Code Playgroud)
只有0和1作为声音[]内的索引.
我想要"微软Kalpana Mobile"发言.我在这个项目上工作了2个月.如果这不起作用,我所有的努力都将继续下去.请帮忙:(
提前致谢.
小智 11
你可以试试这段代码:
import pyttsx3
engine = pyttsx3.init()
voices = engine.getProperty('voices')
for voice in voices:
print(voice, voice.id)
engine.setProperty('voice', voice.id)
engine.say("Hello World!")
engine.runAndWait()
engine.stop()
Run Code Online (Sandbox Code Playgroud)
然后,而不是for循环,只需选择您喜欢的voice.id
我刚刚注意到。设置语言\xe2\x87\x93 这只是我的默认语言设置是“ja_JP”。
\n\nimport pyttsx3\n\nengine = pyttsx3.init()\nvoices = engine.getProperty('voices')\nfor voice in voices:\n print voice\n if voice.languages[0] == u'en_US':\n engine.setProperty('voice', voice.id)\n break\n\nengine.say('Hello World')\nengine.runAndWait()\nRun Code Online (Sandbox Code Playgroud)\n\n或者
\n\nvoice.name == 'Alex'\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
12923 次 |
| 最近记录: |