我创建了一个API密钥,并没有对其设置任何限制。但是,在对“语音到文本Api”进行请求时,此代码始终返回“无效密钥”:
import requests
import sys
GOOGLE_SPEECH_URL = 'https://www.google.com/speech-api/v2/recognize?output=json&lang=en-us&key=<real_key>'
f = open("/[....]/file.flac", "rb")
data = f.read()
res = requests.post(GOOGLE_SPEECH_URL, data=data, headers={'Content-type': 'audio/x-flac; rate=16000'})
print(res.text)
f.close()
===>
<p><b>403.</b> <ins>That’s an error.</ins>
<p>Your client does not have permission to get URL <code>/speech-api/v2/recognize?output=json&lang=en-us&key=<real_key></code> from this server. Invalid key. <ins>That’s all we know.</ins>
这是怎么回事?