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 2024-02-05 18:33  pu369com  阅读(38)  评论(0编辑  收藏  举报

导航