Repository navigation
feat(server): filter speech delivery controls with an opt-in allowlist - #1152
plotarmordev wants to merge 1 commit into
Conversation
--allowed-controls keeps listed delivery controls in a normalized form and strips other cue-only brackets before speech input validation; contextual and unknown brackets stay as written. The built-in cue word list holds only words from tags in Fish Audio's public sources.
|
Thanks @plotarmordev for keeping the filter strictly opt-in, with the no-flag path returning the same pointer without allocating, and for pinning the rules down with 30 golden cases. We are carrying this onto current main ourselves, kept as yours (only - Synthema, Ash's AI Assistant. |
|
Thanks for catching this. Please apply the limit to the text as sent, checked before the filter runs, with no second cap. The order would be: the UTF-8 check and the 4096-character count on the raw Why this one:
The cost is that an input over 4096 characters as sent is refused even when filtering would bring it under; that request is already refused without the flag, so we think it is the expected answer. The redraw filter in #1160 runs on the text that passed this check, so the same bound covers a nonempty |
…the scan bound shield what they nest - zig/src/server/drama_allow.zig: a declined opener (attached, or with no ']' within 120 bytes) with a matching close shields its contents, as docs/speech-controls.md says, so with an empty list x[note [sighs] tail] stays whole. - zig/src/server/drama_allow_golden_test.zig: golden cases for attached and overlong nesting, kept byte for byte; the 30 existing cases are unchanged. - zig/src/server/drama_cues.txt: the source comment is one line within 120 columns; the vocabulary is unchanged.
|
Landed on main as 238653a with a maintainer fix-up (04e203d), thank you @plotarmordev. Speech delivery controls can be filtered with an opt-in allowlist. 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. |
|
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. |
What this changes
Adds
serve --allowed-controls LIST, an opt-in filter for bracketed delivery controls in theinputofPOST /v1/audio/speech. It runs before input validation, tokenization and prompt-derived seeding. Without the flag the input is passed through unchanged, and no copy is made.The filter rules:
gentle robotare accepted. Names, and the text inside brackets, are compared after NFC normalization, lowercasing, whitespace folding and removal of trailing!?.….gentle robotlisted,[Gentle Robot!]becomes[gentle robot].drama_cues.txt, and at least one word is a cue rather than a modifier.[sad]and[softly, whispering]are removed this way;[Pleased!]is kept, becausepleasedis not in the vocabulary. An empty LIST removes every recognized control.drama_cues.txtlists only words used in tags in Fish Audio's public Drama 3 and Emotion Control docs, the Drama 3 model card and the Drama 3 technical report, and names those sources.[someone], notes such as[see note 3], and indexes such asx[i]. It also covers a bracket attached to a preceding letter, digit,_, backtick or index (你好[sighs],m[1][sighs]); Markdown links[text](url); unclosed brackets; brackets longer than 120 bytes; and brackets nested inside a kept bracket.<whisper>,<emphasis>,<soft>,<fast>,<slow>,<stress>and<forceful>are removed case-insensitively, including inside kept brackets, and their enclosed text stays. Other angle-bracket text stays.This is a lexical filter. It is not a prompt-injection or content-safety policy. Chat, completions and
drama3-generateare unaffected. docs/speech-controls.md documents the flag and cites the public sources for its examples.This is independent of #1119, #1120, #1134 and #1135 and can be reviewed in any order.
Receipt
aa6bdaaa6b5cb507bb7b9d4456f4ef9ebd9cec7eond1018b318fb51981c4a18f12e40269a4d3ee9713. aarch64 Linux CPU host with Zig 0.17.0. No checkpoint, MLX, PyTorch or GPU was used.tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: no GPU receipt applies. The change only rewrites the request text before validation and tokenization, which is equivalent to a client sending the filtered text. With the flag omitted, a test checks that the input comes back as the same pointer, without allocating. No model, sampling, codec, scheduler or kernel code changes. Behaviour is pinned by synthetic golden cases: 30 invented input/output pairs indrama_allow_golden_test.zig.tools/bench_openai.py: n/a; decoding is unchanged.ttft_sfromtools/bench_cache.py --require-coldon a long prompt, or "n/a" with the reason when the change cannot reach prompt processing: n/a. The filter runs on request text before tokenization, and prompt processing is unchanged.506ef593, with no cached test results and no reruns.zig fmt --check build.zig zig: clean.zig build test -j8 --summary all: 211/211 steps; 2965/2979 tests passed, 0 failed, 14 skipped. The server suite passed 512/512.CUDA_VISIBLE_DEVICES= zig build test-cuda-host -j8 --summary all: 129/129 steps; 2184/2189 tests passed, 0 failed, 5 skipped.CUDA_VISIBLE_DEVICES= zig build test-kernel-contract -j8 --summary all: 11/11 steps; 65/65 tests passed.CUDA_VISIBLE_DEVICES= zig build test-golden -j8 --summary all: 5/5 steps. Server cases: 306/319 equal with 13 known differences. Security cases: 26/26 equal. 0 unexpected differences.drama_cues.txt,docs/speech-controls.mdanddrama_allow_golden_test.zig.8cf0ae2ekeeps only publicly sourced cue words;aa6bdaaalists two of them in the golden policy, with every expected output printed from the filter. Ataa6bdaaa,zig fmt --check build.zig zigis clean andzig build test -j8 --summary allsucceeds: 211/211 steps, 0 failed.drama_allow.zigand the flag do not exist.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.SUMMARYline is in the receipt.