import pyttsx3# 初始化朗讀引擎
engine = pyttsx3.init()
# 設置朗讀速度
self.engine.setProperty('rate', 120)
# text為需要讀取的內容
self.engine.say(text)
# 不添加下面這句,沒有聲音
self.engine.runAndWait()
pyttsx3其他應用:
python pyttsx3實現文字朗讀_JSON_L的博客-CSDN博客_python3 朗讀文字pyttsx3是Python中的一個文本到語音轉換庫。與其他庫不同,它可以脫機工作,并且與python2和python3兼容1.安裝pyttsx3pip install pyttsx32.朗讀demoimport pyttsx3import timedef talkWith(engine, content): """ 朗讀內容 """ engine.say(content) engine.runAndWait()def talkContent(cohttps://blog.csdn.net/json_ligege/article/details/114027076pyttsx3 和 win32com.client 更換說話人的聲音_中南自動化學院“智能控制與優化決策“至渝的博客-CSDN博客_pyttsx3改變聲音的類型pyttsx3查看可以設置幾種聲音 engine = pyttsx3.init() # 初始化 voices = engine.getProperty('voices') for voice in voices: print ('id = {} \nname = {} \n'.format(voice.id, voice.name)) engine.setProperty('voice', voices[2].id) #設置發音人我電腦輸出是id
https://blog.csdn.net/qq_43657442/article/details/108205540