Python之语音合成

语音合成,通过接收文字,利用接口来实现语音的合成

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
# coding=gbk
import configparser
from aip import AipSpeech
class Baidu():
def __init__(self):
target=configparser.ConfigParser()
target.read("password.ini")
AppID=target.get('我的工单','AppID')
APIkey=target.get('我的工单','APIKey')
SecretKey=target.get('我的工单','SecretKey')
self.client=AipSpeech(AppID,APIkey,SecretKey)
def combition_voice(self):
result=self.client.synthesis("诺铖,诺铖,我爱你,么么哒,mua","zh",1,{
'vol':5, #音量
'spd':3, #语速
'pit':4, #语调
'per':5, #萝莉音
})
with open("1.mp3",'wb') as f:
f.write(result)
if __name__=="__main__":
baidu=Baidu()
baidu.combition_voice()

Fork me on GitHub