Google Voice api reference article address:
Http://blog.laobubu.net/546
Siry Google Android mobile phone in iPhone 4S Voice Search. (I use very few... Failed). Some time ago, I saw that Baidu was also making a speech on Weibo... At that time, we also mentioned the domestic "KEDA xunfei"
I'm really excited... I want to make a speech game as an iPhone Trainer Program ..
// Configure //----------------------------------------------------------------------------------------
[API] Google's Speech Recognition API, which supports various languages, was published on
You can't afford to hurt a child without a good smartphone! It's unfortunate all day! symbian60! Google search for s60 was downloaded from the previous supertraffic, with the magic of "Voice Search "...... Then I met my Android mobile phone today and came with a voice input method! This accuracy! However, based on my many seconds of experience, s60's waste diesel api library is definitely not so perfect for Speech Recognition (anyone who has ever played Nokia should know that, the feature comes out of the standby status by pressing the right software), So Google certainly has a hand!
(Software see http://www.google.com/intl/zh-CN_ALL/mobile/google-mobile-app)
A lot of nonsense. Now let's take a look at Google's cool api stt! (Belongs to recognize of speech-API V1)
Http://www.google.com/speech-api/v1/recognize? Xjerr = 1 & client = chromium & lang = ZH-CN
But it's not that simple to use ......
How to call
To use this API, you must first have some psychological qualities: In the face of bad FLAC format, because this APIOnly data in FLAC format is supported.Cup.
However, if you find my blog, you are happy because I have prepared many good things for you. (By the way, if you want to reprint remember to clearly mark "from http://blog.laobubu.net", I trust you .)
Now let's take a look at how to request data:
- [Url] http://www.google.com/speech-api/v1/recognize? Xjerr = 1 & client = chromium & lang = ZH-CN
- [Method] Post
- [Request Header] Content-Type: Audio/X-Flac; rate = 16000
- [Post] FLAC file data
- [Optional parameter in url] & maxresults = number of returned results
If your character breaks out, you can get a result similar to this.
{"Status": 0, "ID": "54e1babccaa58682ffbb02ceb42aa47c-1", "hypotheses": [{"utterance": "Test Program", "Confidence": 0.8556527}]}
Or you set maxresults (such as http://www.google.com/speech-api/v1/recognize? Xjerr = 1 & client = chromium & lang = ZH-CN & maxresults = 10) You will get:
{"Status": 0, "ID": "fbf23a887b9ac2bfb630aa40dd1a776c-1", "hypotheses": [{"utterance": "Welcome URLs", "Confidence": 0.7275984 }, {"utterance": "Welcome to my website"}, {"utterance": "Welcome to my website" },{ "utterance ": "Welcome websites" },{ "utterance": "url visited by Baiyun" },{ "utterance": "url visited during pregnancy "}, {"utterance": "Welcome URLs" },{ "utterance": "Welcome URLs" },{ "utterance ": "Baiyun visits my website" },{ "utterance": "visiting my website during pregnancy"}]}
It's not easy.
Instance
Python code
- # By laobubu.net
- Import urllib2
- In this case, a file named 1.flac under the current folder is identified.
- Url = 'HTTP: // www.google.com/speech-api/v1/recognize? Xjerr = 1 & client = chromium & lang = ZH-CN'
- Audio = open (file, 'rb'). Read ()
- Headers = {'content-type': 'audio/X-Flac;
Rate = 16000 '}
- Req = urllib2.request (URL, audio, headers)
- Response = urllib2.urlopen (req)
- Print response. Read (). Decode ('utf-8 ')
PHP code
-
- <? PHP
- $ CH = curl_init ();
- Curl_setopt ($ ch, curlopt_url, "http://www.google.com/speech-api/v1/recognize? Xjerr = 1 & client = chromium & lang = ZH-CN & maxresults = 10 ");
- Curl_setopt ($ ch, curlopt_verbose, 0 );
- Curl_setopt ($ ch, curlopt_header, 0 );
- Curl_setopt ($ ch, curlopt_post, 1 );
- Curl_setopt ($ ch, curlopt_returntransfer, 1 );
- Curl_setopt ($ ch, curlopt_postfields, file_get_contents('1.flac '));
- Curl_setopt ($ ch, curlopt_httpheader, array ("Content-Type:
Audio/X-Flac; rate = 16000 "));
- $ DATA = curl_exec ($ ch );
- Curl_close ($ ch );
- If ($ DATA = json_decode ($ data, true )){
- Echo "<ul> ";
- Foreach ($ data ['hybrid'] as $ I) echo "<li>". $ I ['utterance ']. "</LI> ";
- Echo "</ul> ";
- } Else {
- Echo "<I> identify an error </I> ";
- }
- ?>
Headache: FLAC File Format
Here is a short story. Google's FLAC is also restricted, and 22050Hz + kbps is still normal. If it is more than this, it will be wrong.
But how can we generate the FLAC file?
It doesn't matter. Here is the rescue Star: downloading the cmd.exe package.
Http://datastorage.laobubu.net/FLAC.zip
The tool uses the cmd.exe file .wav to call the file on the command line. The test shows that MP3 and other formats are not supported, but the basic WAV format is supported.
In other environments (such as Linux), there is also a corresponding FLAC download. I have never used Linux.
Now, you can create your app. Haha.
API for automatic conversion from laobubu lab
For convenience, I wrote a python program and put it on the Google App Engine. I only need to submit the URL of an audio file (which supports common formats such as MP3 and WAV), and the file size is small, the result is displayed.
API entry: http://laobubumf.appspot.com/stt/
Backup entry: http://glab.laobubu.net/stt/
If you like it, remember + 1. Of course, I don't mind donating it.