适用于 Python 2 和 3 的文本转语音 (TTS) 库。无需互联网连接或延迟即可工作。支持多种 TTS 引擎,包括 Sapi5、nsss 和 espeak。
项目描述
pyttsx3是 Python 中的文本到语音转换库。与其他库不同,它可以离线工作,并且与 Python 2 和 3 兼容。
安装
pip install pyttsx3
如果您收到诸如No module named win32com.client、No module named win32或No module named win32api等错误,则需要额外安装pypiwin32。
用法 :
import pyttsx3 engine = pyttsx3.init() engine.say("I will speak this text") engine.runAndWait()
改变声音,速率和音量:
import pyttsx3 engine = pyttsx3.init() # object creation """ RATE""" rate = engine.getProperty('rate') # getting details of current speaking rate print (rate) #printing current voice rate engine.setProperty('rate', 125) # setting up new voice rate """VOLUME""" volume = engine.getProperty('volume') #getting to know current volume level (min=0 and max=1) print (volume) #printing current volume level engine.setProperty('volume',1.0) # setting up volume level between 0 and 1 """VOICE""" voices = engine.getProperty('voices') #getting details of current voice #engine.setProperty('voice', voices[0].id) #changing index, changes voices. o for male engine.setProperty('voice', voices[1].id) #changing index, changes voices. 1 for female engine.say("Hello World!") engine.say('My current speaking rate is ' + str(rate)) engine.runAndWait() engine.stop() """Saving Voice to a file""" # On linux make sure that 'espeak' and 'ffmpeg' are installed engine.save_to_file('Hello World', 'test.mp3') engine.runAndWait()
图书馆的完整文档
包含的 TTS 引擎:
sapi5
nsss
说
随意包装另一个文本到语音引擎以与pyttsx3一起使用。
项目链接:
PyPI ( https://pypi.python.org )
GitHub ( https://github.com/nateshmbhat/pyttsx3 )
完整文档 ( https://pyttsx3.readthedocs.org )
项目详情
关
pyttsx3-2.90 -py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | a585b6d8cffc19bd92db1e0ccbd8aa9c6528dd2baa5a47045d6fed542a44aa19 |
|
MD5 | 43ce353b05a353f3b858d78423147123 |
|
布莱克2-256 | 339ade4781245f5ad966646fd276259ef7cfd400ba3cf7d5db7c0d5aab310c20 |