Google Voice API vs CND

Source: Internet
Author: User

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
  1. # By laobubu.net
  2. Import urllib2
  3. In this case, a file named 1.flac under the current folder is identified.
  4. Url = 'HTTP: // www.google.com/speech-api/v1/recognize? Xjerr = 1 & client = chromium & lang = ZH-CN'
  5. Audio = open (file, 'rb'). Read ()
  6. Headers = {'content-type': 'audio/X-Flac;
    Rate = 16000 '}
  7. Req = urllib2.request (URL, audio, headers)
  8. Response = urllib2.urlopen (req)
  9. Print response. Read (). Decode ('utf-8 ')
PHP code
  1.  
  2. <? PHP
  3. $ CH = curl_init ();
  4. Curl_setopt ($ ch, curlopt_url, "http://www.google.com/speech-api/v1/recognize? Xjerr = 1 & client = chromium & lang = ZH-CN & maxresults = 10 ");
  5. Curl_setopt ($ ch, curlopt_verbose, 0 );
  6. Curl_setopt ($ ch, curlopt_header, 0 );
  7. Curl_setopt ($ ch, curlopt_post, 1 );
  8. Curl_setopt ($ ch, curlopt_returntransfer, 1 );
  9. Curl_setopt ($ ch, curlopt_postfields, file_get_contents('1.flac '));
  10. Curl_setopt ($ ch, curlopt_httpheader, array ("Content-Type:
    Audio/X-Flac; rate = 16000 "));
  11. $ DATA = curl_exec ($ ch );
  12. Curl_close ($ ch );
  13. If ($ DATA = json_decode ($ data, true )){
  14. Echo "<ul> ";
  15. Foreach ($ data ['hybrid'] as $ I) echo "<li>". $ I ['utterance ']. "</LI> ";
  16. Echo "</ul> ";
  17. } Else {
  18. Echo "<I> identify an error </I> ";
  19. }
  20. ?>
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.