2013-02-13 135 views
1

我试图直接从命令行(在Windows 7上)对一个google服务器执行一个cURL查询。该服务器属于谷歌的语音API,并进行语音识别。因此需要上传音频文件,并将识别结果返回。所以我连接两个cURL查询,一个上传,一个下载。 就像是:cURL:此方法不支持HTTP方法GET,错误405

curl "https://... " & curl "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 
+0

什么是确切的URL?另外,也许你应该使用官方的Google API来处理这样的请求。这就是API的用途,Google可能会限制基于不正确访问的访问。 – JakeGould 2013-02-13 11:01:06

+0

Jup,我正在使用官方的Google API。但他们没有提供有用的支持......这就是为什么我没有给出确切的URL(那里有一个关键)。 – user2067789 2013-02-13 11:08:09

+0

所以你不能通过URL去除这个问题的关键评论?如果你对此含糊不清,你希望任何人提供什么样的支持。 – JakeGould 2013-02-13 11:23:56

回答

0

卷曲默认使用GET方法。你需要使用-X POST,所以它使用POST。其次,你想上传一个文件,所以你也需要添加一个参数:-d @filename

了解更多关于卷曲的man page

+0

谢谢!它仍然没有工作,但我现在尝试另一个角度。 – user2067789 2013-02-13 14:18:14

+0

我也试图将语音文件提交给speech-api serverice,请让我知道您正在使用的其他角度。 – mhrrt 2013-03-28 09:02:10

+0

@mhrrt:我最终得到了它,但仍然没有完美无缺。无论如何,问题出在windows没有所需的CA软件包(可从curl网站下载)。在Linux中,这个软件包是预先安装的,所以没有问题。 它只适用于.amr文件,因为某些原因。 – user2067789 2013-03-28 14:02:29

2

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

更长sample curl与日志= V

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

{"result":[]} 
[email protected] 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} 

两个几秒钟内通过&连接卷曲表达式,你看到结果。请注意一个GET,一个POST并记下POST上的标题。

+0

我似乎无法找到要获取密钥的页面。 https://developers.google.com/apis-explorer没有列出它... – Sharun 2013-06-28 11:45:27

+1

http://stackoverflow.com/questions/8832087/where-i-can-get-google-developer-key – 2013-06-28 13:15:40

+0

谢谢!我一直在搜索Google Speech API密钥的变体,并且无处可去。 – Sharun 2013-06-28 19:23:09

相关问题