pu369com

Python文本转语音库:pyttsx3 初识

1.安装

pip install pyttsx3

2.示例

复制代码
#coding=utf-8
import pyttsx3
text ="""
在这个例子中,使用三引号可以创建多行字符串,换行符会自动包含在字符串中。

请注意,在这些方法中,字符串的换行拼接可以根据需要进行布局,以增强代码的可读性和可维护性。
"""
engine = pyttsx3.init() # object creation
#更改速率
engine.setProperty('rate', 168)
#更改音量
engine.setProperty('volume',1.0)    
# setting up volume level  between 0 and 1
#把语音存储到文件
engine.save_to_file(text,'abc.mp3')
engine.runAndWait()
engine.stop()
print("end")
复制代码

 

 

参考:https://mp.weixin.qq.com/s?__biz=MzA4NTA5OTc2NA==&mid=2650785522&idx=1&sn=fbb8e45c5809bbff41eebb60f93cf6c6&chksm=87d67369b0a1fa7f8bfdbce381d05f61060b253d9779c1f0bdb33c9f8e0382d180da07ca8661&scene=27

https://blog.csdn.net/weixin_42420354/article/details/132769116

https://blog.csdn.net/m0_60659514/article/details/128230253

https://blog.csdn.net/m0_60659514/article/details/134302470

https://blog.csdn.net/m0_46140714/article/details/117410374

https://www.jianshu.com/p/10121e50279a

posted on   pu369com  阅读(232)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 上周热点回顾(3.3-3.9)
· AI 智能体引爆开源社区「GitHub 热点速览」
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示