如何在 python 3.5 on windows 10 中将文本转换为语音?
How to convert text to speech in python 3.5 on windows 10?
我尝试了 espeak 但没有成功,一些功能仅在 python 2.
中受支持
您是否尝试过通过 gTTS 使用 Google 文字转语音?
在Python3.x中使用的语法如下:
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")
这里是 gTTS 的 github repo。
在Windows中离线使用,直接使用SAPI。
您可以使用 SpVoice.
import win32com.client
speaker = win32com.client.Dispatch("SAPI.SpVoice")
speaker.Speak("Jumpman Jumpman Jumpman Them boys up to something!")
我尝试了 espeak 但没有成功,一些功能仅在 python 2.
中受支持您是否尝试过通过 gTTS 使用 Google 文字转语音?
在Python3.x中使用的语法如下:
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")
这里是 gTTS 的 github repo。
在Windows中离线使用,直接使用SAPI。
您可以使用 SpVoice.
import win32com.client
speaker = win32com.client.Dispatch("SAPI.SpVoice")
speaker.Speak("Jumpman Jumpman Jumpman Them boys up to something!")