Social Proof

Text to speech on Huawei

Speechify is the #1 audio reader in the world. Get through books, docs, articles, PDFs, emails - anything you read - faster.
Try for free

Featured In

forbes logocbs logotime magazine logonew york times logowall street logo
Listen to this article with Speechify!
Speechify

Let’s look at Huawei's built-in features and check out some programming techniques you can use to expand on Huawei’s TTS features.

Text to speech on Huawei

If you find a Samsung mobile device’s cost too high or want an alternative, you might try a Huawei phone. Though these devices often have downsides, such as the lack of access to the Google Play store, they still run the Android operating system.

That means you can use built-in text to speech (TTS) readers for verbal playback. Let’s look at how to do that and check out some programming techniques you can use to expand on Huawei’s TTS features.

Who is Huawei?

Since its founding in 1987, Huawei has established itself as a leading electronics and communication technology provider. The Chinese company operates in over 170 countries and employs 195,000 people.

Most know Huawei as the manufacturer of a range of cost-effective mobile devices, such as smartphones. Most of these devices use a version of the Android operating system. However, they have limitations due to many American companies having data-related concerns.

Even so, Huawei is a world-leading technology company that offers a variety of helpful devices and services.

How to enable the TalkBack TTS engine on Huawei devices

Huawei has a built-in text to screen reader named TalkBack. It functions similarly to VoiceOver, which you can find on Apple’s iPhone and iPad.

The app gives you voice feedback, which means it reads anything on your screen aloud. You can also operate a Huawei phone with voice commands – you don’t have to look at the screen. As such, TalkBack is ideal for visually impaired people.

Here’s how to activate TalkBack:

  1. Open “Settings” and select “Accessibility Features.”
  2. Tap “Accessibility.”
  3. Choose “TalkBack” and enable the software.
  4. Tap “OK.”

Disabling TalkBack

If you want to turn TalkBack off, hold your phone’s power button until it displays the “Restart” and “Power Off” icons. Then, touch the screen and hold for three seconds to deactivate TalkBack.

Converting text to speech

Once TalkBack is activated, do the following to have it turn digital text into speech:

  1. Open “Settings” and navigate to the “Accessibility” screen.
  2. Tap “Text to speech” and select your desired text to speech engine.
  3. Adjust the speech rate and pitch to your preferences.

Note that you can use these steps to turn text to speech on for any TTS app installed on your Huawei device. Once activated, your phone will read any text information it sees out loud.

Adding voice to an Android application using MLTtsengine.speak

Huawei devices feature the MLTtsengine.speak development kit. This kit allows you to add text to speech functionality to any Android app you create using the device.

Here are the basic steps using information from a developer named Tushar Srivastava:

  1. Create a new project using Android Studio.
  2. Add the following dependency to the project:
    • implementation 'com.huawei.hms:ml-computer-voice-tts:1.0.4.300'
  3. Add the AGC plugin to the top of the app.gradle file using this code:
    • apply plugin: 'com.huawei.agconnect'
  4. Create a callback in your Android Studio activity using the following code:

var callback: MLTtsCallback = object : MLTtsCallback {

override fun onError(taskId: String, err: MLTtsError) {

}

override fun onWarn(taskId: String, warn: MLTtsWarn) {

}

override fun onRangeStart(taskId: String, start: Int, end: Int) {

}

override fun onEvent(taskId: String, eventName: Int, bundle: Bundle?) {

if (eventName == MLTtsConstants.EVENT_PLAY_STOP) {

val isStop = bundle?.getBoolean(MLTtsConstants.EVENT_PLAY_STOP_INTERRUPTED)

}

}

  1. Initialize the object using the following lines of code:

mlConfigs = MLTtsConfig()

.setLanguage(MLTtsConstants.TTS_EN_US)

.setPerson(MLTtsConstants.TTS_SPEAKER_FEMALE_EN)

.setSpeed(1.0f)

.setVolume(1.0f)

mlTtsEngine = MLTtsEngine(mlConfigs)

mlTtsEngine.setTtsCallback(callback)

  1. Create the below method in your activity so that you can access your text to speech output in your app with a button click:

private fun startTtsService() { val id = mlTtsEngine.speak(sourceText,MLTtsEngine.QUEUE_APPEND)}

Other Useful Callback methods

The Huawei APIs offer several callback methods for using audio data and text to speech in an app. Here are the four most common.

Public void onError()

If an error occurs, the control flow heads to this error callback. It’s used to advise an app user that an error occurred and request they send analytics data to the appropriate place for verification.

Public void onWarn()

The callback flows here if the user experiences a warning, such as not having enough bandwidth for the app.

Public void onEvent()

Use this callback whenever a new event occurs, such as the user pausing audio.

Public void onRangeStart()

This callback returns the mapping between the currently playing segment and the text the user wants to read.

Additional Notes

Any new mlttscallback routine you create has limitations. In the above example, characters get encoded in UTF-8, and you have a 500-character limit.

On the plus side, the function supports male and female voices in English, Mandarin Chinese, and a combination of both.

Speechify - The alternative to Talkback

As you can see, using a Huawei device to read on-device text can get complicated. However, if you’re not keen on programming, an alternative text to speech app can read any text to you in real-time.

That app is Speechify.

Available for all Android devices, Speechify uses speech synthesis technology to provide a range of human-sounding voices in several timbres. Users can choose between over 14 languages and adjust the readout speed as they see fit.

And when you’re not using the app, just shutdown, and you can read the text as you normally would.

If you’d like to learn more about how Speechify can work on your Huawei device, test out a free trial today. You can also use the reader in your browser.

FAQ

How do I turn on text to speech on my Huawei?

Use the directions in this article to activate the TalkBack app.

How do you dictate on Huawei?

Enter your device’s “Control Panel” and head to “Ease of Access.” Select “Speech Recognition” and tap “Start Speech Recognition.”

Is there text to speech on Android?

Beyond TalkBack, you can access many TTS engines for an Android phone.

Tyler Weitzman

Tyler Weitzman

Tyler Weitzman is the Co-Founder, Head of Artificial Intelligence & President at Speechify, the #1 text-to-speech app in the world, totaling over 100,000 5-star reviews. Weitzman is a graduate of Stanford University, where he received a BS in mathematics and a MS in Computer Science in the Artificial Intelligence track. He has been selected by Inc. Magazine as a Top 50 Entrepreneur, and he has been featured in Business Insider, TechCrunch, LifeHacker, CBS, among other publications. Weitzman’s Masters degree research focused on artificial intelligence and text-to-speech, where his final paper was titled: “CloneBot: Personalized Dialogue-Response Predictions.”