Skip to content

feat(speech): add an onset rule to the silence guard - #1158

Closed
plotarmordev wants to merge 2 commits into
ashhart:mainfrom
plotarmordev:feat/silence-onset
Closed

plotarmordev wants to merge 2 commits into
ashhart:mainfrom
plotarmordev:feat/silence-onset

Conversation

@plotarmordev

Copy link
Copy Markdown
Contributor

What this changes

Stacked on the silence-guard PR (#1157) and reviewable after it; independent otherwise.

Adds an onset rule to the Drama 3 silence guard: a reply that has voiced less than --silence-onset-voiced-s seconds so far ends as silence once --silence-onset-s seconds run below the guard's floor, keeping its audio through that frame. It is off unless both flags are given, and without them the guard is unchanged.

  • --silence-onset-s SECONDS: the silent run that ends a reply still under the voiced minimum. It must be positive and below --silence-seconds, so it needs the guard's floor and duration.
  • --silence-onset-voiced-s SECONDS: the cumulative voiced time below which the rule applies. It must be positive and finite and has no default.
  • Either flag without the other, or an explicit 0, is refused at startup. On a non-Drama model all four silence flags are refused.
  • Voiced time is cumulative, so once a reply reaches the minimum only the tail rule can end it. The rule is checked on the same frame as the tail rule, in whole and streamed replies alike.
  • With illustrative values, --silence-floor-dbfs -50 --silence-seconds 8 --silence-onset-s 2 --silence-onset-voiced-s 0.25 logs drama3: silence guard on: a reply ends after 8 s below -50 dBFS, or after 2 s below it with under 0.25 s voiced. Calibrate on built-in or public speech; no value is recommended.
  • This overlaps the mid-silence pull request in the guard config, CLI flag table, usage line, README and changelog. Each conflict resolves by keeping both sides.

Receipt

  • Environment, with the TensorFold commit, MLX or PyTorch version, machine and GPU, checkpoint and revision: 71b8b7a4, on the silence-guard PR's 75736ad0, on main d1018b31. Host tests: Linux aarch64, Zig 0.17.0, CPU only, no MLX or PyTorch. GPU run: one NVIDIA GB10, native CUDA build (-Dsm=121), no MLX or PyTorch, checkpoint fishaudio/drama-3 with its codec.pth (revision not recorded), built-in voice. Stock is upstream d1018b31. The candidate is ca60e9c8, an integration of all the open Drama patches on d1018b31, this one included, not this branch's tip.
  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false: speech returns PCM, so PCM is compared by SHA-256.
    • GPU setup: 18 server launches, one per arm and seed salt (TENSORFOLD_SEED_SALT 0, 10 and 20), each sent the same 10 public synthetic texts: 180 requests, all complete. Every server ran with --parallel 1 --no-drafts --prompt-cache-gib 0 --context 4096 and TF_DRAMA_PREFILL_ROWS=1, which keeps the candidate on stock's prefill schedule.
    • Arms, with illustrative thresholds that are not calibrated for any voice: stock; the candidate without guard flags ("off"); --silence-floor-dbfs -50 --silence-seconds 8 ("base"); base plus --silence-onset-s 2 --silence-onset-voiced-s 0.4 --silence-mid-s 2 --silence-mid-min-voiced-s 0.4 ("silence"); silence plus --silence-redraws 2 --silence-redraw-budget-s 60 --silence-redraw-controls '' --short-reply-ratio 0.6 --short-reply-chars-per-s 12 ("redraw"); and --register-redraw-st 6 --register-redraw-high 50 --register-high-hz 300 --silence-redraw-budget-s 60 ("register").
    • All checks passed. Off equals stock byte for byte on all 30 replies. Guard headers appear exactly when their option is set. Every guarded reply where no guard fired equals off byte for byte. Each redraw counter equals the redraws that finished with audio. A redraw ran exactly when the silence arm's take ended silence or was judged short. Each of the 22 silenced takes in the base and silence arms is a prefix of the off audio.
    • This PR: the onset rule fired once. At salt 0, the onset text ended silence after 2.04 s of audio in the silence arm, where the tail rule alone (base arm) ended it after 8.03 s; the kept audio is a prefix of the off reply. The silence arm's other 11 silence finishes have the base arm's audio, so the onset rule did not change them. One firing on one text exercises the rule but does not calibrate it.
    • Host tests run the production PCM callback and decode schedule: an onset trip cuts whole and streamed replies at the same frame, a short silent start followed by voice past the minimum is kept whole, and with the rule off only the tail rule cuts.
  • Decode speed before and after, from tools/bench_openai.py: not measured; the GPU run compared PCM, not speed. The rule adds one comparison per decoded frame when the guard is on.
  • Prompt speed before and after: the cold first request's ttft_s from tools/bench_cache.py --require-cold on a long prompt, or "n/a" with the reason when the change cannot reach prompt processing: n/a. The rule reads decoded audio and does not reach prompt processing.
  • Tests run, with pass, fail and skip counts:
    • CUDA_VISIBLE_DEVICES= zig build test --summary all: 213/213 steps, 977 passed, 0 failed, 2 skipped.
    • zig build test-lane-api-host --summary all: 222 passed.
    • zig build test-kernel-contract test-golden --summary all: 16/16 steps, 55 passed. Goldens: 306/319 equal with 0 unexpected differences, plus 26/26.
    • zig build native drama3-generate -Dsm=121 with the CUDA toolkit's nvcc: linked.
    • zig fmt --check build.zig zig and git diff --check are clean. tools/zig/lean_check.py reports the same 444 findings as main, none new.
    • These counts are from the second merge of the guard branch. After the third, which brought only the guard's test-only and README changes, the native build and tools/zig/test_speech_flags.py were rerun: 1 passed, onset flags included. Since then the code has changed only by illustrative values in one unit test (919c5121). 71b8b7a4 squashes that branch over 75736ad0, with an identical tree.
    • Seven mutants of the rule, validation and CLI parsing were each killed by the new tests.
  • Not run, and why: Metal compilation and device runs, because no Metal host was used. CUDA decode speed was not measured. Concurrent against solo was not run. No GPU kernel changed and no frozen test data was edited.

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.
  • No precision traded for speed. If the bits change, the description says which sums change and why.
  • A new or changed GPU kernel is registered with the kernel contract (docs/kernel-contract.md); each backend's SUMMARY line is in the receipt.
  • Prompt processing is no slower than the last release.
  • The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.

Add --silence-floor-dbfs and --silence-seconds so native Drama speech can stop after a sustained run below an explicit frame-power floor, keeping the audio and reporting the finish as silence. The guard is off unless both flags are set and is refused for non-speech models.
Add --silence-onset-s with a required --silence-onset-voiced-s so a synthesis that has voiced less than the given minimum ends as silence after a shorter run below the floor. Both flags need the silence guard and have no defaults.
@ashhart

ashhart commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Thanks @plotarmordev for keeping the onset rule paired and opt-in, refusing a lone or zero flag at startup (zig/src/core/speech_guard.zig:18-22), and testing the cut through the real PCM callback, including a short silent start followed by speech that must be kept (zig/src/native/drama_host.zig:359). The onset change itself looks right to us, so we are carrying it onto current main ourselves on top of #1157, with both commits kept as yours; the only fix it needs is #1157's Metal host-test link, which our separate commit on #1157 makes, and since #1159 also changes speech_guard.zig, we will combine the two when the second lands and add a test with both rules set. Then it goes to the device runs on a GB10 and on Metal, where we will check that an onset cut lands on the same frame in whole and streamed replies and that speech past the voiced minimum is kept, and lands. You need not rebase; if you are in the middle of a change, please tell us so we do not collide.

- Synthema, Ash's AI Assistant.

ashhart added a commit that referenced this pull request Oct 24, 2026
…st.zig

- Landed after #1158 and #1159, this PR takes zig/src/server/cli.zig to 606 lines, so its two remaining flag tests (--device and --segments, and the GPU engine's flags) move unchanged to zig/src/server/cli_test.zig, which reaches the private helpers through a test-only cli.Test, as log.zig's Test does.
@ashhart

ashhart commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Landed on main as caea205, thank you @plotarmordev. The silence guard's onset rule is in. On a GB10, the default Drama output stayed byte-identical to main on six inputs with these options off, repeats were 6/6 equal, and concurrent equalled solo. The speech, Drama, server and golden host suites pass on current main.

- Synthema, Ash's AI Assistant.

@ashhart ashhart closed this Oct 24, 2026
@ashhart

ashhart commented Oct 24, 2026

Copy link
Copy Markdown
Owner

This shipped in TensorFold 1.1.4: https://github.com/ashhart/TensorFold/releases/tag/v1.1.4

Thank you @plotarmordev for the contribution.

- Synthema, Ash's AI Assistant.

@ashhart ashhart added the landed Landed on main by the maintainers; the commits keep the contributor's authorship label Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

landed Landed on main by the maintainers; the commits keep the contributor's authorship

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants