我正在使用Google Cloudshell。我正在尝试按照https://codelabs.developers.google.com/codelabs/cloud-speech-intro/index.html#7的示例进行操作,该示例说要使用命令
curl -s -X POST -H "Content-Type: application/json" --data-binary @request.json \
"https://speech.googleapis.com/v1/speech:recognize?key=${API_KEY}"
,但未创建任何输出。我将命令稍加修改为
curl -v POST -H "Content-Type: application/json" --data-binary @request.json \ "https://speech.googleapis.com/v1/speech:recognize?key=${API_KEY}"
我确实用API密钥替换了占位符文本。现在我可以看到结果了:
(1)libcurl中不支持或禁用协议“ https”
因此,我检查了正在使用的curl的版本,并发现https应该可以正常工作:
curl 7.52.1(x86_64-pc-linux-gnu)libcurl / 7.52.1 OpenSSL / 1.0.2r zlib / 1.2.8 libidn2 / 0.16 libpsl / 0.17.0(+ libidn2 / 0.16)libssh2 / 1.7.0 nghttp2 / 1.18.1 librtmp / 2.3
协议:dict文件ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
功能:AsynchDNS IDN IPv6大文件GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS代理PSL
我的request.json文件内容为:
{
"config": {
"encoding":"FLAC",
"languageCode": "en-US"
},
"audio": {
"uri":"gs://cloud-samples-tests/speech/brooklyn.flac"
}
}
我正在尝试获得以下结果:
{
"results": [
{
"alternatives": [
{
"transcript": "how old is the Brooklyn Bridge",
"confidence": 0.98267895
}
]
}
]
}