赞
踩
https://github.com/Baidu-AIP/python-sdk
pip install git+https://github.com/Baidu-AIP/python-sdk.git@master
pip install playsound
from aip import AipSpeech """ 你的 APPID AK SK """ APP_ID = '你的 App ID' API_KEY = '你的 Api Key' SECRET_KEY = '你的 Secret Key' client = AipSpeech(APP_ID, API_KEY, SECRET_KEY) result = client.synthesis('你好百度', 'zh', 1, { 'vol': 5, }) # 识别正确返回语音二进制 错误则返回dict 参照下面错误码 if not isinstance(result, dict): with open('audio.mp3', 'wb') as f: f.write(result)
执行成功后会生成一个audio.mp3
的音频文件:
from playsound import playsound
playsound('audio.mp3')
参考:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。