1 Star 1 Fork 0

开源仓库工具/本地文字转语音工具

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
txt2voice.py 765 Bytes
一键复制 编辑 原始数据 按行查看 历史
chenoh 提交于 2024-08-25 12:33 +08:00 . update txt2voice.py.
# -*- coding:gbk -*-
import pyttsx3
# pip install pyttsx3
# create by csx
# create time 20240825
engine = pyttsx3.init()
# 获取当前可用的语音驱动列表
voices = engine.getProperty('voices')
print(f"Available voices: {len(voices)}")
# 遍历语音驱动,查看每个的信息
for voice in voices:
print(f"ID: {voice.id}")
print(f"Name: {voice.name}")
print(f"Languages: {voice.languages}")
print(f"Gender: {voice.gender}")
print("---")
# 选择一个特定的语音驱动
# 例如,选择第一个女性语音(假设存在)
female_voice = voices[0]
engine.setProperty('voice', female_voice.id)
text = "你好,这是一段离线文本转语音的示例。"
engine.say(text)
engine.runAndWait()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/open-source-repository-tools/local-text-to-speech-tool.git
git@gitee.com:open-source-repository-tools/local-text-to-speech-tool.git
open-source-repository-tools
local-text-to-speech-tool
本地文字转语音工具
master

搜索帮助