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