无法检测我们是否在 Google Compute Engine 上运行

stu*_*ent 6 android google-cloud-platform google-cloud-speech

我正在尝试使用 Google Cloud Speech 识别,但出现此错误

I/omputeEngineCredentials:无法检测我们是否在 Google Compute Engine 上运行。W/System.err: java.io.IOException: 应用程序默认凭据不可用。如果在 Google Compute Engine 中运行,它们就可用。否则,必须定义环境变量 GOOGLE_APPLICATION_CREDENTIALS 指向定义凭据的文件。有关 更多信息,请参阅 https://developers.google.com/accounts/docs/application-default-credentials

我从系统属性/环境变量/用户变量设置环境变量,并且我使用本指南手动设置凭据。

我已经搜索了与此相关的每个主题,但我无法让它发挥作用。我错过了什么?

sne*_*hab 6

我在从本地连接到云存储时遇到了这个问题。以下是我遵循的对我有用的步骤:

  1. 安装云SDK。参考链接:云SDK
  2. 按照所有步骤初始化 SDK。
  3. 现在,在应用程序的根目录中使用以下命令创建应用程序默认凭据 gcloud auth application-default login,google-cloud 将自动检测您的凭据。


小智 0

如果无法访问日志和代码,很难说,但您可能应该从直接从控制台调试对语音 API 的访问开始。 gcloud auth activate-service-account --key-file=[PATH] gcloud ml speech recognize 'gs://cloud-samples-tests/speech/brooklyn.flac' \ --language-code='en-US' https://cloud.google.com/blog/products/ai-machine-learning/ml-explorer-talking-and-listening-with-google-cloud-using-cloud-speech-and-text-to-speech

可能的原因是: - API 被禁用, - 您使用的凭据不包含 ML 权限。- 凭证文件路径错误。