How to Implement Dictation Word Broadcast: Super Simple Integration With ML Kit Can Achieve This!
This article explains how to implement dictation word broadcast by using an automatic voice broadcast app that uses functions of an ML kit.
Join the DZone community and get the full member experience.Join For Free
I believe we all have dictation when we first start learning a language. Nowadays, an important after-school assignment for primary school students is the dictation of new words in the text. Many parents have this experience. On the one hand, this kind of word reading is relatively simple, and on the other hand, parents' time is precious. Nowadays, many dictations are available in the market. These speakers record the words after class in Chinese textbooks for parents to download. However, this kind of recording is not flexible enough; if the teacher left a few extra words today that were not part of the after-school exercise, the recording would not satisfy the needs of parents and children. This document describes an automatic voice broadcast app that uses the universal text recognition function and speech synthesis function of our ML kit. You only need to take photos of dictated words or texts, and then, the text in the photos can be automatically broadcast. The tone can be adjusted.
1. Open the AndroidStudio project-level build.gradle file.
2. Choose allprojects > repositories and configure the Maven repository address of the HMS SDK.
3. Choose buildscript > repository and configure the Maven repository address of the HMS SDK.
4. Choose buildscript > dependencies and configure the AGC plug-in.
Adding Compilation Dependencies
1. Open the application-level build.gradle file.
2. Integrating SDK:
3. Add the ACG plug-in to the file header.
4. Specify permissions and features: declare them in the AndroidManifest.xml file.
Key Steps of Reading Code Aloud
There are two functions: one is to recognize the text, and the other is to read aloud. You can read aloud by using OCR+TTS. After taking a photo, you can click to play the photo.
1. Dynamic permission application.
2. Start reading interface.
3. Invoke createLocalTextAnalyzer() in the onCreate() method to create a text recognizer on the device.
4. Invoke createTtsEngine() in the onCreate() method to create a TTS engine, construct a TTS callback to process the TTS result, and transfer the TTS callback to the new TTS engine.
5. Set the read, take, and read buttons.
6. Enable text recognition in photo and photo read callbacks.
7. After the recognition is successful, click the play button to start the playback.
Now, you know how to implement a dictation word broadcast function in just a few minutes.
Opinions expressed by DZone contributors are their own.