1

I am trying to do a cURL query to a google server directly from the command line (on windows 7). The server belongs to google's speech api and does speech recognition. Therefore it needs an upload of a audio file, and gives back the recognition result. So I connect two cURL queries, one uploading, one downloading. Like that:

curl "https://..." & curl "https://..."

I get back the following error:

<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":[]}

Since I do not directly use the GET method I can't change anything. Please help.

Thanks!


Edit:

The URLs (with x, y and z for keys etc.):

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
user2067789
  • 11
  • 1
  • 3
  • What are the exact URLs? Also, maybe you should be using an official Google API to handle a request like that. That’s what APIs are for & Google could be restricting access to you based on improper access. – Giacomo1968 Feb 13 '13 at 11:01
  • Jup, I am using the official Google API. But they are not providing useful support... That's why I did not give the exact URLs (there is a key in there). – user2067789 Feb 13 '13 at 11:08
  • So you can’t pass along URLs removing the key for review for this question? What level of support do you expect anyone to provide you if you are vague about it. – Giacomo1968 Feb 13 '13 at 11:23

2 Answers2

2

AMR-NB with a sample rate of 8000 should work. I tried amr-wb and it failed.

longer sample curl with 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}

two curl expressions connected by & within a couple seconds, you see the result. Note one GET, one POST and note the headers on the POST.

Robert Rowntree
  • 6,230
  • 2
  • 24
  • 43
  • I can't seem to find the page to get a key. https://developers.google.com/apis-explorer doesn't list it... – Sharun Jun 28 '13 at 11:45
  • Thanks! I kept searching for variations of Google Speech API key and was going nowhere. – Sharun Jun 28 '13 at 19:23
0

curl by default uses the GET method. You need to use it with -X POST so it uses POST. And second, you want to upload a file, so you need to add that as a parameter, too: -d @filename.

Read more about curl on the man page.

Tim
  • 1,315
  • 1
  • 14
  • 35
  • Thanks! Its still not working but Im trying another angle now. – user2067789 Feb 13 '13 at 14:18
  • I am also trying to submit audio file to speech-api serverice, please let me know what Other Angle you are using. – mhrrt Mar 28 '13 at 09:02
  • @mhrrt: I got it working in the end, but still not flawlessly. Anyway, the problem was with windows not having the needed CA bundle (downloadable from curl website). In linux this bundle is pre-installed, so no problem there. And it only works with .amr files with me for some reason. – user2067789 Mar 28 '13 at 14:02