Repository navigation
Move Pocket TTS to Kyutai 4.x models, add Dutch, harden the server, polish the demo - #49
Merged
ronibhakta1 merged 3 commits intoOct 28, 2026
Conversation
Pocket TTS - Bump pocket-tts to 4.0.1 (uv.lock refreshed). - English now uses the 18.2M flagship (english_18m_2026-10): ~111 MB instead of 219 MB, ~3.5x faster on CPU at matching quality. - French switches from french_24l to the new 6-layer french. The 24-layer _24l models are no longer used. - Add Dutch (nl) with the native voice daan; every voice declares nl. - configure.sh and pocket_plan.py know about nl. - prune_weights.py docstring: pocket-tts 4.x pins files to mixed revisions, so pruning stays folder-based. Demo - Pin @readium/speech to 0.18.0 (was 0.5.0). Replace the removed setVoice/setRate/setPitch/setSpeakInContentLanguage calls with submitPreferences(new SpeechPreferences(...)). Docs and tests - Measured sizes and RAM in configuration.md and pocket.md; fix the stale README download size and the API.md language-row fallback claim. - Tests for the model map, installed model configs, voice language coverage and Dutch; integration test for en/fr/nl. Refs readium#35, readium#36
Server - CORS for the Readium Speech demos (CORS_ORIGINS, default https://readium.org); nginx now allows OPTIONS for the preflight and answers rate limits with 429. - Deploy gates on /readyz (healthcheck + docker compose up --wait), so a failed model load fails the job instead of going green. - ElevenLabs: warn in production when the daily cap is 0; keep the usage counter on the weights volume so a redeploy does not reset it. - A busy server returns 429 with Retry-After after SYNTHESIS_QUEUE_TIMEOUT_SECONDS instead of queueing without limit. - API_KEY_ENABLED=true is refused at startup (nothing enforces the key). - Circuit breaker admits one half-open trial at a time. - Wizard: no crash without pydantic, drops cross-language pairs for languages that are no longer selected; the server warns about ignored pairs. - Pocket integration fixture initialises the semaphore. Audio - Default bitrate when the request gives none: Opus 32 kbps (voip), MP3 64 kbps, chosen on measured PESQ against the 24 kHz source. A client bitrate still wins. - nginx serves HTTP/2. Demo - Replay reuses the loaded audio instead of calling /synthesize again. - Word highlighting works: decorate() needs the quote under text, the demo passed it at the top level so nothing was painted. - Opus is the default format and the engine is rebuilt so the request matches. - Smaller type and spacing, shadcn-style components in plain CSS, grouped voice picker, elapsed time on the Speak button, character counter, empty-state hint, GitHub button and clickable endpoint links. Closes readium#36, readium#37, readium#38, readium#39, readium#40, readium#41, readium#42, readium#43, readium#44, readium#45, readium#46, readium#47, readium#48
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved CORS gaps, blocked circuit-breaker recovery, an order-dependent integration test, an insufficient deployment timeout, and incomplete audio replay leave functional and reliability issues.
6 open issues
Increase SSH timeout beyond the readiness wait · New Release trial permits after non-5xx AppError outcomes · New Preserve CORS headers on unhandled 500 responses · New Prevent replay after seeking into a later audio chunk · New Add CORS headers to nginx-generated 429 responses · New Initialize the semaphore in the standalone provider test · New
What changed in this PR
Updates the server’s Pocket TTS integration to Kyutai 4.x, adds Dutch support, and improves deployment reliability and the Readium Speech demo.
Changes:
- Migrates language models, expands the catalog to 27 voices, and updates configuration tools and documentation.
- Adds CORS, bounded synthesis queues, readiness-gated deployment, and provider safeguards.
- Updates the demo to Readium Speech 0.18.0, improves replay and highlighting, and tunes audio defaults.
| File | Description |
|---|---|
uv.lock |
Locks Pocket TTS 4.0.1 and updated dependencies. |
tests/test_pocket_models.py |
Adds model-map and Dutch catalog checks. |
tests/test_language_filter.py |
Updates language coverage and voice counts. |
tests/test_ffmpeg_bitrate.py |
Tests bitrate defaults and overrides. |
tests/test_cors.py |
Tests CORS, authentication guard, and busy responses. |
tests/test_circuit_breaker.py |
Tests half-open trial gating. |
tests/integration/test_pocket_tts.py |
Initializes concurrency and adds multilingual synthesis checks. |
scripts/prune_weights.py |
Clarifies revision-aware cache-pruning documentation. |
scripts/pocket_plan.py |
Adds Dutch and updates planner expectations. |
scripts/configure.sh |
Adds Dutch, planner fallback, and stale-pair cleanup. |
README.md |
Updates supported languages and download sizes. |
pyproject.toml |
Raises the minimum Pocket TTS version. |
nginx/templates/20-speech-server.conf.template |
Enables HTTP/2, preflight requests, and 429 limit responses. |
nginx/templates/00-hardening.conf.template |
Corrects concurrency and authentication comments. |
Makefile |
Prepares development tools for Docker checks. |
docs/voices.md |
Documents the expanded catalog and embedding sizes. |
docs/providers/pocket.md |
Documents the new language models. |
docs/providers/elevenlabs.md |
Clarifies usage-counter persistence. |
docs/development.md |
Updates Docker tooling and request-flow documentation. |
docs/deployment.md |
Documents readiness gates and deployment safeguards. |
docs/configuration.md |
Updates settings, model sizes, and concurrency guidance. |
docs/API.md |
Clarifies CORS, errors, language selection, and bitrates. |
Dockerfile |
Switches health checks to readiness with longer startup grace. |
docker-compose.yml |
Persists ElevenLabs usage on the weights volume. |
docker-compose.dev.yml |
Mounts files needed by development commands. |
app/static/demo.html |
Updates playback APIs, replay, highlighting, and UI. |
app/providers/pocket_tts.py |
Migrates models and warns about ignored language pairs. |
app/main.py |
Adds CORS and uncapped ElevenLabs warnings. |
app/drivers/ffmpeg.py |
Sets speech-oriented Opus and MP3 defaults. |
app/data/voices/pocket/voices.json |
Adds Dutch coverage and the Daan voice. |
app/core/registry.py |
Removes the registry lookup method. |
app/core/daily_limit.py |
Removes the standalone self-check. |
app/core/concurrency.py |
Bounds queue waits and returns retry guidance. |
app/core/circuit_breaker.py |
Gates half-open trial requests. |
app/config/settings.py |
Adds CORS and queue settings; rejects unsupported authentication. |
app/api/routes/synthesize.py |
Returns buffered audio directly and removes obsolete error metadata. |
app/api/errors.py |
Supports error-response headers and removes an unused error class. |
.github/workflows/deploy.yml |
Waits for application readiness before continuing deployment. |
Review effort: Balanced
… deploy - deploy: give the SSH step a 20m command timeout, longer than the 12m readiness wait (the action's default is 10m). - circuit breaker: a half-open trial that ends with a client/quota error (404, 429) no longer keeps the single trial slot; record_neutral() frees it without changing the breaker's state. - CORS: unhandled errors are answered by Starlette's outermost layer, outside CORSMiddleware, so the 500 now carries the allow-origin header itself. - nginx: its own rate-limit 429 responses now carry the CORS headers for NGINX_CORS_ORIGIN (default https://readium.org), Retry-After and a JSON body. Security headers move into a snippet so the named location can include them. - demo: replay only when the first audio chunk is still there; a seek drops earlier chunks and replaying the tail as the whole clip would be wrong. - integration tests: initialise the semaphore for every test, not only the ones using the fixture.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Moves Pocket TTS to Kyutai's 4.x models, adds Dutch, brings the demo page up to the current
@readium/speech, and fixes a set of problems found while auditing and testing the server end to end.Closes #35
Closes #36
Closes #37
Closes #38
Closes #39
Closes #40
Closes #41
Closes #42
Closes #43
Closes #44
Closes #45
Closes #46
Closes #47
Closes #48
What changed
Models (#35)
pocket-tts4.0.1. English uses the 18M flagship (english_18m_2026-10, ~111 MB); fr/it/de/es/pt/nl use their retrained 6-layer models (~219 MB). The old 24-layer_24lmodels and the oldenglishdefault are no longer supported.nl) added to every voice's cross-language set, plus a native Dutch voice,daan. 27 voices.Demo (#36, #37, #45, #47)
@readium/speech0.18.0:submitPreferences(new SpeechPreferences(...))replaces the removedsetVoice/setRate/setPitch/setSpeakInContentLanguage./synthesizeagain.decorate()needs the quote undertext: { highlight, before, after }; the demo passed them at the top level, so nothing was ever painted.Server fixes (#38–#44, #46)
CORS_ORIGINS, defaulthttps://readium.org) and nginxOPTIONSfor the preflight./readyzwith--wait; healthcheck start period 600 s.429withRetry-After.API_KEY_ENABLED=trueis refused at startup (nothing enforced it).Audio (#45)
output.bitrate: Opus 32 kbps (-application voip), MP3 64 kbps. Chosen on measured wideband PESQ against the 24 kHz source: Opus 32k 4.50 / 48k 4.55 / 64k 4.48; MP3 32k 3.81 / 64k 4.45 / 128k 4.63. A client bitrate still wins.429instead of503.Testing
ruff,ruff format --check,mypy app/pytest -m 'not integration and not slow'pytest -m integration(real en/fr/nl models)nginx -t(CI method)/service,/voicesper language, synthesis in nl/fr/en, clean 404 for unsupported voice+language, default Opus 14 KB / MP3 26 KB / WAV 157 KB for the same sentenceRetry-AfterandX-Request-IdexposedRetry-After: 5GET /synthesize403, 413 above 32 KB, dotfiles 403english_18m,french,dutch; would remove oldfrench_24l,italian,spanish,english_7m*:*kept, plan view works through theuvfallbackCodeRabbit CLI: 3 findings, all already satisfied by the current code (
daanis invoices.json, the planner supportsnland its self-test passes with 27 voices / 30 pairs,pocket-ttsis pinned>=4.0.1and locked at 4.0.1). One earlier finding (a late result from an overlapping half-open probe) was skipped on purpose.Not tested
Observations, not changed
MAX_CONCURRENT_SYNTHESESonly parallelises different languages (each model is single-threaded behind a lock). For several readers in one language, raiseWORKERS; this is now noted indocs/configuration.md.voices.jsonmarksalbaasmale(already onmain) whiledocs/voices.mdsays female. Not changed; needs a source.Retry-After) was not tested.http2 on, a mismatched Host header gets421instead of the catch-all's444; still rejected.