Skip to content

feat(server): an environment speaks with voice models the user downloads - #78

Merged
mfituri merged 5 commits into
mainfrom
mohammed/cod-120-the-voice-agent-speaks-with-downloaded
Nov 16, 2026
Merged

mfituri merged 5 commits into
mainfrom
mohammed/cod-120-the-voice-agent-speaks-with-downloaded

Conversation

@mfituri

@mfituri mfituri commented Nov 16, 2026 •

Copy link
Copy Markdown

The app could listen (dictation with a downloaded model) but could not speak. The voice agent layer speaks with the browser's system voice as a stand-in. This adds speech output with downloaded local voice models, working the way dictation's models do.

What it adds

  • Voice settings → speech output: a card per voice model with its size, licence and link, download with progress, cancel and remove; each voice has "Hear a sample" and can be picked. There is no default voice.
  • Server service: lists the voices with their install state, downloads and verifies a model, keeps the selection in a state file, and speaks one sentence per call, returning 16-bit mono PCM with estimated word timings. Synthesis runs in a child process that gets a minimal environment, is killed on cancel and unloads when idle.
  • Wire: a fork HTTP group beside dictation's, through the same authenticated path, so a remote client works the same way. speak answers with a JSON header followed by the PCM bytes.

Where the lists live

  • The runtime (a prebuilt native library) is pinned in this repository: URL, size and SHA-256 per platform. It is the build upstream's open read-aloud pull request (pingdotgg/t3code feat(read-aloud): add optional speech playback across clients pingdotgg/t3code#35910) pins, in upstream's on-disk layout and with the same small edits to SpeechModelStore.ts, so that when upstream ships local synthesis the fork can delete its own runtime code. Upstream's version returns MP3 and no timings; a voice agent needs PCM and timings, which is why the fork has its own service.
  • The list of voice models is not in this repository. It is a data file, voices/voices.json, in the team catalog repository, validated strictly: a model is installed only from a huggingface.co URL pinned to a commit and only after its SHA-256 matches. A missing or invalid file means no voices, with the reason shown.

Safety

Nothing spoken leaves the machine: synthesis is local, and the only network traffic is the downloads the user starts. A hash mismatch installs nothing and removes the partial file. Archive entry paths and the extracted tree are checked before use. The library still runs as the user with no sandbox; the minimal environment limits what it is handed, not what it can reach.

Checked

  • vp run check:changed passes; unit tests use a stand-in worker.
  • The real service, store, extractor, worker and binding were run in a container with no network and no credentials against real models on linux-arm64: six models and seventeen voices spoke through speak, with format, level, length and timing checks passing. That run found two bugs, fixed here: the binding only streamed (three model families deliver audio only whole), and every voice id was sent as an option some models refuse.
  • Not proven: macOS loading (code signing, GPU) and speed, Windows, a real GPU device on Linux, the network download itself, the settings UI in a real client, and the remote path. Nobody has listened to the output of the app's own code path.

Known limits

  • Reached through Settings → Voice only; no command palette action or shortcut.
  • A picked voice can be changed but is cleared only by removing its model.
  • A model taken out of the list while installed stays on disk.
  • Cancelling kills the worker, so the next sentence reloads the model (0.6 to 2.8 s in the container).
  • A model that needs a second file beside its weights cannot be listed yet.
  • The voice agent layer does not use this yet; it still speaks with the system voice.

This change only adds; nothing existing changes format.

Claude Fable 5.2, in 1001 Code (Claude Code harness).

🤖 Generated with Claude Code

mfituri and others added 3 commits November 16, 2026 01:52
A speaking agent needs raw audio and word timings, one sentence at a time.
Upstream's local read-aloud (pingdotgg#35910, still open) returns MP3
with no timings, so this adds a fork service on the same runtime, at the same
version, URLs, hashes and folders, to be folded into upstream's when it ships.

- The speech runtime is executable, so its builds are pinned in code by URL,
  size and SHA-256. The voice models are data: voices/voices.json in the team
  catalog repository, decoded strictly. A missing or invalid file means no
  voices, with the reason shown in Settings. There is no default voice.
- A model is one file from a Hugging Face URL pinned to a commit, installed
  only after its size and SHA-256 match. The runtime archive comes with the
  first model, is verified the same way, and is checked entry by entry before
  and after extraction into a staging folder.
- Synthesis runs in a child process with a minimal environment, one request at
  a time, killed when a request is cancelled and unloaded after ten idle
  minutes. Word timings are estimated from character counts and marked so.
- New HTTP group /api/voice-output: reading and speaking need the operate
  scope, changes need settings write. speak answers with a length-prefixed
  JSON header followed by 16-bit mono PCM.
- Client runtime calls, sentence splitting and word lookup; a Speech output
  section at the end of Settings -> Voice with download progress, samples and
  voice choice.

The native bindings are written from the runtime's C header and upstream's
pull request. No test loads the library: tests use a stand-in module in the
worker and a fixture archive.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The voice binding was written from the runtime's header and had never run
against the real library. Run in a Linux arm64 container with the pinned
runtime build and real models, the service's speak failed for most of them:

- The binding only streamed. Models that do not stream were refused at
  load, and models that return their audio only when the stream finishes
  gave "produced no audio". speak returns a sentence whole, so the binding
  now makes one offline run (audiocpp_session_run) and reads the result's
  audio. Every model checked speaks this way.
- The service sent every voice's id as the request option voice_id. A
  model with one built-in voice declares no such option, and some models
  refuse an option they do not declare. The voice id now travels beside
  the request options, and the binding sends it only to a model that
  declares voice_id.

The binding is tested with a stand-in for koffi: the offline call order,
the copy of the audio before the result is freed, the voice id rule, the
CPU fallback, and the runtime's error text.

Backwards compatible: no stored format or wire contract changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@cursor

cursor Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Introduces native library loading, verified downloads, and archive extraction in the server path, though guarded by strict catalog validation, scoped HTTP auth, and an isolated worker with a stripped environment.

Overview
Adds downloaded local text-to-speech alongside dictation: voice models come from the team catalog's voices/voices.json, the pinned audio.cpp runtime and GGUF weights are downloaded and checksum-verified into the existing speech model layout, and synthesis runs in an isolated child worker (koffi + minimal env) that returns 16-bit PCM with estimated word timings.

The server exposes a new /api/voice-output HTTP group (catalog, install lifecycle, voice selection, speak) with operate vs settings-write scopes; contracts and client-runtime ./voice-output add the wire format (length-prefixed JSON header + PCM) and sentence-by-sentence streaming. SpeechModelStore gains optional direct urls, basename installs, and support for runtime archives (.tar.gz/.zip).

Settings → Voice gets a Speech output section to download models, pick a voice, and play samples; docs and fork README describe the feature and upstream alignment (pingdotgg#35910).

Reviewed by Cursor Bugbot for commit 63d38f8. Bugbot is set up for automated code reviews on this repo. Configure here.

@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, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b5fd789. Configure here.

mfituri and others added 2 commits November 16, 2026 02:45
…test allows the tracer's names

A regular expression for sentence ends backtracked on a long run of
marks with no space after it. On Linux the test runner's file tracer
re-injects two environment names into every child process, which the
worker's minimal-environment test took for a leak.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mfituri
mfituri merged commit cb05d9d into main Nov 16, 2026
27 checks passed
@mfituri
mfituri deleted the mohammed/cod-120-the-voice-agent-speaks-with-downloaded branch November 16, 2026 02:56
mfituri added a commit that referenced this pull request Nov 18, 2026
…ads (#78)

* feat(server): an environment speaks with voice models the user downloads

A speaking agent needs raw audio and word timings, one sentence at a time.
Upstream's local read-aloud (pingdotgg#35910, still open) returns MP3
with no timings, so this adds a fork service on the same runtime, at the same
version, URLs, hashes and folders, to be folded into upstream's when it ships.

- The speech runtime is executable, so its builds are pinned in code by URL,
  size and SHA-256. The voice models are data: voices/voices.json in the team
  catalog repository, decoded strictly. A missing or invalid file means no
  voices, with the reason shown in Settings. There is no default voice.
- A model is one file from a Hugging Face URL pinned to a commit, installed
  only after its size and SHA-256 match. The runtime archive comes with the
  first model, is verified the same way, and is checked entry by entry before
  and after extraction into a staging folder.
- Synthesis runs in a child process with a minimal environment, one request at
  a time, killed when a request is cancelled and unloaded after ten idle
  minutes. Word timings are estimated from character counts and marked so.
- New HTTP group /api/voice-output: reading and speaking need the operate
  scope, changes need settings write. speak answers with a length-prefixed
  JSON header followed by 16-bit mono PCM.
- Client runtime calls, sentence splitting and word lookup; a Speech output
  section at the end of Settings -> Voice with download progress, samples and
  voice choice.

The native bindings are written from the runtime's C header and upstream's
pull request. No test loads the library: tests use a stand-in module in the
worker and a fixture archive.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* fix(server): downloaded voice models speak with one offline run

The voice binding was written from the runtime's header and had never run
against the real library. Run in a Linux arm64 container with the pinned
runtime build and real models, the service's speak failed for most of them:

- The binding only streamed. Models that do not stream were refused at
  load, and models that return their audio only when the stream finishes
  gave "produced no audio". speak returns a sentence whole, so the binding
  now makes one offline run (audiocpp_session_run) and reads the result's
  audio. Every model checked speaks this way.
- The service sent every voice's id as the request option voice_id. A
  model with one built-in voice declares no such option, and some models
  refuse an option they do not declare. The voice id now travels beside
  the request options, and the binding sends it only to a model that
  declares voice_id.

The binding is tested with a stand-in for koffi: the offline call order,
the copy of the audio before the result is freed, the voice id rule, the
CPU fallback, and the runtime's error text.

Backwards compatible: no stored format or wire contract changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* fix(client-runtime): sentences are found in one pass, and the worker test allows the tracer's names

A regular expression for sentence ends backtracked on a long run of
marks with no space after it. On Linux the test runner's file tracer
re-injects two environment names into every child process, which the
worker's minimal-environment test took for a leak.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* fix(web): a voice sample opens its audio inside the click

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
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.

2 participants