使用Python,David和Zira出口文字以mp3形式出口到MP3形式
我最近不得不使用文字进行python的演讲。该代码工作正常。
import pyttsx3
converter = pyttsx3.init()
converter.setProperty('rate', 150)
converter.setProperty('volume', 0.7)
# For Zira's voice uncomment this part of code
# voice_id = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_ZIRA_11.0"
# converter.setProperty('voice', voice_id)
converter.say("Hello I convert text to speech")
converter.say("I am Zira")
现在,我想以mp3表格输出任何文本,即“ Hello David”将保存在MP3文件中。
from gtts import gTTS
from playsound import playsound
mytext="Hello Geek! How are you doing??"
language='en'
myobj=gTTS(text=mytext,lang=language,slow=False)
myobj.save("welcome1.mp3")
playsound("welcome1.mp3")
该代码效果很好,不包括所使用的声音既不是Zira也不是David。
How can I make to export text in voice of David/Zira?
在此处发布的文档中找不到。
I had to use text to speech recently on python. This code worked just fine.
import pyttsx3
converter = pyttsx3.init()
converter.setProperty('rate', 150)
converter.setProperty('volume', 0.7)
# For Zira's voice uncomment this part of code
# voice_id = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_ZIRA_11.0"
# converter.setProperty('voice', voice_id)
converter.say("Hello I convert text to speech")
converter.say("I am Zira")
Now I want to output whatever text I gave to it in mp3 form i.e. "Hello David" would be saved in mp3 file.
from gtts import gTTS
from playsound import playsound
mytext="Hello Geek! How are you doing??"
language='en'
myobj=gTTS(text=mytext,lang=language,slow=False)
myobj.save("welcome1.mp3")
playsound("welcome1.mp3")
This code works great excluding the fact the voice used is neither of Zira nor David.
How can I make to export text in voice of David/Zira?
Couldn't find in docs so posted here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论