speake3
1.0.0
Speake3庫提供了圍繞ESPEAK的包裝器,以使用Python中ESPEAK TTS引擎的文本到語音功能輕鬆編寫有效的程序。
- Linux system
- Espeak
- python3.x
如果安裝了PIP,請簡單地做;
pip3 install speake3
使用Speake模塊的簡單腳本;
>>> import speake3
>>>
>>> engine = speake3.Speake() # Initialize the speake engine
>>> engine.set('voice', 'en')
>>> engine.set('speed', '107')
>>> engine.set('pitch', '99')
>>> engine.say("Hello world!") #String to be spoken
>>> engine.talkback()
您可以查看已安裝的ESPEAK版本;
>>> version = engine.get("version")
>>> print(version)
您可以一般和特定地查看系統中安裝的聲音;
>>> voices = engine.get("voices") # General
>>> for voice in voices:
>>> print(voice)
>>> voices_2 = engine.get("voices", "en") # Specific
>>> for voice in voices_2:
>>> print(voice)
您可以使用SET方法設置屬性;
>>> engine.set("voice", "en") # voice attribute can be any VoiceName value or
>>> #File value gotten from the voices dictionaries
可以設置的可能屬性是: textfile, stdin, amplitude, wordgap, capitals, line-length, pitch, speed, voice, wavfile, stdout, version, voices, text-encoding, markup, quiet, punct, split, write-pm, nopause
已設置的屬性也可以尚不確定;
>>> engine.unset("speed")
>>> engine.unset("pitch")
如果您在調用對講方法之前對多次呼叫說,則說明方法中的所有字符串參數都將接一個地,因為它們被放入內部隊列中。
>>> engine.say("Hello World")
>>> engine.say("Foo bar")
>>> engine.say("Monty Python")
>>> engine.talkback()