python在线合成并播放语音
程序员文章站
2022-04-11 17:28:56
...
from playsound import playsound
from aip import AipSpeech
""" 百度APPID AK SK """
APP_ID = '16881670'
API_KEY = '8FwqrzKk0EAZUWdSol8WHT0p'
SECRET_KEY = 'KhIXWDLGISiWLi2XC2VPt4aX5pHCbWOw'
client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)
tts = '你好,百度'
voiceresult = client.synthesis(tts, 'zh', 1, {'vol': 5,})
if not isinstance(voiceresult, dict):
with open("/home/openailab/stdemo/flite/py_enc/voicebaidu.mp3", "wb") as f:
f.write(voiceresult)
print('speaking...')
playsound('/home/openailab/stdemo/flite/py_enc/voicebaidu.mp3')
上一篇: 百度语音
下一篇: 一个抖音视频下载代码