目录

1. 简单介绍

2. 代码示例


1. 简单介绍

 pyttsx3 · PyPIText to Speech (TTS) library for Python 2 and 3. Works without internet connection or delay. Supports multiple TTS engines, including Sapi5, nsss, and espeak.https://pypi.org/project/pyttsx3/pyttsx3 是 Python 中的文本到语音转换库。与其他库不同,它离线工作,并且与 Python2 和Python3 兼容。

2. 代码示例

安装:

pip install pyttsx3

Python:

import pyttsx3 as pytts


tts = pytts.init()
tts.setProperty("rate", 150)
tts.setProperty("volume", 1)
voices = tts.getProperty("voices")
tts.setProperty("voice", voices[0].id)
tts.say("这是TTS测试")
tts.runAndWait()
tts.stop()

Logo

在这里,我们一起交流AI,学习AI,用AI改变世界。如有AI产品需求,可访问讯飞开放平台,www.xfyun.cn。

更多推荐