python--pyttsx3模塊
文字轉(zhuǎn)語音
import pyttsx3
# 初始化一個朗讀引擎
engine = pyttsx3.init()
# 閱讀
engine.say("study Python!")
# 運行并且等到播放完畢
#修改音量 0-1.0
volume = engine.setProperty("volume",1)
#修改語速
engine.setProperty("rate",200)
#獲取默認(rèn)合成器
voices = engine.getProperty("voices")
print(voices)
# 修改合成器
engine.setProperty("voives",voices[1].id)
將文字保存到MP3中
engine.save_to_file("把文字,寫到,MP3,中,測試內(nèi)容",'output.mp3')
# 運行并且等到播放完畢
engine.runAndWait()

浙公網(wǎng)安備 33010602011771號