Tag Archives: Platform

Introducing a new Text-To-Speech engine on Wear OS

Posted by Ouiam Koubaa – Product Manager and Yingzhe Li – Software Engineer

Today, we’re excited to announce the release of a new Text-To-Speech (TTS) engine that is performant and reliable. Text-to-speech turns text into natural-sounding speech across more than 50 languages powered by Google’s machine learning (ML) technology. The new text-to-speech engine on Wear OS uses decreased prosody ML models to bring faster synthesis on Wear OS devices.

Use cases for Wear OS’s text-to-speech can range from accessibility services, coaching cues for exercise apps, navigation cues, and reading aloud incoming alerts through the watch speaker or Bluetooth connected headphones. The engine is meant for brief interactions, so it shouldn’t be used for reading aloud a long article, or a long summary of a podcast.

How to use Wear OS’s TTS

Text-to-speech has long been supported on Android. Wear OS’s new TTS has been tuned to be performant and reliable on low-memory devices. All the Android APIs are still the same, so developers use the same process to integrate it into a Wear OS app, for example, TextToSpeech#speak can be used to speak specific text. This is available on devices that run Wear OS 4 or higher.

When the user interacts with the Wear OS TTS for the first time following a device boot, the synthesis engine is ready in about 10 seconds. For special cases where developers want the watch to speak immediately after opening an app or launching an experience, the following code can be used to pre-warm the TTS engine before any synthesis requests come in.

private fun initTtsEngine() {
    // Callback when TextToSpeech connection is set up
    val callback = TextToSpeech.OnInitListener { status ->
        if (status == TextToSpeech.SUCCESS) {
            Log.i(TAG, "tts Client Initialized successfully")


            // Get default TTS locale
            val defaultVoice = tts.voice
            if (defaultVoice == null) {
                Log.w(TAG, "defaultVoice == null")
                return@OnInitListener
            }


            // Set TTS engine to use default locale
            tts.language = defaultVoice.locale




            try {
                // Create a temporary file to synthesize sample text
                val tempFile =
                        File.createTempFile("tmpsynthesize", null, applicationContext.cacheDir)


                // Synthesize sample text to our file
                tts.synthesizeToFile(
                        /* text= */ "1 2 3", // Some sample text
                        /* params= */ null, // No params necessary for a sample request
                        /* file= */ tempFile,
                        /* utteranceId= */ "sampletext"
                )


                // And clean up the file
                tempFile.deleteOnExit()
            } catch (e: Exception) {
                Log.e(TAG, "Unhandled exception: ", e)
            }
        }
    }


    tts = TextToSpeech(applicationContext, callback)
}

When you are done using TTS, you can release the engine by calling tts.shutdown() in your activity’s onDestroy() method. This command should also be used when closing an app that TTS is used for.

Languages and Locales

By default, Wear OS TTS includes 7 pre-loaded languages in the system image: English, Spanish, French, Italian, German, Japanese, and Mandarin Chinese. OEMs may choose to preload a different set of languages. You can check what languages are available by using TextToSpeech#getAvailableLanguages(). During watch setup, if the user selects a system language that is not a pre-loaded voice file, the watch automatically downloads the corresponding voice file the first time the user connects to Wi-Fi while charging their watch.

There are limited cases where the speech output may differ from the user’s system language. For example, in a scenario where a safety app uses TTS to call emergency responders, developers might want to synthesize speech in the language of the locale the user is in, not in the language the user has their watch set to. To synthesize text in a different language from system settings, use TextToSpeech#setLanguage(java.util.Locale)

Conclusion

Your Wear OS apps now have the power to talk, either directly from the watch’s speakers or through Bluetooth connected headphones. Learn more about using TTS.

We look forward to seeing how you use Text-to-speech engine to create more helpful and engaging experiences for your users on Wear OS!


Copyright 2023 Google LLC.
SPDX-License-Identifier: Apache-2.0

Top things to know in Android Platform and Quality at Google I/O ’23

Posted by Dan Galpin, Developer Relations Engineer

Google I/O was HUGE for developers with exciting news all across the platform and more around quality. Here are the top three announcements around Android and App Quality from Google I/O 2023:

#1 Android 14 comes with new features in privacy and security, system UI, and more

Android 14 continues our effort to improve privacy and security on the platform with the CredentialManager, which has a unified API that brings support for passkeys and federated login. Health Connect is also now a core part of the platform and available on all Android mobile devices directly in Settings, helping to control how users’ health and fitness data is shared across apps.. In addition, the beta of Privacy Sandbox on Android ensures effective privacy-preserving personalized advertising experiences.

Additionally, you’ll find Foreground Service changes, with required types, new permissions, system runtime checks, and new purpose-built APIs for user initiated data transfers and VoIP telephony that behave more consistently across our entire ecosystem. Android 14 also introduces Grammatical Inflection to help your app correctly address your users, along with updated per-app language and regional preferences. Finally, check out the Updated Predictive Back APIs that support in-app animations.

Watch the sessions that will help you get your app ready:

#2 Premium devices mean premium app experiences with camera & media and on-device ML

To help devices become creative powerhouses, Media3's Transformer supports video editing and transcoding and Android 14 introduces Ultra HDR images and more premium camera extensions. To leverage that CPU and GPU power to enable new productivity experiences, ML Kit adds new, production-ready on-device machine learning models such as document scanning and face mesh, and the Acceleration service for your custom ML models is in public beta.

Check out the sessions from I/O to learn more:

#3 More around app quality: a new quality framework, quality hub, and design hub

We've introduced a quality framework and quality hub which includes insights into how Google Play views app quality. We also created a new UI design hub that gives you a centralized destination for guidance, Figma starter kits, UI samples, and inspirational galleries to help apply our best practices for phones, large screens, wearables, and TVs.

Be sure to catch the full Android Platform and Quality playlist from Google I/O for all these videos!

Coming up next for Android Dev Summit ‘22: The Platform track, on November 14!

Posted by Daniel Galpin (@dagalpin), Developer Relations Engineer On Monday, November 14, we kick off the final of three tracks for Android Dev Summit with the Platform track! This track includes almost 20 talks focused on developer features and guidance around Android 13, and how, together with your help, we're making the platform more private and secure, more personal, and more capable than ever. We dropped information on the livestream agenda, technical talks, and speakers — so start planning your schedule!
Platform Track @ Android Dev Summit
November 14, 2022 at 9:00 AM PT
Sessions
All times in PT
9:50 AM
9:20 AM
9:35 AM
9:00 AM
Migrate Your Apps to Android 13
Designing a High Quality App with the Latest Android Features
Building for a Multilingual World
Improving Your Social Experience Quality with Android Camera
10:10 AM
HDR 10BIT: Capture, Playback, and Sharing 10BIT Video
10:15 AM Foster User Trust by Adopting Privacy-respecting Permission
Workflows
10:28 AM
10:38 AM Presenting a High-quality Media Experience for all Users
Next Up on the Privacy Sandbox
10:58 AM
11:13 AM
Building Accessibility Support for Compose
Hardware Acceleration for ML on-device
11:27 AM Android Graphics
11:44 AM
Migrate to Play Billing Library 5 - More flexible subscriptions on Google Play
Demystifying Attestation
11:59 AM
12:14 AM
Supporting BLE Audio in Your Voice Communication Applications
12:24 PM
Building Modern Android App Widgets
12:33 PM #AskAndroid
12:52 PM
Everything About Storage on Android
1:05 PM
Keep your App From Failing in a 64-bit Only World
1:13 PM
Syncing Data with Health Connect
1:20 PM Introduction to Ultrawide-band on Android
Broadcast live on d.android.com/dev-summit & YouTube

Here’s what to expect on November 14th:

Get ready for all things platform! We’re kicking the livestream off at 9:00 AM PT on November 14th on YouTube and developer.android.com, where you’ll be able to watch almost 20 sessions, with talks such as:

  • Migrate your Apps to Android 13
  • Foster User Trust by Adopting Privacy-respecting Permission Workflows
  • Building for a Multilingual World
  • Android Graphics
  • Improving Your Social Experience Quality with Android Camera

And at approximately 12:30 PM PST, we’ll be hosting a live Q&A – #AskAndroid - so you can get your burning platform questions answered live by the team who built Android. Post your questions to Twitter or comment in the YouTube livestream using #AskAndroid for a chance to have your questions answered on the livestream.

Check out our previous tracks: Modern Android Development and Form Factors.

The Platform track is our third and final track for Android Dev Summit ‘22. Missed the earlier moments? You can still catch up on all of the content: watch the keynote on YouTube and check out the keynote recap so you don’t miss a beat! Plus, get up to speed on all things Modern Android Development with a recap video, blog, and the full MAD playlist where you can find case studies and technical sessions, as well as the recap for Form Factors and the full Form Factors session playlist.

We’re so excited for all the great content yet to come from Android Dev Summit, and we’re looking forward to connecting with you!

Android Platform Codelab Kickstarts OS Development

Posted by Clay Murphy, Technical Writer

The Android Platform Codelab has been published to take developers from bare metal to a (virtual) device under test in a single page. This document will help new Android operating system engineers quickly learn the tools and processes needed to establish a build environment, sync the repository, build a virtual device image, and load that image onto an Android virtual device (AVD), allowing quick iteration of platform changes.

The codelab walks through:

  1. Environment setup
  2. Downloading of code
  3. Creating a Cuttlefish Android Virtual Device (AVD) image
  4. Building the OS
  5. Using Acloud to set up and render the Cuttlefish AVD
  6. Creating and testing changes
  7. Uploading, reviewing, and reverting those modifications

If you encounter errors during this codelab, please report them using the Site feedback link on the bottom of any page. Send questions to the android-building group.