Search News with Voice (Search Kit — ML Kit(ASR)— Network Kit)

Mehmet Yozgatlı
Huawei Developers
Published in
3 min readMay 24, 2021

--

Hello everyone. In this article, I will try to talk about the uses of Huawei Search Kit, Huawei ML Kit and Huawei Network Kit. I have developed a demo app using these 3 kits to make it clearer.

What is Search Kit?

HUAWEI Search Kit fully opens Petal Search capabilities through the device-side SDK and cloud-side APIs, enabling ecosystem partners to quickly provide the optimal mobile app search experience.

What is Network Kit?

Network Kit is a basic network service suite. It incorporates Huawei’s experience in far-field network communications, and utilizes scenario-based RESTful APIs as well as file upload and download APIs. Therefore, Network Kit can provide you with easy-to-use device-cloud transmission channels featuring low latency, high throughput, and high security.

What is ML Kit — ASR?

Automatic speech recognition (ASR) can recognize speech not longer than 60s and convert the input speech into text in real time. This service uses industry-leading deep learning technologies to achieve a recognition accuracy of over 95%.

Development Steps

  1. Integration

First of all, we need to create an app on AppGallery Connect and add related details about HMS Core to our project. You can access the article about that steps from the link below.

2.Adding Dependencies

After HMS Core is integrated into the project and the Search Kit and ML Kit are activated through the console, the required library should added to the build.gradle file in the app directory as follows. The project’s minSdkVersion value should be 24. For this, the minSdkVersion value in the same file should be updated to 24.

3.Adding Permissions

4.Application Class

When the application is started, we need to initialize the Kits in the Application class. Then we need to specify the Application class to the “android: name” tag in the manifest file.

5.Getting Access Token

We need to use Access Token to send requests to Search Kit. I used the Network Kit to request the Access Token. Its use is very similar to services that perform other Network operations.

As with other Network Services, there are Annotations such as POST, FormUrlEncoded, Headers, Field.

We need to create our request structure using the RestClient class.

Finally, by sending the request, we reach the AccessToken.

6.ML Kit (ASR) — Search Kit

Since we are using ML Kit (ASR), we first need to get microphone permission from the user. Then we start ML Kit (ASR) with the help of a button and get a text from the user. By sending this text to the function we created for the Search Kit, we reach the data we will show on the screen.

Here I used the Search Kit’s Web search feature. Of course, News, Image, Video search features can be used according to need.

Output

Screen Record

Conclusion

By using these 3 kits effortlessly, you can increase the quality of your application in a short time. I hope this article was useful to you.
See you in other articles :)

References

Network Kit:

ML Kit:

Search Kit:

--

--