Integration and use of Android Huawei HiAI voice recognition

1. Introduction to speech recognition

Speech recognition is based on speech. Through speech signal processing and pattern recognition, machines can automatically recognize and understand human spoken language.

Speech recognition technology, also known as automatic speech recognition ASR, is a technology that allows machines to convert speech signals into corresponding text or commands through the process of recognition and understanding.

The speech recognition SDK development kit is a set of secondary development interfaces related to speech recognition provided by major speech recognition companies. Users can use this interface to quickly develop speech recognition applications that meet customer needs.                    

The main speech recognition service providers are:

Baidu, Tencent, iFlytek, Yunzhisheng, Alibaba, Huawei

Baidu, Xunfei, Tencent, Ali and other service providers have begun to charge for voice recognition, but they provide a limited time trial.

Huawei's HiAI is free, but only for Huawei terminals.

2. Introduction to Huawei HiAI

Huawei speech recognition is based on the HUAWEI HiAI open platform.

HUAWEI HiAI is an AI capability open platform for smart terminals, based on a three-tier open architecture of "core, terminal, and cloud".

The advantage of HUAWEI HiAI is that it makes full use of the NPU capability of Huawei's Kirin chip, combined with Huawei EMUI to build the capability on the end side, which can realize fast access, lightweight deployment, decoupling and independent deployment of Engine and App, rapid upgrade and online model update support . Another advantage is that Huawei HiAI is free and open to developers.

Huawei's voice recognition engine is a voice recognition capability for mobile terminals. It provides developers with artificial intelligence application layer APIs that can convert voice files and real-time voice data streams into Chinese character sequences with an accuracy rate of over 90%

Third, the use of Huawei voice recognition

1. Registration and certification download

First, you need to register for certification, enter the page of Huawei Developer Alliance, and log in to the official website of Huawei Developer Alliance.

Then enter the service access, first click "Management Center"> "Development Service", click the HUAWEI HiAI card to add HUAWEI HiAI service.

Then sign the Huawei developer HiAI service agreement

Then you can download the SDK, click "SDK Download" to download the SDK compressed package.

It is recommended to use Android Studio 3.0.1 and above to develop HiAI applications, the terminal processor is no less than Kirin 970, and the system software version is no less than EMUI 8.1.0.

2. Development steps

(1) Add dependent libraries

Copy the huawei-hiai-pdk-1.0.0.aar and huawei-hiai-asr-10.0.4.309.aar packages to app/libs in the project.

In build.gradle, add huawei-hiai-pdk-1.0.0.aar and huawei-hiai-asr-10.0.4.309.aar to the project.

(2) Program design

       1) Initialization of the speech recognition engine,

         Call the createAsrRecognizer() method to create the engine,

         Configure the voice input source and silence detection time,

         Call the mAsrRecognizer.init method to initialize. The init method has two parameters:

         The first parameter is intent, which will pass in the voice input source and silence detection time just set.

         The second parameter is an AsrListener, which is used to monitor various states of speech recognition. This Listener needs to be implemented.

       2) After the initialization is complete, when the user clicks the voice recognition button, the startListening() method is called for voice recognition.

         The onResults and onPartialResults methods in the AsrListener class can obtain the recognition result. After the recognition result or part of the recognition result is obtained, the useful result needs to be processed. If the "front" is recognized, the forward command "ONA" needed by the car terminal needs to be sent , If the "left" is recognized, the left turn command "ONC" is sent, and so on.

        3) When the recognition is not needed, you can call the cancel or stop recognition method.

        4) When the page is destroyed, you need to call the engine release method to release the engine.

Fourth, the complete code

Follow the public account "Android hard development", reply "Bluetooth car"

 

Guess you like

Origin blog.csdn.net/Lwjobs/article/details/112717479