【问题标题】:cURL: HTTP method GET is not supported by this URL, Error 405cURL:此 URL 不支持 HTTP 方法 GET,错误 405
【发布时间】:2013-02-13 10:58:30
【问题描述】:

我正在尝试直接从命令行(在 Windows 7 上)对 google 服务器进行 cURL 查询。服务器属于google的speech api,做语音识别。因此需要上传音频文件,并返回识别结果。所以我连接了两个 cURL 查询,一个上传,一个下载。 像这样:

卷曲"https://..." & 卷曲"https://..."

我得到以下错误:

<HTML>
<HEAD>
<TITLE>HTTP method GET is not supported by this URL</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>HTTP method GET is not supported by this URL</H1>
<H2>Error 405</H2>
</BODY>
</HTML>
{"result":[]}

由于我不直接使用 GET 方法,我无法更改任何内容。请帮忙。

谢谢!


编辑:

网址(用 x、y 和 z 表示键等):

curl "https://www.google.com/speech-api/full-duplex/v1/down?pair=xxxxxx" & curl "https://www.google.com/speech-api/full-duplex/v1/up?lang=de-DE&lm=dictation&client=yyyy&pair=xxxxxx&key=zzzzzzz" --header "Content-Type: audio/amr; rate=16000" --data-binary @test.amr

【问题讨论】:

  • 确切的 URL 是什么?此外,也许您应该使用官方的 Google API 来处理这样的请求。这就是 API 的用途,Google 可能会根据不当访问限制对您的访问。
  • Jup,我使用的是官方的 Google API。但他们没有提供有用的支持......这就是为什么我没有给出确切的 URL(那里有一个键)。
  • 所以你不能传递 URL 删除这个问题的审查密钥?如果您对此含糊不清,您希望任何人为您提供什么级别的支持。

标签: curl get


【解决方案1】:

采样率为 8000 的 AMR-NB 应该可以工作。我尝试了amr-wb,但失败了。

更长的sample curl,log=V

rob@ beacon$ curl "https://www.google.com/speech-api/full-duplex/v1/down?pair=12345678901234567" & curl -X POST "https://www.google.com/speech-api/full-duplex/v1/up?lang=en-US&lm=dictation&client=chromium&pair=12345678901234567&key=.....PMU" --header "Transfer-Encoding: chunked" --header "Content-Type: audio/x-flac; rate=22050"  --data-binary @11.rec
[1] 16320

{"result":[]}
rob@ beacon$ {"result":[{"alternative":[{"transcript":"hi how are you we have to go down to the store and see if we can get the groceries for this week so we can bring them back in the car","confidence":0.971865}],"final":true}],"result_index":0}

在几秒钟内用 & 连接两个 curl 表达式,你会看到结果。注意一个 GET,一个 POST,并注意 POST 上的标题。

【讨论】:

  • 我似乎无法找到获取密钥的页面。 developers.google.com/apis-explorer 没有列出来...
  • 谢谢!我一直在寻找 Google Speech API 密钥的变体,但无处可去。
【解决方案2】:

curl 默认使用 GET 方法。您需要将它与 -X POST 一起使用,因此它使用 POST。其次,您要上传文件,因此您也需要将其添加为参数:-d @filename

man page 上阅读有关 curl 的更多信息。

【讨论】:

  • 谢谢!它仍然无法正常工作,但我现在正在尝试另一个角度。
  • 我也在尝试将音频文件提交到speech-api serverice,请告诉我您使用的是什么其他角度。
  • @mhrrt:我最终让它工作了,但仍然不是完美无缺。无论如何,问题在于 Windows 没有所需的 CA 包(可从 curl 网站下载)。在 linux 中,这个包是预先安装的,所以没有问题。出于某种原因,它只适用于我的 .amr 文件。
猜你喜欢
  • 2015-02-14
  • 1970-01-01
  • 2012-12-14
  • 2015-03-10
  • 2020-07-16
  • 2016-01-08
  • 2016-02-13
  • 2016-10-30
相关资源
最近更新 更多