2
我想現在如何將文本轉換爲Python中的語音。如何將文本轉換爲Python中的語音
在.NET中,我用
Dim SAPI
Msg = 'Hi this is a test'
SAPI = CreateObject("sapi.spvoice")
SAPI.Speak(Msg)
我想現在如何將文本轉換爲Python中的語音。如何將文本轉換爲Python中的語音
在.NET中,我用
Dim SAPI
Msg = 'Hi this is a test'
SAPI = CreateObject("sapi.spvoice")
SAPI.Speak(Msg)
您可以通過pyttsx模塊實現它。它使用默認的MS語音識別系統。
import pyttsx
engine = pyttsx.init()
engine.say("Your Message")
engine.runAndWait()
我知道它的真正晚在這裏回答,但我想我會在這裏發佈,因爲我基於使用SAPI
在python
TTS
轉換,這是OP的原來的問題有解決方案。
這對於使用SAPI
的python
尋找解決方案的其他人可能會有用。
from win32com.client import constants, Dispatch
Msg = "Hi this is a test"
speaker = Dispatch("SAPI.SpVoice") #Create SAPI SpVoice Object
speaker.Speak(Msg) #Process TTS
del speaker #Delete speaker object and free up memory
你能告訴我怎樣才能改變它的聲音,女聲(也語) –
還耽誤..... –
我沒有親自做這件事,但根據研究,這可能是可能的通過設置「Sapi.SpVoice.Voice」屬性來改變語音。請參閱此處的SAPI文檔http://www.microsoft.com/en-us/download/details.aspx?id=10121 –