From 454efe9f17ed455d29c14d3adc07273602df044a Mon Sep 17 00:00:00 2001 From: Mikei386 <44135113+Mikei386@users.noreply.github.com> Date: Mon, 26 Oct 2026 20:59:18 +0100 Subject: [PATCH] Fix native Q4 TTS silence collapse with standard sampling --- docs/QWEN_NATIVE_CPU_TTS.md | 8 + docs/maintenance/tts-e2e-2026-10-26/README.md | 149 ++++++++++++ .../full-candidate-results.json | 212 ++++++++++++++++++ .../full-candidate-summary.json | 8 + .../tts-e2e-2026-10-26/native-comparison.json | 52 +++++ qwen_native_worker.py | 6 +- 6 files changed, 434 insertions(+), 1 deletion(-) create mode 100644 docs/maintenance/tts-e2e-2026-10-26/README.md create mode 100644 docs/maintenance/tts-e2e-2026-10-26/full-candidate-results.json create mode 100644 docs/maintenance/tts-e2e-2026-10-26/full-candidate-summary.json create mode 100644 docs/maintenance/tts-e2e-2026-10-26/native-comparison.json diff --git a/docs/QWEN_NATIVE_CPU_TTS.md b/docs/QWEN_NATIVE_CPU_TTS.md index d8829c3..6dd6bea 100644 --- a/docs/QWEN_NATIVE_CPU_TTS.md +++ b/docs/QWEN_NATIVE_CPU_TTS.md @@ -38,6 +38,14 @@ Korrektur wird nicht auf Q4 übertragen. Beide verwenden denselben Q8-Codec, dieselbe private Anna-Referenz und die bereits installierte CPU-Laufzeit0.4.2. [Aktivierung, Prüfung und Rückfall](maintenance/2026-10-22-qwen-q4.md). +Am 26. Oktober wurde mit einem normalen deutschen Satz ein Q4-Fehler bei +erzwungenem Greedy-Decoding reproduziert: Nach dem Satzanfang folgten lange +nahezu stille Codec-Frames. Der Q4-Worker verwendet deshalb die normalen +Sampling-Vorgaben der gepinnten Bindung, weiterhin mit festem Seed 42. Q8 bleibt +unverändert. Die [Ende-zu-Ende-Prüfung und Aktivierungsgrenzen](maintenance/tts-e2e-2026-10-26/README.md) +trennen die vorbereitete Quellkorrektur von ihrer tatsächlichen Aktivierung; +eine bestehende Installation übernimmt eine Quelldatei nicht automatisch. + ## Ressourcen und Verhalten Optionale feste Trennung von Strata und Qwen auf vollständige physische Kerne: diff --git a/docs/maintenance/tts-e2e-2026-10-26/README.md b/docs/maintenance/tts-e2e-2026-10-26/README.md new file mode 100644 index 0000000..5542134 --- /dev/null +++ b/docs/maintenance/tts-e2e-2026-10-26/README.md @@ -0,0 +1,149 @@ +# TTS path investigation — 26 October 2026 + +## Confirmed failure, independently of the Mac client + +A KIT/LiteLLM reply completed normally and its complete 2,212-character text was +present in the owning Hermes session. The requesting profile correctly inherited +the managed Athena STT/TTS routes. Hermes' actual installed `SentenceChunker` and +speech normalizer retained the reply as 21 nonempty speech fragments. + +The original first Qwen request completed with 3.44 seconds of audio. The next +request began producing PCM in about 0.60 seconds but was cancelled after 38.6 +seconds. Cancellation alone did not identify the original cause. + +A controlled replay from the NAS, using the real installed Hermes +`OpenAIStreamer` and existing scoped credentials, reproduced the second-fragment +failure without a Mac or a new LLM call. A 92-character fragment kept producing +near-silent PCM: 73.04 seconds had arrived when the *test's own* 75-second limit +closed its request. Five-second windows after the opening had signed-16 RMS +around 2–15, rather than useful speech. Local STT of a short opening crop +recognized only the introductory two words; the complete long, mostly silent +recording was rejected as silence. This is not evidence of a network buffer +dropping the remainder of the written answer. + +## Native sampling comparison + +The deployed `qwen_native_worker.py` explicitly forced `do_sample=False` for both +quantizations. The pinned native CPU binding 0.4.2 / ABI 5 defaults to +`do_sample=True`, temperature 0.9, top-k 50, top-p 1.0 and repetition penalty 1.05. + +An isolated CPU process reused the existing Q4 talker, Q8 codec and Anna reference +without changing or unloading production workers. It had a four-GiB memory cap, +two-CPU quota, low priority, no GPU and a four-minute lifetime. The comparative +runs used the same 256-token limit; an own-test-only five-second near-silence +guard stopped bad output. These resource-limited timings are **not production +throughput benchmarks**. + +| Native setting | Seed | Audio duration | Outcome | +|---|---:|---:|---| +| Greedy | 42 | 6.16 s before guard | Introductory words, then silence | +| Binding-default sampling | 42 | 5.84 s | All clause content recognized by local STT | +| Binding-default sampling | 43 | 6.80 s | All clause content recognized by local STT | +| Sampling, separate German technical control | 42 | 5.04 s | Complete; units and product names recognized | +| Sampling, following sentence | 42 | 3.36 s | Complete | + +Foreign product names/acronyms in the sampled original were imperfectly recognized +by STT. This comparison establishes removal of the reproduced silence collapse; +it does not prove exact pronunciation or universal freedom from synthesis errors. + +A subsequent full test executed the **actual candidate worker**, not a substitute +generator, and fed it all 21 Hermes-normalized fragments. All 21 completed, +producing 148.80 seconds of audio. Native synthesis took 333.55 seconds under the +deliberate two-CPU/low-priority diagnostic limit; this is not a real-time result +for the production CPU policy. The transient process exited and its unit was +independently confirmed inactive. [Per-fragment results](full-candidate-results.json), +[summary](full-candidate-summary.json), [sampling comparison](native-comparison.json). + +The combined recording was transcribed by the existing local Parakeet service, +in two groups at existing fragment boundaries (87.92 and 60.88 seconds, below its +120-second upload limit). The 2,074-character transcript reached the final +sentence. This verifies continuation through the whole synthesized reply, not +verbatim identity: technical-name recognition/pronunciation and the sanitizer +loss described below remain separate limitations. The first attempt to send the +entire recording was cleanly rejected with HTTP 400 for the 120-second limit; +no STT settings were changed to accommodate a diagnostic file. + +## Separate upstream text-loss finding + +The installed Hermes normalizer deletes natural compounds such as `15-min-Takt` +and `24-Stunden-Betrieb`: its dense-identifier heuristic treats a digit plus two +hyphens as a machine identifier. The failure is reproducible with public, +synthetic single-sentence inputs, before any TTS request. In the quoted reply, +this explains the missing frequency phrase in the full candidate transcription. +The native Q4 correction cannot recover text that was already deleted upstream. + +This logic is part of upstream commit +[`9b761903b9`](https://github.com/NousResearch/hermes-agent/commit/9b761903b9), +mirrored in the Python gateway and desktop TypeScript normalizers. The examined +local source files are clean relative to their tracked Git versions. No +published correction for these false positives was verified. No Hermes source, +Mac source, skill or personality prompt was patched to hide this finding. + +There is also an intentional mode difference in the inspected desktop source: +explicit read-aloud sanitizes completed text on the client (including summarizing +Markdown tables by their headers), whereas live conversation feeds raw deltas +to the gateway's sentence normalizer. Neither behavior explains the reproduced +second-fragment silent collapse, but a post-activation client test must identify +which mode it exercises rather than treating them as interchangeable. + +## Scoped correction and deployment + +Only the native **Q4** worker switches to the pinned binding's normal sampling. +Seed 42 remains fixed. The previously qualified, inactive Q8 route stays greedy; +its checkpoint-specific onset profile is unchanged. No model weights, voice, +codec, CPU allocation, Hermes profile, endpoint, Mac app or KIT model changes. + +The normal installer already includes `qwen_native_worker.py`; a native Debian +installation receives the correction through the same source file, using the +existing pinned CPU environment. Refresh only an idle owned TTS worker, or +restart its owning service in an authorized idle window. Keep the configured +state/model/voice paths and service user. No Docker-only dependency was added to +the worker or native installation requirements. + +For today's existing Docker deployment, a thin image on the exact verified +current base was built with only this worker replaced: +`athena-deck-standalone:tts-q4-sampling-20261026`. No base/runtime/weight download +or consolidation is needed. The running root filesystem is read-only, so an +attempted atomic hot replacement failed **before any production write**. +Independent readback confirmed unchanged live/canonical worker hashes, +installation image, container start time and resident worker. Do not weaken the +read-only filesystem or write into Docker overlay storage to bypass this. + +Activation therefore requires an authorized, normally recreated Deck container +at idle, followed by restoration of the previous chat profile. At this report's +initial stage it is **prepared, not yet active**. The earlier attempted build +using a bare image ID also failed before activation; the successful thin build +uses the existing local tag after verifying it resolves to the running image ID. + +## Validation and remaining acceptance + +- Fifty existing targeted tests passed: native Qwen, Pocket protocol/routing, + audio policy, German speech normalization and endpoint enhancer. +- A broader run had one existing STT-fixture failure: + `test_audio_residency.test_stt_reuses_cpu_server_until_stop` lacks the `model` + fixture key now required by `stt.start`. Neither that test nor `stt.py` was + changed. Do not report the broader 52-test run as passing. +- Existing local STT successfully transcribed the control and comparison audio. +- Actual Mac client and gateway both display 0.22.5. The Mac's installed + speak-stream path accepts incremental text and schedules signed-16 PCM at the + gateway's announced sample rate. No Mac files were edited. +- A whole reply through the unchanged Mac app and its actual remote WebSocket + remains required **after activation**; configuration checks and the isolated + native comparison do not substitute for it. +- Physical speaker quality and real microphone barge-in behavior need separate + observation. No claim that crackles or every conversation interruption is fixed. + +Generated audio, the quoted private reply and raw diagnostic outputs stay in the +task's own work/test folders, outside Git. No production transcript corpus, +private prompt, key, voice reference, weight or VPN material is included here. +No Hermes/VPN container or host was restarted during preparation. + +## Primary references + +- [Hermes audio relay implementation](https://github.com/NousResearch/hermes-agent/blob/main/hermes_cli/web_routers/audio.py) +- [Hermes native desktop playback](https://github.com/NousResearch/hermes-agent/blob/main/apps/desktop/src/lib/voice-playback.ts) +- [Pinned CPU binding package and scheduling limitations](https://pypi.org/project/realtimetts-qwen-native-cpu/0.4.2/) +- [Qwen native engine and CPU operation](https://github.com/KoljaB/RealtimeTTS/blob/master/docs/engines/qwen.md) + +The behavior/signature comparison used the **installed** 0.4.2 binding and +Hermes source, rather than assuming upstream main matches the deployed build. diff --git a/docs/maintenance/tts-e2e-2026-10-26/full-candidate-results.json b/docs/maintenance/tts-e2e-2026-10-26/full-candidate-results.json new file mode 100644 index 0000000..d9b3e9e --- /dev/null +++ b/docs/maintenance/tts-e2e-2026-10-26/full-candidate-results.json @@ -0,0 +1,212 @@ +[ + { + "fragment": 0, + "characters": 44, + "ok": true, + "quant": "Q4", + "duration": 3.12, + "sample_rate": 24000, + "seconds": 6.9828406069973425, + "first_chunk_seconds": 0.484549305998371 + }, + { + "fragment": 1, + "characters": 92, + "ok": true, + "quant": "Q4", + "duration": 5.84, + "sample_rate": 24000, + "seconds": 12.965412140998524, + "first_chunk_seconds": 0.5648148020009103 + }, + { + "fragment": 2, + "characters": 62, + "ok": true, + "quant": "Q4", + "duration": 4.08, + "sample_rate": 24000, + "seconds": 9.072049905000313, + "first_chunk_seconds": 0.4692418760023429 + }, + { + "fragment": 3, + "characters": 151, + "ok": true, + "quant": "Q4", + "duration": 8.56, + "sample_rate": 24000, + "seconds": 19.1115673029999, + "first_chunk_seconds": 0.620963268000196 + }, + { + "fragment": 4, + "characters": 327, + "ok": true, + "quant": "Q4", + "duration": 22.72, + "sample_rate": 24000, + "seconds": 50.81320586700167, + "first_chunk_seconds": 0.761176019001141 + }, + { + "fragment": 5, + "characters": 114, + "ok": true, + "quant": "Q4", + "duration": 6.32, + "sample_rate": 24000, + "seconds": 14.635219431002042, + "first_chunk_seconds": 0.5852003420004621 + }, + { + "fragment": 6, + "characters": 141, + "ok": true, + "quant": "Q4", + "duration": 9.36, + "sample_rate": 24000, + "seconds": 21.13131739000164, + "first_chunk_seconds": 0.6429750319985033 + }, + { + "fragment": 7, + "characters": 162, + "ok": true, + "quant": "Q4", + "duration": 14.24, + "sample_rate": 24000, + "seconds": 31.917101455001102, + "first_chunk_seconds": 0.40717742899869336 + }, + { + "fragment": 8, + "characters": 65, + "ok": true, + "quant": "Q4", + "duration": 4.4, + "sample_rate": 24000, + "seconds": 10.118430091002665, + "first_chunk_seconds": 0.5287764839995361 + }, + { + "fragment": 9, + "characters": 30, + "ok": true, + "quant": "Q4", + "duration": 2.56, + "sample_rate": 24000, + "seconds": 5.7047057269992365, + "first_chunk_seconds": 0.42179903599753743 + }, + { + "fragment": 10, + "characters": 96, + "ok": true, + "quant": "Q4", + "duration": 6.72, + "sample_rate": 24000, + "seconds": 14.931530837999162, + "first_chunk_seconds": 0.5145313590001024 + }, + { + "fragment": 11, + "characters": 108, + "ok": true, + "quant": "Q4", + "duration": 9.28, + "sample_rate": 24000, + "seconds": 20.56802203299958, + "first_chunk_seconds": 0.6538595099991653 + }, + { + "fragment": 12, + "characters": 88, + "ok": true, + "quant": "Q4", + "duration": 6.48, + "sample_rate": 24000, + "seconds": 14.33538431100169, + "first_chunk_seconds": 0.35503150400109007 + }, + { + "fragment": 13, + "characters": 113, + "ok": true, + "quant": "Q4", + "duration": 9.04, + "sample_rate": 24000, + "seconds": 19.91482547800115, + "first_chunk_seconds": 0.4049223779984459 + }, + { + "fragment": 14, + "characters": 31, + "ok": true, + "quant": "Q4", + "duration": 3.28, + "sample_rate": 24000, + "seconds": 7.208547706002719, + "first_chunk_seconds": 0.4532418830021925 + }, + { + "fragment": 15, + "characters": 59, + "ok": true, + "quant": "Q4", + "duration": 5.68, + "sample_rate": 24000, + "seconds": 13.21358799200243, + "first_chunk_seconds": 0.5164929019992996 + }, + { + "fragment": 16, + "characters": 72, + "ok": true, + "quant": "Q4", + "duration": 5.36, + "sample_rate": 24000, + "seconds": 12.008726664997084, + "first_chunk_seconds": 0.5155859609985782 + }, + { + "fragment": 17, + "characters": 131, + "ok": true, + "quant": "Q4", + "duration": 7.84, + "sample_rate": 24000, + "seconds": 17.93570649799949, + "first_chunk_seconds": 0.605659958000615 + }, + { + "fragment": 18, + "characters": 73, + "ok": true, + "quant": "Q4", + "duration": 4.88, + "sample_rate": 24000, + "seconds": 10.99592600500182, + "first_chunk_seconds": 0.5729022049999912 + }, + { + "fragment": 19, + "characters": 60, + "ok": true, + "quant": "Q4", + "duration": 4.24, + "sample_rate": 24000, + "seconds": 9.38204708700141, + "first_chunk_seconds": 0.5200995280029019 + }, + { + "fragment": 20, + "characters": 66, + "ok": true, + "quant": "Q4", + "duration": 4.8, + "sample_rate": 24000, + "seconds": 10.60315390499818, + "first_chunk_seconds": 0.5160307839978486 + } +] diff --git a/docs/maintenance/tts-e2e-2026-10-26/full-candidate-summary.json b/docs/maintenance/tts-e2e-2026-10-26/full-candidate-summary.json new file mode 100644 index 0000000..ea626a0 --- /dev/null +++ b/docs/maintenance/tts-e2e-2026-10-26/full-candidate-summary.json @@ -0,0 +1,8 @@ +{ + "fragments": 21, + "all_complete": true, + "audio_seconds": 148.8, + "isolated_cpu_wall_seconds": 333.54930843500915, + "timing_caveat": "Isolated two-CPU low-priority run; not production throughput", + "runtime": "Q4 sampled candidate; Q8 codec; Anna" +} diff --git a/docs/maintenance/tts-e2e-2026-10-26/native-comparison.json b/docs/maintenance/tts-e2e-2026-10-26/native-comparison.json new file mode 100644 index 0000000..78a0830 --- /dev/null +++ b/docs/maintenance/tts-e2e-2026-10-26/native-comparison.json @@ -0,0 +1,52 @@ +[ + { + "case": "greedy-original", + "do_sample": false, + "seed": 42, + "wall": 14.267326959998172, + "audio_seconds": 6.16, + "first_audio": 0.5677038979993085, + "stopped": "five_seconds_near_silence", + "producer_alive": false + }, + { + "case": "sample-original-42", + "do_sample": true, + "seed": 42, + "wall": 12.825009013999079, + "audio_seconds": 5.84, + "first_audio": 0.5092893879991607, + "stopped": null, + "producer_alive": false + }, + { + "case": "sample-original-43", + "do_sample": true, + "seed": 43, + "wall": 14.916078956001002, + "audio_seconds": 6.8, + "first_audio": 0.5641650219986332, + "stopped": null, + "producer_alive": false + }, + { + "case": "sample-technical", + "do_sample": true, + "seed": 42, + "wall": 11.071966374998738, + "audio_seconds": 5.04, + "first_audio": 0.4926884090018575, + "stopped": null, + "producer_alive": false + }, + { + "case": "sample-next", + "do_sample": true, + "seed": 42, + "wall": 7.417793287000677, + "audio_seconds": 3.36, + "first_audio": 0.48551487200165866, + "stopped": null, + "producer_alive": false + } +] diff --git a/qwen_native_worker.py b/qwen_native_worker.py index 06e9603..5c9a352 100644 --- a/qwen_native_worker.py +++ b/qwen_native_worker.py @@ -53,7 +53,11 @@ def main(): voice=voice_for(request['voice']);parts=[];first=None;index=0;total=0;cancel=JobCancellation(root) for text in spoken_chunks(dict(text=request['text'],language='German')): if cancel.is_set():break - with closing(model.stream(text=text,lang='german',ref_spk_emb=voice,seed=42,do_sample=False,max_new_tokens=1024,onset_silence_profile=onset,cancel_event=cancel)) as stream: + # Q4 greedy decoding can emit a short prefix followed by near-silent + # codec frames until the token cap (reproduced with a normal German + # sentence). Use the pinned binding's standard sampling for Q4; keep + # the previously qualified Q8 path unchanged. The seed remains fixed. + with closing(model.stream(text=text,lang='german',ref_spk_emb=voice,seed=42,do_sample=quant=='Q4',max_new_tokens=1024,onset_silence_profile=onset,cancel_event=cancel)) as stream: for chunk,rate in stream: if cancel.is_set():break if rate!=24000 or not np.isfinite(chunk).all():raise ValueError('Ungültige Qwen-Audiodaten.')