gpt4 book ai didi

google-cloud-platform - google speech api 识别无效

转载 作者:行者123 更新时间:2023-12-05 06:40:05 25 4
gpt4 key购买 nike

我正在尝试按照此处找到的有关 google speech api 的示例

https://cloud.google.com/speech/docs/getting-started

1)我创建了如下json请求文件

{
'config': {
'encoding':'FLAC',
'sampleRate': 16000,
'languageCode': 'en-US'
},
'audio': {
'uri':'gs://cloud-samples-tests/speech/brooklyn.flac'
}
}

2) 对我的服务帐户进行身份验证

gcloud auth activate-service-account --key-file=service-account-key-file

3) 成功获取我的授权 token

gcloud auth print-access-token
access_token

4) 然后使用下面的curl命令

curl -s -k -H "Content-Type: application/json" \
-H "Authorization: Bearer access_token" \
https://speech.googleapis.com/v1beta1/speech:syncrecognize \
-d @sync-request.json

但我不断收到以下回复

{
"error": {
"code": 400,
"message": "Invalid recognition 'config': bad encoding..",
"status": "INVALID_ARGUMENT"
}
}

我是否需要访问 uri gs://cloud-samples-tests/speech/brooklyn.flac 的权限?这就是问题所在吗?

提前致谢..

最佳答案

在我看来,这是一个文件格式问题。

您必须发送 WAV 文件而不是 FLAC ...

[ 不支持 FLAC 和 MP3 格式 <=> 需要在服务器端进行文件转换(代表成本)]

将您的音频文件转换为 WAV(使用 ffmpegavconv ),然后重试。

你也可以看看here (查看工作示例)

关于google-cloud-platform - google speech api 识别无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43396831/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com