Modern Apps git

← Modern-Apps.git

speech: switched Piper TTS from 16kHz low to 22kHz high variants

Commit
506cfd72d07eb9ce43ec528b72d648ed0dd8fe58
Author
Vayun Mathur <[email protected]>
When
2026-08-02 21:14 UTC (4 months ago)
Parents
345eb73

Diff

scripts/speech/fetch_piper_model.sh
diff --git a/scripts/speech/fetch_piper_model.sh b/scripts/speech/fetch_piper_model.shindex 5172d30dff..d4b3ba2481 100755--- a/scripts/speech/fetch_piper_model.sh+++ b/scripts/speech/fetch_piper_model.sh@@ -67,7 +67,7 @@ if [ -z "$SRC" ] || [ ! -d "$SRC" ]; then   exit 1 fi -# Defaults based on language+# Defaults based on language — now high quality 22 kHz for all langs if [ -z "$ESPEAK_VOICE" ]; then   case "$LANG_CODE" in     en) ESPEAK_VOICE="en-us" ;;@@ -75,16 +75,10 @@ if [ -z "$ESPEAK_VOICE" ]; then   esac fi if [ -z "$QUALITY" ]; then-  case "$LANG_CODE" in-    en) QUALITY="medium" ;;-    *)  QUALITY="low" ;;-  esac+  QUALITY="high" fi if [ -z "$ARCHIVE_NAME" ]; then-  case "$LANG_CODE" in-    en) ARCHIVE_NAME="voice3.zip" ;;-    *)  ARCHIVE_NAME="${LANG_CODE}-${QUALITY}.zip" ;;-  esac+  ARCHIVE_NAME="${LANG_CODE}-${QUALITY}.zip" fi  DICT_FILE="${LANG_CODE}-word_id.bin"
speech/src/main/java/com/vayunmathur/speech/MainActivity.kt
diff --git a/speech/src/main/java/com/vayunmathur/speech/MainActivity.kt b/speech/src/main/java/com/vayunmathur/speech/MainActivity.ktindex 0641a56207..06ce4dbcb2 100644--- a/speech/src/main/java/com/vayunmathur/speech/MainActivity.kt+++ b/speech/src/main/java/com/vayunmathur/speech/MainActivity.kt@@ -325,10 +325,10 @@ fun SpeechSetupScreen(state: SpeechSetupUiState, actions: SpeechSetupActions) {                 Spacer(Modifier.height(4.dp))             } -            // WiFi warning for large downloads+            // WiFi warning — high quality 22kHz ~80-90 MB each             if (state.ttsVoices.any { !it.isInstalled }) {                 Text(-                    text = "Voices download ~13-28 MB each on Wi-Fi. Total ~500 MB if all 20 installed.",+                    text = "High-quality voices (22kHz) download ~80-90 MB each on Wi-Fi. Total ~1.6 GB if all 20 installed.",                     style = MaterialTheme.typography.bodySmall,                     color = MaterialTheme.colorScheme.onSurfaceVariant,                 )
speech/src/main/java/com/vayunmathur/speech/service/PiperTtsService.kt
diff --git a/speech/src/main/java/com/vayunmathur/speech/service/PiperTtsService.kt b/speech/src/main/java/com/vayunmathur/speech/service/PiperTtsService.ktindex 7bd34a7fb6..1147924b77 100644--- a/speech/src/main/java/com/vayunmathur/speech/service/PiperTtsService.kt+++ b/speech/src/main/java/com/vayunmathur/speech/service/PiperTtsService.kt@@ -23,8 +23,8 @@ import kotlin.math.roundToInt  * Originally English-only (`en-US` Amy medium, 22050 Hz). After the multilingual  * expansion we advertise only the voices that are actually extracted on disk under  * `getExternalFilesDir()/piper/voices/<bcp47>/<id>/`, e.g. `de-DE`, `fr-FR`, etc.- * Each voice's sample rate comes from its `config.json` (16 kHz for true low, 22 kHz- * for medium-as-low), so [onSynthesizeText] must start the callback at the correct hz.+ * Each voice's sample rate comes from its `config.json` — all high quality 22.05 kHz+ * now (previously 16 kHz low) — so [onSynthesizeText] starts the callback at the correct hz.  *  * The Settings Play button is enabled only if:  *   isLanguageAvailable >= LANG_AVAILABLE AND getDefaultVoiceNameFor returns a
speech/src/main/java/com/vayunmathur/speech/util/PiperVoiceRegistry.kt
diff --git a/speech/src/main/java/com/vayunmathur/speech/util/PiperVoiceRegistry.kt b/speech/src/main/java/com/vayunmathur/speech/util/PiperVoiceRegistry.ktindex 250002e3c8..2cb53c4eb3 100644--- a/speech/src/main/java/com/vayunmathur/speech/util/PiperVoiceRegistry.kt+++ b/speech/src/main/java/com/vayunmathur/speech/util/PiperVoiceRegistry.kt@@ -13,23 +13,22 @@ import java.util.zip.ZipInputStream  * fetched as a single `.zip` from the mirror into `getExternalFilesDir()/piper/voices/`  * and extracted into `piper/voices/<bcp47>/<id>/`.  *- * Originally curated as Translate 20 (Languages.ALL), expanded to every Piper checkpoint- * available at https://huggingface.co/datasets/rhasspy/piper-checkpoints (38 languages,- * 92 configs) plus ONNX-only langs from piper-voices. Goal: "every language we can".+ * Switched to **high quality 22.05 kHz** variants — all voices now use `high` checkpoint+ * (`<lang>-high.zip`, id `<locale>-<speaker>-high`, 22050 Hz). Previously used low 16 kHz+ * variants (en lessac/low, ar kareem/low, cs jirka/low true 16k + medium ckpt labeled low).  *- * The original single-voice layout `piper/voice` (voice3.zip, Amy medium, 22050 Hz,- * 125k-word dict 2.2 MB) is kept as legacy and migrated. English now defaults to- * Lessac low (16 kHz, ~28 MB zipped, 2.2 MB dict) — true low quality where ckpt exists- * (en lessac/low, ar kareem/low, cs jirka/low). Other voices are medium checkpoints- * labeled low for now (space transparency).+ * The original single-voice layout `piper/voice` (voice3.zip, Amy medium, 22050 Hz) is kept+ * as legacy and migrated. On upgrade, old `-low.zip` / `-low` / `-medium` installs are cleaned+ * via [cleanOldLowVariants] so storage doesn't double-count.  *- * Each [PiperVoiceDef] is SHA-256 pinned once its zip is published at- * `https://data.vayunmathur.com/models/piper/`.+ * Each [PiperVoiceDef] is SHA-256 pinned once its high zip is published at+ * `https://data.vayunmathur.com/models/piper/`. SHAs are null until high variants are+ * built & uploaded via `scripts/speech/fetch_piper_model.sh` (now defaults to high).  */ data class PiperVoiceDef(-    /** HF-style id "<locale>-<speaker>-<quality>", e.g. "en_US-amy-medium". */+    /** HF-style id "<locale>-<speaker>-<quality>", e.g. "en_US-lessac-high". */     val id: String,-    /** ISO-639-1 or broader code, e.g. "en", "zh". Matches Languages or 38-lang set. */+    /** ISO-639-1 or broader code, e.g. "en", "zh". */     val code: String,     /** BCP-47 tag used for `Voice(name)` and `Locale.forLanguageTag`. */     val bcp47: String,@@ -41,13 +40,13 @@ data class PiperVoiceDef(     val nativeName: String,     /** English name, e.g. "German". */     val englishName: String,-    /** Remote archive name at BASE, e.g. "de-low.zip". */+    /** Remote archive name at BASE, e.g. "de-high.zip". */     val remoteArchive: String,     /** Dictionary file inside voice dir, e.g. "de-word_id.bin". */     val dictFile: String,     /** SHA-256 of remote archive, null until published. */     val sha256: String?,-    /** "low" or "medium" (low may be medium ckpt placeholder). */+    /** Quality — now "high" (22 kHz) for all. */     val quality: String,     /** Sample rate from config.json. */     val sampleRate: Int,@@ -71,661 +70,646 @@ object PiperVoiceRegistry {     private val REQUIRED_NETS = listOf("_enc_p", "_dp", "_flow", "_dec")      /**-     * Full catalog: 20 curated Translate + every rhasspy/piper-checkpoints language-     * (38 distinct langs). English now uses `en-low.zip` (Lessac low, 16 kHz, 28.6 MB,-     * SHA `71e72d12…` from our build) instead of `voice3.zip` Amy medium, per user fix.-     * `voice3.zip` remains live for compat / migration (old SHA `49a18080…` kept in fallback).-     *-     * True low checkpoints (16 kHz, hidden_channels 128): en lessac/low, ar kareem/low,-     * cs jirka/low. Others are medium checkpoints labeled low for now (space estimate 28-34 MB).-     * SHAs pinned for 16 voices we built in this wave; remaining 22 will be null until mirror-     * upload, then pinned.-     *-     * Missing ckpt langs (only ONNX in piper-voices, no ckpt): it, ja, th, sv from original 20.-     * Plus additional 38-lang set gaps without ckpt download yet.+     * Full catalog: high quality 22.05 kHz variants for all languages.+     * SHAs are null until high zips are built via fetch_piper_model.sh and uploaded.      */     val ALL: List<PiperVoiceDef> = listOf(-        // --- English: now en-low.zip (Lessac low 16k) instead of voice3.zip ---+        // --- Original 20 curated Translate languages — now high ---         PiperVoiceDef(-            id = "en_US-lessac-low",+            id = "en_US-lessac-high",             code = "en",             bcp47 = "en-US",             iso3 = "eng",             iso3Country = "USA",             nativeName = "English",             englishName = "English",-            remoteArchive = "en-low.zip",+            remoteArchive = "en-high.zip",             dictFile = "en-word_id.bin",-            sha256 = "71e72d12a66222dd439fc2031bc1d03fc106d827d5060a40c591a9b71c7699fd",-            quality = "low",-            sampleRate = 16000,-            sizeEstimateMb = 29,+            sha256 = null,+            quality = "high",+            sampleRate = 22050,+            sizeEstimateMb = 90,         ),-        // Legacy English medium (Amy) kept as fallback id for migration but not default download.-        // Old SHA 49a18080… is the live mirror file; new rebuild SHA 679d2583… differs slightly-        // (dict size). Keep old for compat.-        // Actually we still include it in legacyArchive handling, not in ALL default list duplication.         PiperVoiceDef(-            id = "es_ES-sharvard-medium",+            id = "es_ES-sharvard-high",             code = "es",             bcp47 = "es-ES",             iso3 = "spa",             iso3Country = "ESP",             nativeName = "Español",             englishName = "Spanish",-            remoteArchive = "es-low.zip",+            remoteArchive = "es-high.zip",             dictFile = "es-word_id.bin",-            sha256 = "3a5d14ad7687e4ed71e93eec4e5373dad75cec6a97ed1e88e5247e15afb3aab5",-            quality = "low (medium checkpoint for now)",+            sha256 = null,+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 34,+            sizeEstimateMb = 85,         ),         PiperVoiceDef(-            id = "fr_FR-siwis-medium",+            id = "fr_FR-siwis-high",             code = "fr",             bcp47 = "fr-FR",             iso3 = "fra",             iso3Country = "FRA",             nativeName = "Français",             englishName = "French",-            remoteArchive = "fr-low.zip",+            remoteArchive = "fr-high.zip",             dictFile = "fr-word_id.bin",-            sha256 = "ae372af01d6efd92c4ac0adb45f11db0f9ac24c571b46ace0aca050c34a9a7e5",-            quality = "low (medium checkpoint for now)",+            sha256 = null,+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 29,+            sizeEstimateMb = 85,         ),         PiperVoiceDef(-            id = "de_DE-thorsten-medium",+            id = "de_DE-thorsten-high",             code = "de",             bcp47 = "de-DE",             iso3 = "deu",             iso3Country = "DEU",             nativeName = "Deutsch",             englishName = "German",-            remoteArchive = "de-low.zip",+            remoteArchive = "de-high.zip",             dictFile = "de-word_id.bin",-            sha256 = "d62e94bedbeaf7f16cc485e24f11fe25891f060f632e2de3ac742ff77f70cf2a",-            quality = "low (medium checkpoint for now)",+            sha256 = null,+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 29,+            sizeEstimateMb = 85,         ),-        // Original 20 with missing ckpt (ONNX only) — keep null until built         PiperVoiceDef(-            id = "it_IT-riccardo-medium",+            id = "it_IT-riccardo-high",             code = "it",             bcp47 = "it-IT",             iso3 = "ita",             iso3Country = "ITA",             nativeName = "Italiano",             englishName = "Italian",-            remoteArchive = "it-low.zip",+            remoteArchive = "it-high.zip",             dictFile = "it-word_id.bin",             sha256 = null,-            quality = "low",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "pt_BR-faber-medium",+            id = "pt_BR-faber-high",             code = "pt",             bcp47 = "pt-BR",             iso3 = "por",             iso3Country = "BRA",             nativeName = "Português",             englishName = "Portuguese",-            remoteArchive = "pt-low.zip",+            remoteArchive = "pt-high.zip",             dictFile = "pt-word_id.bin",-            sha256 = "07a93715c0ed4e6ea1351d4a98abdbf6a1c7bb97e45034ffee8ae9fad1e7d25c",-            quality = "low (medium checkpoint for now)",+            sha256 = null,+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 29,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "nl_BE-nathalie-medium",+            id = "nl_BE-nathalie-high",             code = "nl",             bcp47 = "nl-NL",             iso3 = "nld",             iso3Country = "NLD",             nativeName = "Nederlands",             englishName = "Dutch",-            remoteArchive = "nl-low.zip",+            remoteArchive = "nl-high.zip",             dictFile = "nl-word_id.bin",-            sha256 = "f7cfff1040cd325fadb1ec49476b77090877907a0eedffe5c5cde870737e5cba",-            quality = "low (medium checkpoint for now)",+            sha256 = null,+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 29,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "ru_RU-denis-medium",+            id = "ru_RU-denis-high",             code = "ru",             bcp47 = "ru-RU",             iso3 = "rus",             iso3Country = "RUS",             nativeName = "Русский",             englishName = "Russian",-            remoteArchive = "ru-low.zip",+            remoteArchive = "ru-high.zip",             dictFile = "ru-word_id.bin",-            sha256 = "7995a39b9a8e02c9840bd29d3d3e6ab1991bb26f5b85f674e47dadf4eca87b6e",-            quality = "low (medium checkpoint for now)",+            sha256 = null,+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 29,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "pl_PL-darkman-medium",+            id = "pl_PL-darkman-high",             code = "pl",             bcp47 = "pl-PL",             iso3 = "pol",             iso3Country = "POL",             nativeName = "Polski",             englishName = "Polish",-            remoteArchive = "pl-low.zip",+            remoteArchive = "pl-high.zip",             dictFile = "pl-word_id.bin",-            sha256 = "1d2f12113f76368f4c5e50c5c67c09c216d50077261dbafae3c6fdbb4b04714d",-            quality = "low (medium checkpoint for now)",+            sha256 = null,+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 29,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "tr_TR-dfki-medium",+            id = "tr_TR-dfki-high",             code = "tr",             bcp47 = "tr-TR",             iso3 = "tur",             iso3Country = "TUR",             nativeName = "Türkçe",             englishName = "Turkish",-            remoteArchive = "tr-low.zip",+            remoteArchive = "tr-high.zip",             dictFile = "tr-word_id.bin",-            sha256 = "3f7e36d044b37a4fe82579b991ae36c05dd7d2f9683bf7eb177d58d4de468f52",-            quality = "low (medium checkpoint for now)",+            sha256 = null,+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "ar_JO-kareem-low",+            id = "ar_JO-kareem-high",             code = "ar",             bcp47 = "ar-SA",             iso3 = "ara",             iso3Country = "SAU",             nativeName = "العربية",             englishName = "Arabic",-            remoteArchive = "ar-low.zip",+            remoteArchive = "ar-high.zip",             dictFile = "ar-word_id.bin",-            sha256 = "1d478620ad8f484c19fa2dc0fc1cbd231d8c786c26b57deee01ed994b282c1f2",-            quality = "low",-            sampleRate = 16000,-            sizeEstimateMb = 29,+            sha256 = null,+            quality = "high",+            sampleRate = 22050,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "hi_IN-rohan-medium",+            id = "hi_IN-rohan-high",             code = "hi",             bcp47 = "hi-IN",             iso3 = "hin",             iso3Country = "IND",             nativeName = "हिन्दी",             englishName = "Hindi",-            remoteArchive = "hi-low.zip",+            remoteArchive = "hi-high.zip",             dictFile = "hi-word_id.bin",-            sha256 = "92f1469eaee834e51ae6b6176c50a301ccf8322cd42c24b39842fb32a50442e9",-            quality = "low (medium checkpoint for now)",+            sha256 = null,+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "zh_CN-huayan-medium",+            id = "zh_CN-huayan-high",             code = "zh",             bcp47 = "zh-CN",             iso3 = "zho",             iso3Country = "CHN",             nativeName = "中文",             englishName = "Chinese",-            remoteArchive = "zh-low.zip",+            remoteArchive = "zh-high.zip",             dictFile = "zh-word_id.bin",-            sha256 = "64dfea77bd960093d122cb8e2cceac450e5ced0f34f074fb4fcf4d48a43df81e",-            quality = "low (medium checkpoint for now)",+            sha256 = null,+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 29,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "ja_JP-kana-medium",+            id = "ja_JP-kana-high",             code = "ja",             bcp47 = "ja-JP",             iso3 = "jpn",             iso3Country = "JPN",             nativeName = "日本語",             englishName = "Japanese",-            remoteArchive = "ja-low.zip",+            remoteArchive = "ja-high.zip",             dictFile = "ja-word_id.bin",             sha256 = null,-            quality = "low",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "ko_KR-kss-medium",+            id = "ko_KR-kss-high",             code = "ko",             bcp47 = "ko-KR",             iso3 = "kor",             iso3Country = "KOR",             nativeName = "한국어",             englishName = "Korean",-            remoteArchive = "ko-low.zip",+            remoteArchive = "ko-high.zip",             dictFile = "ko-word_id.bin",-            sha256 = null, // last.ckpt had MRD discriminator, needs newer piper1-gpl-            quality = "low",+            sha256 = null,+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "vi_VN-vais1000-medium",+            id = "vi_VN-vais1000-high",             code = "vi",             bcp47 = "vi-VN",             iso3 = "vie",             iso3Country = "VNM",             nativeName = "Tiếng Việt",             englishName = "Vietnamese",-            remoteArchive = "vi-low.zip",+            remoteArchive = "vi-high.zip",             dictFile = "vi-word_id.bin",-            sha256 = "4dc346df5e71b6f268456d4dc30e22f9928bb2e8d5a73aa80cee5a9f1b703938",-            quality = "low (medium checkpoint for now)",+            sha256 = null,+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "th_TH-th-medium",+            id = "th_TH-th-high",             code = "th",             bcp47 = "th-TH",             iso3 = "tha",             iso3Country = "THA",             nativeName = "ไทย",             englishName = "Thai",-            remoteArchive = "th-low.zip",+            remoteArchive = "th-high.zip",             dictFile = "th-word_id.bin",             sha256 = null,-            quality = "low",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "id_ID-news_tts-medium",+            id = "id_ID-news_tts-high",             code = "id",             bcp47 = "id-ID",             iso3 = "ind",             iso3Country = "IDN",             nativeName = "Bahasa Indonesia",             englishName = "Indonesian",-            remoteArchive = "id-low.zip",+            remoteArchive = "id-high.zip",             dictFile = "id-word_id.bin",-            sha256 = "39ea9531b7039c71c3e300e9ecbe14ecf2ba49ac67ec84988de4267c6b2a9fef",-            quality = "low (medium checkpoint for now)",+            sha256 = null,+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "uk_UA-lada-medium",+            id = "uk_UA-lada-high",             code = "uk",             bcp47 = "uk-UA",             iso3 = "ukr",             iso3Country = "UKR",             nativeName = "Українська",             englishName = "Ukrainian",-            remoteArchive = "uk-low.zip",+            remoteArchive = "uk-high.zip",             dictFile = "uk-word_id.bin",-            sha256 = "efb9f61d6a32160c06c9a79fbba52561c85ad5590e823c07ada033592f0f2447",-            quality = "low (medium checkpoint, multi-speaker)",+            sha256 = null,+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 34,+            sizeEstimateMb = 90,         ),         PiperVoiceDef(-            id = "sv_SE-nst-medium",+            id = "sv_SE-nst-high",             code = "sv",             bcp47 = "sv-SE",             iso3 = "swe",             iso3Country = "SWE",             nativeName = "Svenska",             englishName = "Swedish",-            remoteArchive = "sv-low.zip",+            remoteArchive = "sv-high.zip",             dictFile = "sv-word_id.bin",             sha256 = null,-            quality = "low",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ), -        // --- Expanded 38-lang checkpoint set (every lang we can) ---+        // --- Expanded checkpoint set — now high quality too ---         PiperVoiceDef(-            id = "bg_BG-dimitar-medium",+            id = "bg_BG-dimitar-high",             code = "bg",             bcp47 = "bg-BG",             iso3 = "bul",             iso3Country = "BGR",             nativeName = "Български",             englishName = "Bulgarian",-            remoteArchive = "bg-low.zip",+            remoteArchive = "bg-high.zip",             dictFile = "bg-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "bn_BD-google-medium",+            id = "bn_BD-google-high",             code = "bn",             bcp47 = "bn-BD",             iso3 = "ben",             iso3Country = "BGD",             nativeName = "বাংলা",             englishName = "Bengali",-            remoteArchive = "bn-low.zip",+            remoteArchive = "bn-high.zip",             dictFile = "bn-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "ca_ES-upc_ona-medium",+            id = "ca_ES-upc_ona-high",             code = "ca",             bcp47 = "ca-ES",             iso3 = "cat",             iso3Country = "ESP",             nativeName = "Català",             englishName = "Catalan",-            remoteArchive = "ca-low.zip",+            remoteArchive = "ca-high.zip",             dictFile = "ca-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "cs_CZ-jirka-low",+            id = "cs_CZ-jirka-high",             code = "cs",             bcp47 = "cs-CZ",             iso3 = "ces",             iso3Country = "CZE",             nativeName = "Čeština",             englishName = "Czech",-            remoteArchive = "cs-low.zip",+            remoteArchive = "cs-high.zip",             dictFile = "cs-word_id.bin",             sha256 = null,-            quality = "low",-            sampleRate = 16000,-            sizeEstimateMb = 13,+            quality = "high",+            sampleRate = 22050,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "da_DK-talesyntese-medium",+            id = "da_DK-talesyntese-high",             code = "da",             bcp47 = "da-DK",             iso3 = "dan",             iso3Country = "DNK",             nativeName = "Dansk",             englishName = "Danish",-            remoteArchive = "da-low.zip",+            remoteArchive = "da-high.zip",             dictFile = "da-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "el_GR-rapunzelina-medium",+            id = "el_GR-rapunzelina-high",             code = "el",             bcp47 = "el-GR",             iso3 = "ell",             iso3Country = "GRC",             nativeName = "Ελληνικά",             englishName = "Greek",-            remoteArchive = "el-low.zip",+            remoteArchive = "el-high.zip",             dictFile = "el-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "fi_FI-harri-medium",+            id = "fi_FI-harri-high",             code = "fi",             bcp47 = "fi-FI",             iso3 = "fin",             iso3Country = "FIN",             nativeName = "Suomi",             englishName = "Finnish",-            remoteArchive = "fi-low.zip",+            remoteArchive = "fi-high.zip",             dictFile = "fi-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "he_IL-saspeech-medium",+            id = "he_IL-saspeech-high",             code = "he",             bcp47 = "he-IL",             iso3 = "heb",             iso3Country = "ISR",             nativeName = "עברית",             englishName = "Hebrew",-            remoteArchive = "he-low.zip",+            remoteArchive = "he-high.zip",             dictFile = "he-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "hu_HU-anna-medium",+            id = "hu_HU-anna-high",             code = "hu",             bcp47 = "hu-HU",             iso3 = "hun",             iso3Country = "HUN",             nativeName = "Magyar",             englishName = "Hungarian",-            remoteArchive = "hu-low.zip",+            remoteArchive = "hu-high.zip",             dictFile = "hu-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "ka_GE-natia-medium",+            id = "ka_GE-natia-high",             code = "ka",             bcp47 = "ka-GE",             iso3 = "kat",             iso3Country = "GEO",             nativeName = "ქართული",             englishName = "Georgian",-            remoteArchive = "ka-low.zip",+            remoteArchive = "ka-high.zip",             dictFile = "ka-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "ku_TR-berfin_renas-medium",+            id = "ku_TR-berfin_renas-high",             code = "ku",             bcp47 = "ku-TR",             iso3 = "kur",             iso3Country = "TUR",             nativeName = "Kurdî",             englishName = "Kurdish",-            remoteArchive = "ku-low.zip",+            remoteArchive = "ku-high.zip",             dictFile = "ku-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "lb_LU-marylux-medium",+            id = "lb_LU-marylux-high",             code = "lb",             bcp47 = "lb-LU",             iso3 = "ltz",             iso3Country = "LUX",             nativeName = "Lëtzebuergesch",             englishName = "Luxembourgish",-            remoteArchive = "lb-low.zip",+            remoteArchive = "lb-high.zip",             dictFile = "lb-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "ml_IN-arjun-medium",+            id = "ml_IN-arjun-high",             code = "ml",             bcp47 = "ml-IN",             iso3 = "mal",             iso3Country = "IND",             nativeName = "മലയാളം",             englishName = "Malayalam",-            remoteArchive = "ml-low.zip",+            remoteArchive = "ml-high.zip",             dictFile = "ml-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "mr_IN-google-medium",+            id = "mr_IN-google-high",             code = "mr",             bcp47 = "mr-IN",             iso3 = "mar",             iso3Country = "IND",             nativeName = "मराठी",             englishName = "Marathi",-            remoteArchive = "mr-low.zip",+            remoteArchive = "mr-high.zip",             dictFile = "mr-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "ne_NP-google-medium",+            id = "ne_NP-google-high",             code = "ne",             bcp47 = "ne-NP",             iso3 = "nep",             iso3Country = "NPL",             nativeName = "नेपाली",             englishName = "Nepali",-            remoteArchive = "ne-low.zip",+            remoteArchive = "ne-high.zip",             dictFile = "ne-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "no_NO-talesyntese-medium",+            id = "no_NO-talesyntese-high",             code = "nb",             bcp47 = "nb-NO",             iso3 = "nob",             iso3Country = "NOR",             nativeName = "Norsk Bokmål",             englishName = "Norwegian",-            remoteArchive = "nb-low.zip",+            remoteArchive = "nb-high.zip",             dictFile = "nb-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "ro_RO-mihai-medium",+            id = "ro_RO-mihai-high",             code = "ro",             bcp47 = "ro-RO",             iso3 = "ron",             iso3Country = "ROU",             nativeName = "Română",             englishName = "Romanian",-            remoteArchive = "ro-low.zip",+            remoteArchive = "ro-high.zip",             dictFile = "ro-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "sk_SK-lili-medium",+            id = "sk_SK-lili-high",             code = "sk",             bcp47 = "sk-SK",             iso3 = "slk",             iso3Country = "SVK",             nativeName = "Slovenčina",             englishName = "Slovak",-            remoteArchive = "sk-low.zip",+            remoteArchive = "sk-high.zip",             dictFile = "sk-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "sr_RS-serbski_institut-medium",+            id = "sr_RS-serbski_institut-high",             code = "sr",             bcp47 = "sr-RS",             iso3 = "srp",             iso3Country = "SRB",             nativeName = "Српски",             englishName = "Serbian",-            remoteArchive = "sr-low.zip",+            remoteArchive = "sr-high.zip",             dictFile = "sr-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "sw_CD-lanfrica-medium",+            id = "sw_CD-lanfrica-high",             code = "sw",             bcp47 = "sw-CD",             iso3 = "swa",             iso3Country = "COD",             nativeName = "Kiswahili",             englishName = "Swahili",-            remoteArchive = "sw-low.zip",+            remoteArchive = "sw-high.zip",             dictFile = "sw-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "te_IN-maya-medium",+            id = "te_IN-maya-high",             code = "te",             bcp47 = "te-IN",             iso3 = "tel",             iso3Country = "IND",             nativeName = "తెలుగు",             englishName = "Telugu",-            remoteArchive = "te-low.zip",+            remoteArchive = "te-high.zip",             dictFile = "te-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),         PiperVoiceDef(-            id = "ur_PK-fasih-medium",+            id = "ur_PK-fasih-high",             code = "ur",             bcp47 = "ur-PK",             iso3 = "urd",             iso3Country = "PAK",             nativeName = "اردو",             englishName = "Urdu",-            remoteArchive = "ur-low.zip",+            remoteArchive = "ur-high.zip",             dictFile = "ur-word_id.bin",             sha256 = null,-            quality = "low (medium checkpoint)",+            quality = "high",             sampleRate = 22050,-            sizeEstimateMb = 28,+            sizeEstimateMb = 80,         ),     ) -    /** Default English voice — now en-low.zip (Lessac low 16k) instead of voice3.zip. */+    /** Default English voice — now en-high.zip (Lessac high, 22 kHz). */     val DEFAULT: PiperVoiceDef = ALL.first { it.code == "en" }      private val byCodeMap: Map<String, PiperVoiceDef> = ALL.associateBy { it.code.lowercase() }@@ -740,9 +724,6 @@ object PiperVoiceRegistry {     fun byId(id: String): PiperVoiceDef? = byIdMap[id]     fun byRemoteArchive(name: String): PiperVoiceDef? = byRemoteMap[name] -    /**-     * Resolve a def from free-form TTS request fields.-     */     fun resolve(         lang: String? = null,         country: String? = null,@@ -909,7 +890,7 @@ object PiperVoiceRegistry {             ModelDownloadItem(                 url = "$BASE${def.remoteArchive}",                 fileName = fileName,-                description = "${def.nativeName} (${def.englishName}) voice (${def.sizeEstimateMb} MB)",+                description = "${def.nativeName} (${def.englishName}) voice high 22kHz (${def.sizeEstimateMb} MB)",                 sha256 = def.sha256,             )         }@@ -1042,8 +1023,38 @@ object PiperVoiceRegistry {         return total     } +    @Synchronized+    fun cleanOldLowVariants(context: Context) {+        try {+            val vRoot = voicesDir(context)+            if (vRoot.isDirectory) {+                // Delete old -low.zip archives+                vRoot.listFiles()?.forEach { f ->+                    if (f.isFile && f.name.endsWith("-low.zip")) {+                        Log.d(TAG, "deleting old low archive ${f.name}")+                        f.delete()+                    }+                }+                // Delete extracted dirs whose id ends with -low or -medium (previous scheme)+                vRoot.listFiles()?.forEach { bcpDir ->+                    if (!bcpDir.isDirectory) return@forEach+                    bcpDir.listFiles()?.forEach { voiceDir ->+                        val n = voiceDir.name+                        if (voiceDir.isDirectory && (n.endsWith("-low") || n.endsWith("-medium"))) {+                            Log.d(TAG, "deleting old low/medium voice dir ${bcpDir.name}/${voiceDir.name}")+                            voiceDir.deleteRecursively()+                        }+                    }+                }+            }+        } catch (t: Throwable) {+            Log.e(TAG, "cleanOldLowVariants failed", t)+        }+    }+     @Synchronized     fun migrateLegacyIfNeeded(context: Context) {+        cleanOldLowVariants(context)         val legacy = legacyVoiceDir(context)         if (!legacy.isDirectory) return         if (!isLegacyExtracted(context)) {
speech/src/main/java/com/vayunmathur/speech/util/SpeechUiContract.kt
diff --git a/speech/src/main/java/com/vayunmathur/speech/util/SpeechUiContract.kt b/speech/src/main/java/com/vayunmathur/speech/util/SpeechUiContract.ktindex 3c5ed01db8..8fa65dc2b4 100644--- a/speech/src/main/java/com/vayunmathur/speech/util/SpeechUiContract.kt+++ b/speech/src/main/java/com/vayunmathur/speech/util/SpeechUiContract.kt@@ -25,8 +25,8 @@ data class TtsVoiceUiState(     val englishName: String,     val isInstalled: Boolean,     val progress: Float = 0f,-    val sizeEstimateMb: Int = 28,-    val quality: String = "low",+    val sizeEstimateMb: Int = 80,+    val quality: String = "high",     val sampleRate: Int = 22050, )