python文字转语音开源库
Python 文字转语音(TTS,TextToSpeech)有很多库可以实现,例如:
pyttsx3
gTTS
IBM Watson TTS
win32com(Windows 平台)
注意:如未安装请先安装,为节省时间,以下我把安装和使用写在一个代码块中了,应该是分开的。
# pyttsx3
pip install pyttsx3
import pyttsx3
pyttsx3.speak("Hello World")# gTTS
pip install gTTS
from gtts import gTTS
tts = gTTS('Hello World')
tts.save('hello.mp3')# IBM Watson TTS
pip install tts-watson
from tts_watson.TtsWatson import TtsWatson
ttsWatson = TtsWatson('watson_user', 'watson_password', 'en-US_AllisonVoice') ttsWatson.play("Hello World")# win32com(Windows 平台)
import win32com.client as wincl
speak = wincl.Dispatch("SAPI.SpVoice")
speak.Speak("Hello World")
参考网址:https://www.zhihu.com/question/473797102
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
