Android calls the system interface using voice recognition dialog boxes such as Google Voice, Baidu Voice, and voice flight

Source: Internet
Author: User






Now that the app's development process integrates some speech recognition capabilities, and the general developer doesn't have a speech recognition engine of their own, most of the time is to choose an already mature speech recognition engine SDK to integrate into your app.






Typically, this integration is divided into two, one is to directly invoke the SDK for developers to design a popup, developers do not need to develop the identification interface, there is a developer only use the SDK provided by the speech recognition services, their own development of an interactive design.






This article describes the simplest way to directly tune up a popup box.






First of all, the test machine needs to install such as Google Voice, Baidu Voice, audio and voice products such as voice software, at this point in the system Setup interface language and input to find the relevant speech recognition function list. Then you can call it directly.






Here are the steps to invoke:






First: In the activity instance, an Intent,intent ACTION is set to Recognizerintent.action_recognize_speech or Recognizerintent.action_web_ Search, about recognizerintent You can view the previous articles in this blog, and then call an action with a return result










<pre name= "code" class= "Java" > @Override public        void OnClick (View v) {           Intent intent=new Intent ( Recognizerintent.action_recognize_speech);     Intent intent=new Intent (recognizerintent.action_web_search);           Startactivityforresult (Intent, 0);        }












Then: The result of carrying string recognizerintent.extra_results is taken out in the return result, the Android speech recognition service unifies the result in the form of arraylist<string> return, the following code













@Override    protected void onactivityresult (int requestcode, int resultcode, Intent data) {        Super.onactivityresult (Requestcode, ResultCode, data);        arraylist<string> results = Data                . Getstringarraylistextra (recognizerintent.extra_results);        LOG.I ("ZPF", Results.get (0). toString ());    



In addition, you need to add the following in the configuration file:













<uses-permission android:name= "Android.permission.RECORD_AUDIO"/><uses-permission android:name= " Android.permission.INTERNET "/>












Android calls the system interface using voice recognition dialog boxes such as Google Voice, Baidu Voice, and voice flight




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.