Skip to content

field-voiced: the Chatterbox worker, and a shared worker client - #60

Merged
ninjudd merged 3 commits into
mainfrom
voice/worker
Aug 8, 2026
Merged

ninjudd merged 3 commits into
mainfrom
voice/worker

Conversation

@ninjudd

@ninjudd ninjudd commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

field-voiced — voice as the second client of the lifecycle #59 extracted. Worker, protocol, adapter, TS client, live protocol tests. No CLI wiring yet; that is the next slice.

The adapter is wired against the wheel, not the README

I downloaded and read chatterbox-tts 0.1.7 rather than working from documentation, and three things that reading settled are recorded in the adapter's docstring:

  • from_pretrained handles the MPS-unavailable fallback itself, so we pass a device preference rather than probing for one.
  • conds.pt ships as a builtin voice. That is what makes audio_prompt_path=None a genuine default voice rather than an error path — the configuration bloom is about to use, now confirmed to exist rather than assumed.
  • model.sr is 24000. A voice variant is therefore at no project rate, so creek will wrap it in a normalize sound — the rule chunk 5 just rebuilt around our own resampler. The bloom half depends on work that already shipped.

The client extraction was a trigger, not a preference

src/aced/client.ts carried this: "The deliberate duplication with audiod/client.ts is small and tolerated until a third daemon argues for a shared base." field-voiced is the third daemon. Copying 226 lines while that sentence sat in the file would have been the same shape of defect the last several reviews kept finding — a claim written down and then not honoured.

What was aced-specific turned out to be seven strings and a job type. The generate response is shared too, since GenerationOutput became shared in #59.

audiod's client stays where it is, deliberately: it spawns a C++ binary rather than a uv project, and its vocabulary is transport rather than generation. Framing is all it shares, and sharing framing alone would tangle both sides more than either is now.

The existing harness paid for itself again

The first draft of connectTo built a base WorkerClient and cast it to the subclass. That typechecks; at runtime it dies with generate is not a function. The live aced tests caught it on the first run, and the constructor is threaded through now.

That is the second time on this branch — the first was the lazy-import constraint those tests imply, which I learned from #59's review rather than from planning.

Verification

360 tests. field-voiced gets the same live harness as field-aced: spawn, handshake, unknown op, job validation, all against the real Python daemon with no torch installed. It is also what would notice if a future edit imported chatterbox at module scope, which would silently cost that coverage.

Both Python packages are pyright strict and CI gates all three — worker, aced, voiced. Adding a package that declares strict typing with nothing running it is exactly what #59's review caught, and doing it a third time silently would have been worse.

What is not here

No field generate routing yet, and no real model run: proving the default voice end to end means downloading ~2 GB of weights, which belongs to the first real run rather than to CI. What is proven is that the job parses, the daemon serves, and the API the adapter calls is the API the wheel exposes.


Note

Medium Risk
New long-lived daemon with model loading and file I/O, but it mirrors the proven aced worker pattern with lazy imports and a quarantined adapter boundary.

Overview
Adds field-voiced, a new Python uv worker that plugs into the shared field_worker daemon lifecycle (same NDJSON socket pattern as field-aced).

The worker defines a VoiceJob wire shape (text, seed, variants, output_dir, optional voice_ref) and a Pipeline that lazily loads Chatterbox TTS 0.1.7, generates numbered WAV variants with per-variant seeds, and returns shared GenerationOutput. Untyped Chatterbox/torch imports are quarantined in adapter.py so pyright stays strict elsewhere and CI can run without torch.

CI now runs pyright on python/voiced alongside worker and aced (uv sync --only-group dev).

Reviewed by Cursor Bugbot for commit ff1b2c1. Configure here.

ninjudd added 2 commits August 7, 2026 20:49
Voice as the second client, which is what #59's extraction was for. The
package is a job dataclass and an adapter; the flock, framing, gate and
idle-exit are field_worker's.

The adapter is wired against chatterbox-tts 0.1.7 read from the published
wheel rather than from its README, and three things that reading settled
are recorded in its docstring. `from_pretrained` handles the
MPS-unavailable fallback itself, so we pass a preference rather than
probing. `conds.pt` ships as a builtin voice, which is what makes
audio_prompt_path=None a real default voice rather than an error path —
the configuration bloom is about to use. And model.sr is 24000, so a
voice variant is not at any project rate and creek will wrap it in a
normalize sound, which is the rule chunk 5 just rebuilt around our own
resampler.

Verified rather than assumed: pyright strict passes, and the daemon
imports and parses a job on a bare interpreter with no torch present,
which is the lazy-import constraint the aced harness set. CI gates this
package too — a package declaring strict typing with nothing running it
is exactly what the #59 review found, and adding a third one silently
would repeat it.

No TS client yet, deliberately. src/aced/client.ts records that its
duplication with audiod/client.ts is "tolerated until a third daemon
argues for a shared base", and field-voiced is that third daemon. The
trigger the codebase wrote down has fired, so the client is an extraction
rather than a copy, and that is its own change.
src/aced/client.ts said its duplication with audiod/client.ts was
"tolerated until a third daemon argues for a shared base". field-voiced
is that third daemon, so this is the trigger the codebase wrote down
firing, not a preference.

What was aced-specific turned out to be seven strings and a job type. The
generate *response* is shared too, because GenerationOutput became shared
in #59: paths, the seeds that made them, and the model is what a recipe
records whichever model it was. AcedClient and VoicedClient are each a
WorkerSpec and a typed generate.

audiod's client stays put, and that is a judgement rather than an
oversight: it spawns a C++ binary rather than a uv project and its
vocabulary is transport, not generation. Framing is all it shares, and
sharing framing alone would tangle both sides more than either is now.

The live aced tests caught a real bug in the first draft. connectTo built
a base WorkerClient and I cast it to the subclass, which typechecks and
then dies with "generate is not a function"; the constructor is threaded
through now. That is the second time on this branch that the existing
harness has paid for itself.

field-voiced gets the same harness — spawn, handshake, unknown op, and
job validation, all against the real daemon with no torch installed. It
is also what would notice if a future edit imported chatterbox at module
scope, which would silently cost the coverage.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ff1b2c1. Configure here.

Comment thread src/workers/client.ts Resolved
Comment thread src/workers/protocol.ts Resolved
#60 review, five findings, all confirmed.

P1 is the one that would have shipped a lie. Chatterbox's generate stores
the conditionals it derives: with a reference, prepare_conditionals
assigns self.conds; without one it only asserts self.conds is not None and
reuses whatever is there. The daemon holds the model for its lifetime —
which is the entire point of the daemon-lite design — so one referenced
job silently becomes the voice of every later unreferenced job in the
session. The recipe would say default voice and the committed audio would
be someone else's. Verified against the 0.1.7 wheel at tts.py:206 and 222.

The pristine builtin conditionals are now kept aside at load and restored
before every unreferenced variant, deep-copied both times because
generate mutates conds.t3 in place.

Four more. The handshake checked the protocol but never who answered, so
one worker's daemon satisfied another's client on a stale socket —
reproduced by starting field-aced on voice's socket path, and that
reproduction is now a test. int(float(...)) took variants: 2.7 as 2 and
seed 1.5 as 1, recording inputs the caller never gave. An empty voice_ref
read as "absent" rather than as the malformed path it is, which would
generate in the wrong voice and commit it. And the protocol tests still
exercised the per-worker ACE schema copies, which went dead when the
client moved to the shared ones — testing shapes nothing parsed with,
while the shapes everything parsed with had no tests at all. Moved rather
than duplicated, since the point is that there is one contract now.

Every fix has a regression, and each fails with its fix disabled.
@ninjudd
ninjudd merged commit a4508cc into main Aug 8, 2026
2 checks passed
ninjudd added a commit that referenced this pull request Aug 8, 2026
Make field-voiced work against the actual model

Five merged pull requests built this worker and every one of them said,
accurately, that nothing had loaded Chatterbox yet. Generating creek's
line is the first time anything did, and it found three things — two of
them mine.

`chatterbox-tts` needs `pkg_resources` and nothing in the graph asks for
it. Chatterbox watermarks every generation through `perth`, whose
`perth_net/__init__.py` imports `pkg_resources`; Python 3.12 no longer
ships it and uv does not install it unasked. perth catches that
ImportError and sets `PerthImplicitWatermarker = None`, so the failure
surfaced one layer up as `'NoneType' object is not callable` from
Chatterbox's constructor, naming neither perth nor setuptools. Declared
as `setuptools>=70,<81` — the upper bound is not decoration, since
setuptools removed `pkg_resources` itself and 83.0.0 satisfies a bare
`>=70` while leaving perth exactly as broken.

The #60 leak fix never worked. Restoring the builtin voice before each
unreferenced variant went through `copy.deepcopy(model.conds)`, and
torch refuses: "Only Tensors created explicitly by the user (graph
leaves) support the deepcopy protocol." Some of those tensors come out
of a forward pass. The fix was right about the leak and inoperative
against the model, and it was verified by reading `chatterbox/tts.py`
rather than by running it — which is precisely the distinction that
review round could not make, because loading the model was the one thing
the harness existed to avoid. `clone_conds` rebuilds the dataclass field
by field with each tensor detached, which is the same shape Chatterbox's
own `save`/`load` round-trip uses.

A model-side failure left no trace. The lifecycle turned every exception
into a one-line protocol error and logged nothing, so the first of these
presented as a single sentence with no stack anywhere, and diagnosing it
meant rebuilding the whole model load by hand outside the daemon. The
wire still carries one line; the daemon's log now also carries the
traceback that explains it.

The regression test for that last one gets its own interpreter rather
than the shared harness's. The existing one prefers
`python/voiced/.venv` when it exists, which after a real `field setup
voiced` contains Chatterbox — so a test wanting the backend to fail on
import would instead load a 2 GB model, and would do so only on machines
where setup had been run. Stating the precondition beats inheriting it;
that is the same ambient-state trap the environment gate hit twice in
#61 and #62.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes voice worker runtime dependencies, conditional cloning on
every default-voice variant, and error logging; no auth surface, but
incorrect cond cloning could still affect voice provenance.
> 
> **Overview**
> Fixes **field-voiced** so the first real Chatterbox load works:
**`setuptools>=70,<81`** is declared so **`perth`** can import
**`pkg_resources`** (otherwise **`'NoneType' object is not callable`**
with no useful name on the wire).
> 
> Replaces **`copy.deepcopy(model.conds)`** with **`clone_conds`**,
which rebuilds conditionals field-by-field with detached tensor
clones—the prior #60 leak fix failed on real tensors from the forward
pass.
> 
> The shared worker daemon now logs full tracebacks to stderr (the
voiced log) on request and generation failures while clients still get
one-line protocol errors.
> 
> Adds a Vitest block that uses a **bare** Python (no Chatterbox) so a
backend import failure is asserted to appear in **`voiced.log`**,
avoiding the main harness’s venv that would load the model.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
b520227. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@ninjudd
ninjudd deleted the voice/worker branch September 28, 2026 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant