程序连接科大讯飞语音,将一段文本转换为一个mp3语音格式存在当前文件夹下:
#科大讯飞语音
def txt2voice(msg):
import requests
import json
url = 'http://www.xfyun.cn/herapi/solution/synthesis?vcn=x_xiaolin&vol=7&spd=medium&textType=cn&textPut='+msg
head = {'Accept': 'application/json, text/javascript, */*; q=0.01',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN',
'Connection': 'Keep-Alive',
'Cookie': 'token=null; account_id=null; SESSION=8e0116e7-32f0-4d55-96b5-08af593936f4; pgv_pvi=3816536064; Hm_lvt_83a57cc9e205b0add91afc6c4f0babcc=1518569845; pgv_si=s7171897344; Hm_lpvt_83a57cc9e205b0add91afc6c4f0babcc=1518569969',
'Host': 'www.xfyun.cn',