speech: use voice3.zip for cache-busted 125k-word TTS bundle
- Commit
498d05f36da218ac34a957584bbbb60bd35b0d6f- Author
- Vayun Mathur <[email protected]>
- When
- 2026-08-02 17:30 UTC (4 months ago)
- Parents
ccb23b5
Diff
scripts/speech/fetch_piper_model.sh
diff --git a/scripts/speech/fetch_piper_model.sh b/scripts/speech/fetch_piper_model.shindex b0426e8cc5..25f584a2e8 100755--- a/scripts/speech/fetch_piper_model.sh+++ b/scripts/speech/fetch_piper_model.sh@@ -2,7 +2,7 @@ # # Stage an offline Piper (VITS) voice, in ncnn format, as a single zip for the model # mirror. The :speech app downloads it at runtime — it is NOT bundled in the APK — from-# https://data.vayunmathur.com/models/piper/voice.zip+# https://data.vayunmathur.com/models/piper/voice3.zip # and extracts it (see PiperModel). The zip must contain the voice's CONTENTS at its root: # <voice>_enc_p.ncnn.{param,bin} text encoder # <voice>_dp.ncnn.{param,bin} duration predictor@@ -130,13 +130,18 @@ echo "Word list: $WORDS ($(wc -l < "$WORDS" | tr -d ' ') lines)" --out "$TMP/en-word_id.bin" mkdir -p "${ABS_DEST}"-rm -f "${ABS_DEST}/voice.zip"+rm -f "${ABS_DEST}/voice.zip" "${ABS_DEST}/voice2.zip" "${ABS_DEST}/voice3.zip" # Zip the CONTENTS (not the wrapping folder) so entries sit at the zip root.+# Produce voice.zip for compat and voice3.zip as the cache-busted canonical name+# (voice.zip was old sherpa, voice2.zip had 33k-word dict missing HELLO). ( cd "$TMP" && rm -f cmudict.txt words.txt && zip -r -q -X "${ABS_DEST}/voice.zip" . )+cp "${ABS_DEST}/voice.zip" "${ABS_DEST}/voice2.zip"+cp "${ABS_DEST}/voice.zip" "${ABS_DEST}/voice3.zip" echo-echo "Staged ${DEST}/voice.zip"-du -sh "${ABS_DEST}/voice.zip"+echo "Staged ${DEST}/voice.zip + voice2.zip + voice3.zip (same content)"+du -sh "${ABS_DEST}/voice.zip" "${ABS_DEST}/voice3.zip" shasum -a 256 "${ABS_DEST}/voice.zip"-echo "Upload it to: https://data.vayunmathur.com/models/piper/voice.zip"-echo "The SHA-256 above must match what the download config pins."+shasum -a 256 "${ABS_DEST}/voice3.zip"+echo "Upload voice3.zip to: https://data.vayunmathur.com/models/piper/voice3.zip"+echo "And voice.zip for compat. SHA-256 must match PiperModel.FILES pin."
speech/src/main/java/com/vayunmathur/speech/util/PiperModel.kt
diff --git a/speech/src/main/java/com/vayunmathur/speech/util/PiperModel.kt b/speech/src/main/java/com/vayunmathur/speech/util/PiperModel.ktindex 357c3532eb..223e316bf2 100644--- a/speech/src/main/java/com/vayunmathur/speech/util/PiperModel.kt+++ b/speech/src/main/java/com/vayunmathur/speech/util/PiperModel.kt@@ -28,11 +28,12 @@ import java.util.zip.ZipInputStream * * Mirror layout (zip the voice dir's *contents* at the zip root; * `scripts/speech/fetch_piper_model.sh` stages it):- * https://data.vayunmathur.com/models/piper/voice2.zip+ * https://data.vayunmathur.com/models/piper/voice3.zip *- * voice2.zip is the ncnn VITS bundle (amy medium, 22050 Hz). voice.zip was the old- * sherpa-onnx layout and was removed to bust Cloudflare cache; voice2 is used to- * avoid the 404 / stale edge-cache after deletion.+ * voice3.zip is the ncnn VITS bundle (amy medium, 22050 Hz, 125k-word dict, 2.2 MB+ * en-word_id.bin). voice.zip was the old sherpa-onnx layout, voice2.zip was the first+ * ncnn bundle but with the broken 33k-word CMUdict parse (593 KB dict, missing HELLO)+ * due to shell sed illegal-byte-sequence on macOS; voice3 busts Cloudflare cache again. */ object PiperModel { const val DIR = "piper"@@ -48,12 +49,12 @@ object PiperModel { private const val BASE = "https://data.vayunmathur.com/models/piper/" /**- * The downloadable archive name. Uses voice2.zip to bust Cloudflare cache — voice.zip- * served stale sherpa-onnx data, deleting it caused 404s on edge, so voice2.zip is the- * canonical ncnn VITS voice now. The on-disk archive path is still piper/voice.zip for- * backward compat, but the URL points to voice2.zip on the mirror.+ * The downloadable archive name. Uses voice3.zip to bust Cloudflare cache — voice.zip+ * served stale sherpa-onnx data, voice2.zip served the first ncnn bundle with the broken+ * 33k-word dict (HELLO missing → letter-by-letter spelling). voice3 is the 125k-word full+ * dict. The on-disk archive path is still piper/voice.zip for backward compat. */- const val REMOTE_ARCHIVE = "voice2.zip"+ const val REMOTE_ARCHIVE = "voice3.zip" /** On-disk archive path (under getExternalFilesDir). Kept as voice.zip for compat. */ private const val ARCHIVE = "$DIR/voice.zip"@@ -145,16 +146,6 @@ object PiperModel { dir.deleteRecursively() } }- // Old archive from sherpa path (64 MB) or earlier broken ncnn (33k dict) should be- // dropped so downloadModels re-fetches voice2.zip with correct SHA.- val root = rootDir(context)- if (root != null) {- val oldArchive = File(root, ARCHIVE)- if (oldArchive.exists() && oldArchive.length() < 5_000_000L) {- Log.d(TAG, "deleting suspiciously small archive $oldArchive")- oldArchive.delete()- }- } return isExtracted(context) }