How to convert text to speech in python 3.5 on windows 10?

假装没事ソ 提交于 2019-12-30 10:34:30

问题


I tried espeak but didn't succeed and some functionalities only supported in python 2.


回答1:


Have you tried using gTTS?

The syntax for using it in Python 3.x is as follows:

from gtts import gTTS
my_tts = "Text you want to process"
tts = gTTS(text=my_tts, lang='en')
tts.save("Absolute/path/to/file.mp3")

Here is the github repo of gTTS.




回答2:


For offline use: Direct use SAPI [Windows]

Following code will help for demo...

import win32com.client speaker = win32com.client.Dispatch("SAPI.SpVoice") speaker.Speak("Jumpman Jumpman Jumpman Them boys up to something!")



来源:https://stackoverflow.com/questions/38540005/how-to-convert-text-to-speech-in-python-3-5-on-windows-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!