概述
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
最后
以上就是曾经石头为你收集整理的python文字转语音开源库的全部内容,希望文章能够帮你解决python文字转语音开源库所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复