[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
主要步骤:
* 主要使用class pbyttsx3.engine.Engine
* (1)<变量名>=pyttsx3.init() ——初始化来获取语音引擎,必须有。固定写法
*
当我们第一次调用init操作的时候,会返回一个pyttsx3的engine对象(pyttsx3.engine.Engine),再次调用的时候,如果存在engine对象实例,就会使用现有的,否则再重新创建一个。如engine=pyttsx3.init()engine.say(<文本内容>)——调用实例
* (2)调用.say属性朗读文本
* (3)调用.runAndWait()——pytttsx发出语音,并在发出语音时阻塞程序,固定写法
* 最后都要有这句,没有这句没有声音(不能保存),每次调用say(),后面都要接这句
* (4)调用.save_to_file(<文本内容>,'文件名.mp3') ——保存音频到本地,格式为mp3.
调整声音的类型、速度、音量大小
* 调用.getProperty(name:string)属性,获取引擎属性的当前值['rate','voice','voices','volume']可选
* 调用.setProperty(name,value)属性,设置新的引擎属性值['rate','voice','volume']可选
* .getProperty('voices')返回一个含多个class
pyttsx3.voice.Voice的实例(即不同的声音类型)的列表,通过列表切片的方法和.id属性来选取音色
* 通过class pyttsx3.voice.Voice的属性来获取声音的相关信息(.age/.gender/.id/.languages/.name)
* age——发音人的年龄,默认为None
* gender——以字符串为类型的发音人性别: male, female, or neutral.默认为None
* id——关于Voice的字符串确认信息. 调用.id来设置音色
* languages——发音支持的语言列表,如果没有,则为一个空的列表。
* name——发音人名称,默认为None.