安徽365热线-Bets365-365bet线上娱乐

百度语音API的申请以及调用

百度语音API的申请以及调用

step1:

打开链接https://cloud.baidu.com/product/speech/tts,点击“立即使用”;

step2:

点击创建应用;

step3:

填写基本信息

step4:

安装python SDK

pip3 install baidu-aip

step5:

创建python文件,复制以下代码

#encoding:utf8

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(text = '你好百度', options={'vol':5})

if not isinstance(result,dict):

with open('audio.mp3','wb') as f:

f.write(result)

else:print(result)

代码参考博客:https://blog.csdn.net/Nicholas_Wong/article/details/80819763

相关推荐