{"id":210654,"date":"2024-03-06T16:36:14","date_gmt":"2024-03-06T16:36:14","guid":{"rendered":"https:\/\/michigandigitalnews.com\/index.php\/2024\/03\/06\/introducing-a-new-text-to-speech-engine-on-wear-os\/"},"modified":"2025-06-25T17:21:10","modified_gmt":"2025-06-25T17:21:10","slug":"introducing-a-new-text-to-speech-engine-on-wear-os","status":"publish","type":"post","link":"https:\/\/michigandigitalnews.com\/index.php\/2024\/03\/06\/introducing-a-new-text-to-speech-engine-on-wear-os\/","title":{"rendered":"Introducing a new Text-To-Speech engine on Wear OS"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div>\n<meta content=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjz59FlzcTBW59NOVhyLb_vZd-ePuN6w-TMUiMvxaZDiofpQHayKQn8sPLmP-bmuj5-6kPS7wHUOTqpzOTwoRqBRO1zdnLE3EuqPaH97Cw0ezGgLFKIbX0dzXfI4xx0bPa8XLl6FyvhYKs3XKBowHEz2ambpEB1H5UypEtPrn-dXMXkGlJEKu7NdjMV\/s1600\/Android%20-%20Policy%20Updates-%20Improving%20Wear%20App%20Quality-social.png\" name=\"twitter:image\"\/><br \/>\n<img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjz59FlzcTBW59NOVhyLb_vZd-ePuN6w-TMUiMvxaZDiofpQHayKQn8sPLmP-bmuj5-6kPS7wHUOTqpzOTwoRqBRO1zdnLE3EuqPaH97Cw0ezGgLFKIbX0dzXfI4xx0bPa8XLl6FyvhYKs3XKBowHEz2ambpEB1H5UypEtPrn-dXMXkGlJEKu7NdjMV\/s1600\/Android%20-%20Policy%20Updates-%20Improving%20Wear%20App%20Quality-social.png\" style=\"display: none;\"\/><\/p>\n<p><em>Posted by Ouiam Koubaa \u2013 Product Manager and Yingzhe Li \u2013 Software Engineer<\/em><\/p>\n<p><a href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEhVviCwvyzix33x3GBKtuFuXHOivMjeQP5FrEX8df4khO7Y6KSKwdAqBIRmac1eN5T9EIMbwATiUxqjjnOoMZow-T458ZZadL0fpwy901_pNLayQ-wLUAm8w0W2OyNZk_6KAYPwHOLqKcu9bLnpoc8K-3RIQvNeRV11iSzBSL2U20bRnb89EXghEHBs\/s1600\/Android%20-%20Policy%20Updates-%20Improving%20Wear%20App%20Quality-header.png\"><img decoding=\"async\" border=\"0\" data-original-height=\"800\" data-original-width=\"1058\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEhVviCwvyzix33x3GBKtuFuXHOivMjeQP5FrEX8df4khO7Y6KSKwdAqBIRmac1eN5T9EIMbwATiUxqjjnOoMZow-T458ZZadL0fpwy901_pNLayQ-wLUAm8w0W2OyNZk_6KAYPwHOLqKcu9bLnpoc8K-3RIQvNeRV11iSzBSL2U20bRnb89EXghEHBs\/s1600\/Android%20-%20Policy%20Updates-%20Improving%20Wear%20App%20Quality-header.png\"\/><\/a><\/p>\n<p>Today, we\u2019re 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\u2019s 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.<\/p>\n<p>Use cases for Wear OS\u2019s 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\u2019t be used for reading aloud a long article, or a long summary of a podcast.<\/p>\n<h3>How to use Wear OS\u2019s TTS<\/h3>\n<p>Text-to-speech has long been supported on Android. Wear OS\u2019s 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, <span style=\"font-family: Courier;\"><a href=\"https:\/\/developer.android.com\/reference\/android\/speech\/tts\/TextToSpeech#speak%28java.lang.CharSequence,%20int,%20android.os.Bundle,%20java.lang.String%29\" target=\"_blank\" rel=\"noopener\">TextToSpeech#speak<\/a><\/span> can be used to speak specific text. This is available on devices that run Wear OS 4 or higher.<\/p>\n<p>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 <i><u>immediately<\/u><\/i> 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.<\/p>\n<div style=\"background: rgb(248, 248, 248); border: 0px; overflow: auto; width: auto;\">\n<pre style=\"line-height: 125%; margin: 0px;\">private fun initTtsEngine() {\n    <span style=\"color: #666666;\">\/\/<\/span> Callback when TextToSpeech connection is set up\n    val callback <span style=\"color: #666666;\">=<\/span> TextToSpeech<span style=\"color: #666666;\">.<\/span>OnInitListener { status <span style=\"color: #666666;\">-&gt;<\/span>\n        <span style=\"color: green;\">if<\/span> (status <span style=\"color: #666666;\">==<\/span> TextToSpeech<span style=\"color: #666666;\">.<\/span>SUCCESS) {\n            <span style=\"color: blue;\">Log<\/span><span style=\"color: #666666;\">.<\/span>i(TAG, <span style=\"color: #ba2121;\">\"tts Client Initialized successfully\"<\/span>)\n\n\n            <span style=\"color: #666666;\">\/\/<\/span> Get default TTS locale\n            val defaultVoice <span style=\"color: #666666;\">=<\/span> tts<span style=\"color: #666666;\">.<\/span>voice\n            <span style=\"color: green;\">if<\/span> (defaultVoice <span style=\"color: #666666;\">==<\/span> null) {\n                <span style=\"color: blue;\">Log<\/span><span style=\"color: #666666;\">.<\/span>w(TAG, <span style=\"color: #ba2121;\">\"defaultVoice == null\"<\/span>)\n                <span style=\"color: green;\">return<\/span><span style=\"color: #19177c;\">@OnInitListener<\/span>\n            }\n\n\n            <span style=\"color: #666666;\">\/\/<\/span> Set TTS engine <span style=\"color: green;\">to<\/span> use default locale\n            tts<span style=\"color: #666666;\">.<\/span>language <span style=\"color: #666666;\">=<\/span> defaultVoice<span style=\"color: #666666;\">.<\/span>locale\n\n\n\n\n            try {\n                <span style=\"color: #666666;\">\/\/<\/span> Create a temporary file <span style=\"color: green;\">to<\/span> synthesize sample text\n                val tempFile <span style=\"color: #666666;\">=<\/span>\n                        File<span style=\"color: #666666;\">.<\/span>createTempFile(<span style=\"color: #ba2121;\">\"tmpsynthesize\"<\/span>, null, applicationContext<span style=\"color: #666666;\">.<\/span>cacheDir)\n\n\n                <span style=\"color: #666666;\">\/\/<\/span> Synthesize sample text <span style=\"color: green;\">to<\/span> our file\n                tts<span style=\"color: #666666;\">.<\/span>synthesizeToFile(\n                        <span style=\"color: #666666;\">\/*<\/span> text<span style=\"color: #666666;\">=<\/span> <span style=\"color: #666666;\">*\/<\/span> <span style=\"color: #ba2121;\">\"1 2 3\"<\/span>, <span style=\"color: #666666;\">\/\/<\/span> Some sample text\n                        <span style=\"color: #666666;\">\/*<\/span> params<span style=\"color: #666666;\">=<\/span> <span style=\"color: #666666;\">*\/<\/span> null, <span style=\"color: #666666;\">\/\/<\/span> No params necessary <span style=\"color: green;\">for<\/span> a sample request\n                        <span style=\"color: #666666;\">\/*<\/span> file<span style=\"color: #666666;\">=<\/span> <span style=\"color: #666666;\">*\/<\/span> tempFile,\n                        <span style=\"color: #666666;\">\/*<\/span> utteranceId<span style=\"color: #666666;\">=<\/span> <span style=\"color: #666666;\">*\/<\/span> <span style=\"color: #ba2121;\">\"sampletext\"<\/span>\n                )\n\n\n                <span style=\"color: #666666;\">\/\/<\/span> <span style=\"color: green;\">And<\/span> clean up the file\n                tempFile<span style=\"color: #666666;\">.<\/span>deleteOnExit()\n            } catch (e<span style=\"color: #666666;\">:<\/span> Exception) {\n                <span style=\"color: blue;\">Log<\/span><span style=\"color: #666666;\">.<\/span>e(TAG, <span style=\"color: #ba2121;\">\"Unhandled exception: \"<\/span>, e)\n            }\n        }\n    }\n\n\n    tts <span style=\"color: #666666;\">=<\/span> TextToSpeech(applicationContext, callback)\n}\n<\/pre>\n<\/div>\n<p>When you are done using TTS, you can release the engine by calling <span style=\"color: #0d904f; font-family: Courier;\">tts.shutdown()<\/span> in your activity\u2019s <span style=\"color: #0d904f; font-family: Courier;\">onDestroy()<\/span> method. This command should also be used when closing an app that TTS is used for.<\/p>\n<h3>Languages and Locales<\/h3>\n<p>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 <span style=\"font-family: Courier;\"><a href=\"https:\/\/developer.android.com\/reference\/android\/speech\/tts\/TextToSpeech#getAvailableLanguages%28%29\" target=\"_blank\" rel=\"noopener\">TextToSpeech#getAvailableLanguages()<\/a><\/span>.  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. <\/p>\n<p>There are limited cases where the speech output may differ from the user\u2019s 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 <span style=\"font-family: Courier;\"><a href=\"https:\/\/developer.android.com\/reference\/android\/speech\/tts\/TextToSpeech#setLanguage%28java.util.Locale%29\" target=\"_blank\" rel=\"noopener\">TextToSpeech#setLanguage(java.util.Locale)<\/a><\/span><\/p>\n<h3>Conclusion<\/h3>\n<p>Your Wear OS apps now have the power to talk, either directly <a href=\"https:\/\/developer.android.com\/training\/wearables\/apps\/audio\" target=\"_blank\" rel=\"noopener\">from the watch\u2019s speakers or through Bluetooth<\/a> connected headphones. Learn more about <a href=\"https:\/\/developer.android.com\/reference\/android\/speech\/tts\/TextToSpeech\" target=\"_blank\" rel=\"noopener\">using TTS<\/a>.<\/p>\n<p>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!<\/p>\n<div style=\"background: #f8f8f8; overflow:auto;width:auto;border:0;\">\n<pre style=\"margin: 0; line-height: 125%\">Copyright <span style=\"color: #666666\">2023<\/span> Google LLC<span style=\"color: #666666\">.<\/span>\nSPDX<span style=\"color: #666666\">-<\/span>License<span style=\"color: #666666\">-<\/span>Identifier<span style=\"color: #666666\">:<\/span> Apache<span style=\"color: #666666\">-2.0<\/span>\n<\/pre>\n<\/div>\n<\/div>\n<p>[ad_2]<br \/>\n<br \/><a href=\"http:\/\/android-developers.googleblog.com\/2024\/03\/introducing-new-text-to-speech-engine-wear-os.html\">Source link <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] Posted by Ouiam Koubaa \u2013 Product Manager and Yingzhe Li \u2013 Software Engineer Today, we\u2019re excited to announce the release of a new Text-To-Speech<\/p>\n","protected":false},"author":1,"featured_media":210655,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[146],"tags":[],"_links":{"self":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/posts\/210654"}],"collection":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/comments?post=210654"}],"version-history":[{"count":2,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/posts\/210654\/revisions"}],"predecessor-version":[{"id":339906,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/posts\/210654\/revisions\/339906"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/media\/210655"}],"wp:attachment":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/media?parent=210654"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/categories?post=210654"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/tags?post=210654"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}