【问题标题】:Accessing Google Cloud speech-to-text response访问 Google Cloud 语音到文本的响应
【发布时间】:2019-04-07 15:23:39
【问题描述】:

我完全是初学者,希望有人能指出我正确的方向:我使用了 Google Cloud Speech-to-text API,尤其是 longrunningrecognize 方法。现在一切正常,我得到了预期的结果:

{
  "name": "4983661747957213554",
  "metadata": {
    "@type": 
"type.googleapis.com/google.cloud.speech.v1.LongRunningRecognizeMetadata",
    "progressPercent": 100,
    "startTime": "2019-04-07T10:22:26.018723Z",
    "lastUpdateTime": "2019-04-07T10:23:17.659732Z"
  },
  "done": true
}

在这之后已经被困了一整天。转录已完成,但我如何访问它?我可以调用哪个变量来查看结果?如何将其保存到文件中? 最重要的是,我想知道在 GCP 中运行 Python 脚本的最佳方式是什么。

我已经看到了这个答案:Google cloud speech API response : Parsing iOS 但这给我带来了一个我遇到的非常基本的问题:如何以及在哪里执行该代码的最佳方式?

我也尝试过创建 *.py 文件并对其进行 chmod,但有没有更简单的方法来运行简单的脚本?

我的预期结果是最终的文本文件,甚至只是访问操作背后的字符串:我得到了返回。

【问题讨论】:

    标签: google-cloud-platform speech-recognition


    【解决方案1】:

    Google 在documentation 中有示例:

    在shell中,你可以运行

    curl -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
         -H "Content-Type: application/json; charset=utf-8" \
         "https://speech.googleapis.com/v1/operations/4983661747957213554"
    

    其中 4983661747957213554 是上面返回的操作的名称。它会打印你的结果:

    {
      "name": "7612202767953098924",
      "metadata": {
        "@type": "type.googleapis.com/google.cloud.speech.v1.LongRunningRecognizeMetadata",
        "progressPercent": 100,
        "startTime": "2017-07-20T16:36:55.033650Z",
        "lastUpdateTime": "2017-07-20T16:37:17.158630Z"
      },
      "done": true,
      "response": {
        "@type": "type.googleapis.com/google.cloud.speech.v1.LongRunningRecognizeResponse",
        "results": [
          {
            "alternatives": [
              {
                "transcript": "okay so what am I doing here...(etc)...",
                "confidence": 0.96096134,
              }
            ]
          },
          {
    

    在 Python 中,您可以运行 demo script

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-27
      • 1970-01-01
      • 2021-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多