Google Speech API:在此服务器上找不到请求的网址

问题描述 投票:0回答:1

我正在尝试对Google Speech API进行一些简单的测试,当我的服务器向此网址发出请求时(下方),我得到了404. that's an error响应。不知道为什么。

https://speech.googleapis.com/v1/speech:recognize?key=[MY_API_KEY]

我的请求正文如下:

{
    "config": {
        "languageCode": "en-US",
        "encoding": "LINEAR16",
        "sampleRateHertz": 16000,
        "enableWordTimeOffsets": true,
        "speechContexts": [{
            "phrases": ["Some", "Helpful", "Phrases"]
        }]
    },
    "audio":{
        "uri":"gs://mydomain.com/my_file.mp3"
    }
}

以下是回复:

enter image description here

正如你所看到的,这是一个有效的资源路径,除非我完全弄错了(我确定我是):https://cloud.google.com/speech-to-text/docs/reference/rest/v1/speech/recognize

更新1:,每当我使用Google API资源管理器工具尝试此操作时,我都会收到超出此配额的消息(即使我尚未向API发出成功请求)。

{
  "error": {
    "code": 429,
    "message": "Quota exceeded for quota metric 'speech.googleapis.com/default_requests' and limit 'DefaultRequestsPerMinutePerProject' of service 'speech.googleapis.com' for consumer '[MY_API_KEY]'.",
    "status": "RESOURCE_EXHAUSTED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.Help",
        "links": [
          {
            "description": "Google developer console API key",
            "url": "https://console.developers.google.com/project/[my_project_id]/apiui/credential"
          }
        ]
      }
    ]
  }
}

更新2:有趣的是,我能够使用Restlet客户端获得200个ok,但即使在这些情况下,响应体也是空的(见下面的截图)

enter image description here

google-api google-cloud-platform google-authentication google-cloud-speech
1个回答
1
投票

我已经使用您添加到帖子中的确切URL和Body内容进行了测试,但是,我能够执行API调用correctly

我注意到,如果我在URL中添加一些额外的字符,它会因为不存在而失败并返回相同的400错误。我建议您验证您的请求的URL不包含拼写错误,并且您使用的客户端正在正确执行API调用。此外,请确保您的调用代码不对url进行编码,这可能会导致在url中显示冒号:时出现问题。

我建议您直接使用Try this API工具或Restlet client执行此测试,这些工具是我用来复制此方案的工具。

© www.soinside.com 2019 - 2024. All rights reserved.