Android Developers Blog
The latest Android and Google Play news for app and game developers.
πŸ”
Platform Android Studio Google Play Jetpack Kotlin Docs News

28 九月 2022

Listen to our major Text to Speech upgrades for 64 bit devices.


Link copied to clipboard

Posted by Rakesh Iyer, Staff Software Engineer and Leland Rechis, Group Product Manager

We are upgrading the Speech Services by Google speech engine in a big way, providing clearer, more natural voices. All 421 voices in 67 languages have been upgraded with a new voice model and synthesizer.

If you already use TTS and the Speech Services by Google engine, there is nothing to do – everything will happen behind the scenes as your users will have automatically downloaded the latest update. We’ve seen a significant side by side quality increase with this change, particularly in respects to clarity and naturalness.

With this upgrade we will also be changing the default voice in en-US to one that is built using fresher speaker data, which alongside our new stack, results in a drastic improvement. If your users have not selected a system voice, and you rely on system defaults, they will hear a slightly different speaker. You can hear the difference below

Speaker change and upgrade for EN-US

Sample Current Speaker

Sample Upgraded Speaker


Speaker upgrades in a few other languages

Current

Upgraded

HI-IN

HI-IN

PT-BR

PT-BR

ES-US

ES-US


This update will be rolling out to all 64 bit Android devices via the Google Play Store over the next few weeks as a part of the Speech Services by Google apk. If you are concerned your users have not updated this yet, you can check for the minimum version code ,210390644 on the package com.google.android.tts.

If you haven't used TTS in your projects yet, or haven’t given your users the ability to choose a voice within your app, it's fairly straightforward, and easy to experiment with. We’ve included some sample code to get you started. 

Here’s an example of how to set up voice synthesis, get a list of voices, and set a specific voice. We finally send a simple utterance to the synthesizer.

class MainActivity : AppCompatActivity() {
  companion object {
      private const val TAG = "TextToSpeechSample"
  }
  private lateinit var tts: TextToSpeech
  private val progressListener: UtteranceProgressListener = object : UtteranceProgressListener() {
      override fun onStart(utteranceId: String) {
        Log.d(TAG, "Started utterance $utteranceId")
      }
      override fun onDone(utteranceId: String) {
        Log.d(TAG, "Done with utterance $utteranceId")
      }
      override fun onError(utteranceId: String?) {}
  }
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
      val onInitListener = TextToSpeech.OnInitListener {
        tts.setOnUtteranceProgressListener(progressListener)
        tts.voice = tts.voices.find { it.name == "en-us-x-iog-local" } ?: tts.defaultVoice
        tts.speak("1 2 3", TextToSpeech.QUEUE_ADD, Bundle(), "utteranceId")
      }
      tts = TextToSpeech(this, onInitListener)
  }
  override fun onDestroy() {
      tts.shutdown()
      super.onDestroy()
  }
}


We are excited to see this upgraded experience in your app!