【发布时间】:2019-02-13 15:23:35
【问题描述】:
声明这是我第一次使用 Google Cloud,所以这可能是一个菜鸟问题。
我想使用 Google Cloud Speech 库对音频文件上的文本进行一些语音。我还想通过提供私钥文件在代码中明确说明要使用的 Google Cloud 服务帐户凭据。我该怎么做?
看来我想要的是this quickstart for speech recognition 和this example of how to set credentials within the code 的混合(explicit() 部分)。
我试过这样做,但是explicit() 使用google.cloud.storage 来设置客户端,
from google.cloud import storage
storage_client = storage.Client.from_service_account_json('service_account.json')
为了发出 API 请求。
设置
client = storage.Client.from_service_account_json('service_account.json')
然后运行
client.recognize(config, audio)
显然会抛出一个错误,指出client 没有该属性。我的猜测是我需要类似的东西,但是对于google.cloud.speech?我试过查看文档 - 我错过了什么吗?
【问题讨论】:
标签: python google-cloud-platform