Android uses Baidu voice recognition example code
This paper uses Baidu speech recognition to complete the function of speech recognition. To use Baidu speech recognition, you must first apply for app ID. there are explanatory documents on Baidu website, which will not be repeated in this paper. After applying, download the SDK package, merge LIBS and res directories into the project according to the requirements of Baidu's official website, and then add them under Android {...} in build.gradle (module: APP)
In this way, the so file of Baidu speech recognition can be used normally.
Add permissions to the manifest file
Then, add the in the manifest
App ID, API_ Key and secret_ Key is replaced by the content you applied for.
We encapsulate a tool class to use speech recognition
The interface of mainactivity is as follows
The class implementation of mainactivity is:
You can run it to see the effect. I think the recognition rate is still good.
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.