簡體   English   中英

訪問Google Cloud語音轉文本響應

[英]Accessing Google Cloud speech-to-text response

我完全是個初學者,我希望有人能為我指明正確的方向:我使用了Google Cloud語音到文本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雲語音API響應:解析iOS,但這使我面臨一個非常基本的問題,即執行代碼的最佳方法是什么?在哪里?

我也嘗試過創建* .py文件並對其進行chmod修改,但是有沒有更簡單的方法來運行簡單腳本?

我的預期結果是最終的文本文件,甚至只是訪問操作背后的字符串:我得到了返回。

Google在文檔中提供了示例:

在外殼中,您可以運行

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"

其中4986661747957213554是上面返回的操作名稱。 它將打印出結果:

{
  "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中,您可以運行演示腳本

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM