参考调用百度语音识别API进行语音转文字的教程:https://blog.csdn.net/qq_15821487/article/details/119206606
# 安装命令 pip install baidu-aip
from aip import AipSpeech
APP_ID = '*****'
API_KEY = '*******'
SECRET_KEY = '**********'
client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)
def get_file_content(file_path):
with open(file_path, 'rb') as fp:
return fp.read()
result = client.asr(get_file_content('file.wav'), 'wav', 16000, {
'dev_pid': 1537})
print(result['result'])
报错:
该报错表示代码调用api失败,result中没有生成'result'键。
改写代码为:<