Compare commits

...
Author SHA1 Message Date
Palash Debnath 38c2405fa1 Merge pull request #2007 from debpalash/release/v0.5.2
docs(changelog): cut the 0.5.2 release section
2026-09-10 10:09:20 -07:00
Palash Debnath 97b153df3a test(changelog): count versions the way the app's changelog parser reads them
The one-section-per-version check matched raw heading text, so [v0.5.2]
and [0.5.2] would pass as two versions while core.changelog, which serves
the in-app notes, strips the v and whitespace and reads them as one. The
check now uses parse_changelog itself.
2026-09-10 09:47:54 -07:00
Palash Debnath 4e37e21745 chore(release): v0.5.2
Cut the Unreleased notes as 0.5.2 (2026-09-10) and fold in the untagged
0.5.2 section prepared on 2026-09-02, so release.yml publishes one
complete section. A test now requires one section per version.
2026-09-10 09:42:08 -07:00
Palash Debnath 3bfdeeddba Merge pull request #2024 from debpalash/fix/uv-no-app-config
fix(engines): engine installs never inherit VoiceStudio's own uv config
2026-09-10 09:42:02 -07:00
Palash Debnath ac35351000 Merge remote-tracking branch 'origin/main' into fix/uv-no-app-config
# Conflicts:
#	CHANGELOG.md
2026-09-10 09:11:59 -07:00
Palash Debnath 764fed09bc Merge pull request #2018 from debpalash/fix/license-reason-passthrough
fix(engines): say when a license or the platform is what blocks an engine
2026-09-10 09:04:07 -07:00
Palash Debnath 4fdde15079 Merge pull request #2023 from debpalash/fix/translation-uninstall-guard
fix(translation): uninstalling an engine never removes what others need
2026-09-10 09:00:07 -07:00
Palash Debnath 14a8a9cd46 docs(changelog): link the uv config entry to #2024 2026-09-10 08:46:57 -07:00
Palash Debnath 1af1ecc5bd fix(engines): engine installs never inherit VoiceStudio's own uv config
The backend runs inside the app's tree, and the uv processes it starts for
engine installs had no working directory of their own. uv therefore
discovered VoiceStudio's pyproject.toml and applied its [tool.uv]
constraint-dependencies, torch==2.8.0 among them, to each engine's venv.

Resolved that way, MOSS-TTS-v1.5 (torch==2.9.1+cu128) and Confucius4
(torch==2.7.0) are unsatisfiable, so their one-click installs and
bootstraps could never succeed. An engine that pins no torch got the app's
instead of its own, so its venv was not really independent.

uv_subprocess_env, which every one-click install step and every engine
bootstrap already uses, now always sets UV_NO_CONFIG=1. It used to return
None in two cases and let the call inherit the environment; it now always
returns a copy. Region and custom mirrors still apply, because they reach
uv as UV_INDEX_URL. The app's own `uv sync` and the translation installer,
which install into the app's environment on purpose, are unchanged.
2026-09-10 08:46:49 -07:00
Palash Debnath e0879027d5 Merge remote-tracking branch 'origin/main' into fix/license-reason-passthrough
# Conflicts:
#	CHANGELOG.md
#	tests/test_engine_unavailable_reason_1866.py
2026-09-10 08:41:45 -07:00
Palash Debnath 5298c8e5e1 Merge pull request #2016 from debpalash/feat/isolated-engine-installs
feat(engines): isolated one-click installs for five engines
2026-09-10 08:38:39 -07:00
Palash Debnath 1de4fedad7 docs(changelog): file the translation guard under Fixed, not Highlights 2026-09-10 08:33:55 -07:00
Palash Debnath c5f32d020a fix(translation): uninstalling an engine never removes what others need
The translation uninstall route runs `pip uninstall -y <package>` on the
app's own environment. Two entries made that break something else:

- The LLM engine's package is openai, a core dependency that Settings →
  LLM Providers also uses. Unlike Argos, it was not marked builtin, so
  uninstalling that engine removed it from the app.
- Google, DeepL, Microsoft and MyMemory share deep_translator. Uninstalling
  any one removed it for all four.

The route now asks uninstall_blocker() first. It refuses (400) a package
VoiceStudio itself depends on, read from the installed package metadata so
there is no second list to keep in step, and refuses (409) a package
another engine shares, naming the engines that would stop working. The
openai entry is marked builtin as well, and a test requires every entry
backed by an app dependency to be.
2026-09-10 08:26:53 -07:00
Palash Debnath f5ea363724 fix(engines): name the missing MPS on Apple Silicon, and hold the MLX test on every host
mlx_supported() fails three ways. Only the non-Apple branch is a platform
gap; Apple Silicon whose PyTorch cannot use MPS was left on the generic
line, and the live-host test asserted a platform reason even there, so it
would fail on such a Mac. That case now has its own owned sentence, and
the live test asserts only the branch its host can produce, with literal
cases covering the rest on every machine.
2026-09-10 08:22:20 -07:00
Palash Debnath ae68dd5bfd fix(engines): a half-finished install is repaired, not reported installed
An engine with no weights download counted as installed once its venv
interpreter existed, so a dependency install that died halfway made the
next attempt answer already_installed and the engine failed at its first
import. The import probe now writes a completion marker, and a fresh
dependency step removes the old one. IndexTTS keeps its weights check, so
no existing install is asked to reinstall.

The MOSS bootstrap no longer blames a non-CUDA host for an install
failure; the index is always supplied, and uv's error says what failed.
The PocketTTS and Supertonic guides now say where the sidecar runs, and
the three repository-engine guides say what to do if the first weight
download outlasts the compute-time budget.
2026-09-10 08:12:17 -07:00
Palash Debnath 2fd4cb3caf test(engines): cover dots.tts's own Windows reason in the platform category 2026-09-10 07:53:10 -07:00
Palash Debnath e532c9d8dd fix(engines): say when an engine can't run on this platform
The public reason sanitizer had no category for a host the engine cannot
run on at all, the same gap that hid the license button. "MLX requires
Apple Silicon" and PocketTTS's Intel-Mac reason became the generic
"check installation" line, and "not supported on this platform" became
"isn't installed yet", which an existing test asserted. Each sent people
after an install that could never work.

A platform category, matched after the license and before the install
and file checks, now says the engine doesn't run on this platform and
points at its guide. mlx-audio's "Apple Silicon only" wording is left
out of the markers: it also appears on an M-series Mac when the package
is simply missing, where installing does help.
2026-09-10 07:52:46 -07:00
Palash Debnath 5516750a4f fix(engines): accept Confucius4's requirements.txt-only source layout
Source validation demanded a pyproject.toml in every checkout, and
Confucius4 ships none, so its install could never get past fetching the
source. The manifest file is now per spec. The regression test fabricates
each pinned upstream's real root files.
2026-09-10 07:48:52 -07:00
Palash Debnath c079b721ed feat(engines): Supertonic-3 and PocketTTS install into their own venvs
Both engines ran with the app's interpreter, installed as optional extras
into the app's own environment (`uv sync --extra`). They now get one-click
installs like the sidecar engines: a PyPI-only spec (no source to fetch)
creates DATA_DIR/engines/<id>/.venv and installs the app's own pinned wheel
there, so nothing they install can touch the app or another engine.

Each engine prefers its own venv and falls back to the app's interpreter,
so an existing `uv sync --extra` install keeps working and is never
provisioned over: the spec counts a package found in the app environment
as installed.

PocketTTS installs from PyTorch's CPU index: it never uses a GPU, and
PyPI's Linux torch pulls ~15 NVIDIA packages. It stays unoffered on Intel
Macs, where no usable torch exists.

Supertonic's sidecar loads its constants by path when the revision env var
is absent, instead of importing the engines package, whose __init__
imports the app backend that its own venv does not have.

The Install button is hidden once only the license review stands between
the user and the engine. The installer tests' autouse fixture now removes
every spec's env var on teardown: a bare delenv of an unset var restored
nothing, and a persisted path leaked into later suites.
2026-09-10 07:44:42 -07:00
Palash Debnath 664c9ea4b5 fix(engines): keep the license reason so Supertonic-3 and PocketTTS can be enabled
The Model Catalogue shows an engine's license Accept button only when its
reason matches /license not accepted/i. public_backends() replaces probe
text with owned sentences, and no category covered a license gate, so the
reason arrived as the generic "Engine unavailable" line and the only way
to enable Supertonic-3 or PocketTTS never rendered (#2017).

A license category, matched first, keeps those words. The test reads the
regex out of EngineCompatibilityMatrix.jsx, so a wording change on either
side fails CI instead of silently hiding the button.
2026-09-10 07:34:06 -07:00
Palash Debnath faa3d39836 feat(engines): isolated one-click installs for MOSS-TTS-v1.5, Confucius4 and dots.tts
Three engines that shipped as terminal-only setups now install from Model
Catalogue → Engines with the existing sidecar installer, which is
generalised to take a per-engine venv interpreter, install target, import
probe and host gate.

Each engine gets DATA_DIR/engines/<id>/ with its own checkout and .venv;
every uv pip install passes --python for that venv, never the app's
interpreter. Switching the active engine only changes a pref, so moving
between engines and back cannot corrupt a working one, and uninstalling one
removes only its own folder. Tests pin both invariants for every spec.

MOSS-TTS-v1.5's [torch-runtime] extra pins torch==2.9.1+cu128, which exists
only on PyTorch's index, so its manual install and its bootstrap could never
resolve (#2015). core.torch_indexes defines the index once for the
installer and the bootstrap, and a test ties it to the app's own
pytorch-cuda index.

Install buttons appear only where the install can work: MOSS on CUDA hosts,
dots.tts off Windows (upstream publishes no Windows install). A direct POST
on an unsupported host gets a 409 with the reason. An engine with no
one-click install now points at its guide, not at a page with no Install
button.
2026-09-10 07:28:42 -07:00
Palash Debnath b0cae840c4 Merge pull request #2010 from debpalash/fix/pill-visibility-desync
fix(dictation): pill window, card and stale model on Windows (#2009, #2012)
2026-09-10 07:18:22 -07:00
Palash Debnath 566aad7bba fix(dictation): mirror the widget's shadow setting in the macOS overlay
Tauri applies platform config as a JSON Merge Patch, so the windows array in
tauri.macos.conf.json REPLACES the base one rather than merging window objects.
desktopWindowConfig.test.js pins that every base window property survives on
macOS, and it caught the base gaining "shadow": false without the overlay.

The programmatic builder already sets shadow(false) on every platform; this
keeps the macOS declaration in step with it. The Linux and Windows overlays
declare no widget window, so the base entry applies there unchanged.
2026-09-10 06:53:49 -07:00
Palash Debnath e9965b2cb4 fix(dictation): never show the pill natively when Tauri's show fails
Greptile on #2010: if win.show() fails while hwnd() succeeds, the native
SW_SHOWNOACTIVATE show still ran, putting an always-on-top window on screen
that Tauri believes is hidden. dismiss() and the idle reconcile then cannot
remove it — the stranded-window bug this PR fixes, reached by a different
door.

The previous commit degraded to the native show on purpose, reasoning that a
visible pill beats none. That was the wrong trade: the tray's red dot already
tells the user they are being recorded, while an unhidable always-on-top window
is left behind for the rest of the session. The native show now runs only
after Tauri's show has succeeded, and the test that pinned the fallback is
flipped to pin its absence.
2026-09-10 06:36:06 -07:00
Palash Debnath 52887ae44d fix(dictation): no card around the pill, and the pill uses your model (#2009, #2012)
Two more defects from the same live report.

The card. Tauri's default window shadow on Windows gives an undecorated
window a 1px white border and, on Windows 11, rounded corners — drawn around
the whole 460x164 pill window, which is far wider than the pill (at most
284px). That is the bordered card framing empty space, visible whether or not
the pill is showing. The widget window now sets shadow(false), in the builder
and in its tauri.conf.json declaration; the capsule draws its own edge in CSS.

The stale model (#2012). The pill runs in its own window with its own store,
created at app start, usually before the backend listens. CaptureWidget
hydrated the dictation prefs once and memoized the promise whether or not the
load worked, and loadDictationPrefs swallowed the failure and marked itself
loaded. So the widget kept the store's seed, sherpa-whisper-tiny, for the
session. The main window checked the model actually picked (Parakeet,
installed) and said ready; the widget asked the server for the seed, and the
server correctly answered that it was not installed.

loadDictationPrefs now reports whether the backend answered. Only a successful
load is kept; a failed one is retried, and a capture start re-reads so a model
chosen in the main window reaches the widget. An in-flight load is shared.

On the same path, the missing-model install toast was called from the widget,
whose window has no <Toaster> in the desktop app, so it rendered nowhere. The
install recommendation now rides the dictation notice to the main window,
which shows the one-click download. The browser build, where the widget lives
inside the main window, keeps its local toast. The pill labels a missing model
as that rather than "Transcription failed: ...", and clamps error text to two
lines instead of spilling a paragraph past the capsule.

Tests: a failed first load is retried instead of pinning the seed, and a model
changed elsewhere is picked up at the next capture — both fail against main's
widget. The notice routes a missing model to the install toast. The
setup-race test now asserts no local toast in Tauri and the notice payload
instead. 91 frontend tests and 256 Rust lib tests pass; typecheck:ci passes.
2026-09-10 06:34:26 -07:00
Palash Debnath b0f1558db0 fix(dictation): tell Tauri the pill is visible, not just Windows (#2009)
Closing the dictation pill on Windows left an empty dark rectangle on screen,
always on top, removable only by quitting the app.

show_pill_noactivate called the raw Win32 ShowWindow(hwnd, SW_SHOWNOACTIVATE)
and never Tauri's own win.show(). The flag is there for a good reason (#982: a
pill that takes foreground makes the dictated text paste into the pill instead
of the user's document), but going straight to Win32 puts the window on screen
behind Tauri's back. Tauri went on believing it was hidden, and every mechanism
that could have removed it was disabled by that one desync:

  - isVisible() answered false while the user was looking at the window;
  - hide() was a no-op on a window Tauri thought was already hidden, so
    dismiss() in CaptureWidget could not remove it;
  - the idle reconcile — the backstop that exists precisely to clean up a
    stranded pill — asks isVisible() first, and concluded there was nothing
    to clean up.

win.show() now runs first, then the native flag. The no-activation behaviour is
carried by the WS_EX_NOACTIVATE style bit that mark_pill_noactivate applies at
creation, which is what makes the Tauri show safe: the style bit, not the show
flag, is what refuses activation. The flag stays as a second line of defence,
since hwnd() can fail and the bit might not have been applied.

Windows only. macOS and Linux already took the win.show() branch.

The ordering is now a function with both shows as parameters, so two tests can
pin it: Tauri's show runs and runs first, and a failing Tauri show still puts
the pill on screen — degrading to the old behaviour beats not showing the user
that they are being recorded.

256 Rust lib tests green; the 10 stranded-pill frontend tests unchanged and
still passing.
2026-09-10 05:57:22 -07:00
Palash Debnath dea884a22d Merge pull request #2006 from debpalash/fix/worker-artifact-id-posix
fix(worker): identify a staged input the same way on every OS (#2005)
2026-09-10 05:31:39 -07:00
Palash Debnath bee9fa25ff Merge remote-tracking branch 'origin/main' into fix/worker-artifact-id-posix
# Conflicts:
#	CHANGELOG.md
2026-09-10 05:02:02 -07:00
Palash Debnath 06c15ce37f fix(worker): identify a staged input the same way on every OS (#2005)
A staged task input's artifact id was built with os.path.join, so a Windows
control plane produced `inputs\<sha256>.wav`. That id is not a local path. It
is persisted into remote_tasks.params_json, shipped to remote workers over
gRPC as the identifier for the input they must fetch, and compared against a
later disk sweep to decide whether a staged file is still referenced.

So a Windows host hands a Linux worker `inputs\abc.wav`, where the backslash is
an ordinary filename character and no such file exists. Remote GPU workers are
a shipped feature; this broke them for every Windows control plane. The same
ids also stop matching when an omnivoice_data/ directory moves between
operating systems.

artifact_id_for() makes it canonical POSIX — resolve_within already treats both
separators as structural, so resolution is unchanged. normalize_artifact_id()
covers the upgrade: rows written by the old code carry a backslash, and the
sweeper decides "unreferenced" by comparing ids, so without it an upgraded
install reads every legacy row as garbage and deletes inputs that surviving
tasks still point at.

Two other tests in this run asserted POSIX-only behaviour rather than product
behaviour, and are corrected here too:

  - the durability-barrier test required a directory fsync, which
    _fsync_parent_directory deliberately skips without os.O_DIRECTORY. It now
    gates on that same attribute rather than on the OS name, so the test and
    the code it checks cannot drift apart.
  - the read-only-cache test built its scenario with chmod(0o500), which on
    Windows only toggles a read-only FILE attribute and does not stop a file
    being created inside the directory. It verifies its premise by probing and
    skips when the host writes anyway — which also covers root and anything
    holding CAP_DAC_OVERRIDE, replacing a geteuid check that named only one of
    them.

Then the reason none of this was visible: CI runs tests/ on Linux only. The two
worker suites join the existing Windows step in the smoke matrix. They need no
ffmpeg, so they cost seconds. Verified green on Windows first — 244 tests
across the four suites in that step.

Fails before, passes after, both directions: a staged id containing a
backslash, and a legacy-id input deleted by the sweeper.
2026-09-10 04:51:36 -07:00
Palash Debnath bb9149ce1f Merge pull request #2004 from debpalash/fix/grpc-loop-budget
test(worker): size the loop-responsiveness budget against what it measures
2026-09-10 04:40:54 -07:00
Palash Debnath 4c10e802ab test(worker): size the loop-responsiveness budget against what it measures
main is red. Smoke (Windows) failed on
test_upload_durability_barrier_does_not_block_the_grpc_loop with

    assert 0.20299999999997453 < 0.2

Three milliseconds of scheduling noise on a shared runner, and a red build
that says nothing about the product.

The three tests here prove a blocking filesystem call does NOT stall the gRPC
event loop: they park the call on a barrier and check the loop still ran their
own coroutine promptly. That is a wall clock on shared hardware, so the two
numbers have to be chosen against each other. The discriminator was a 0.5 s
watchdog — a stalled loop could not proceed until it fired — while the budget
sat at 0.2 s. Responsive measured ~0.2. The line was drawn exactly where the
noise lives.

Both numbers are named constants now, with the reasoning next to them:
a 1.5 s hold, a 0.75 s budget. Responsive lands near 0.2, stalled lands at 1.5,
and the line sits between them with room on both sides. The waiter's own cap
moved above the hold too, so a genuinely stalled loop is reported by the budget
assertion that names the problem rather than by a bare TimeoutError.

Verified the assertion is still worth having: with the blocking call made to
stall the loop for real, the test fails. It is a wider net, not a hole.

55 tests in the file, three runs in a row.
2026-09-10 04:15:06 -07:00
Palash Debnath c021fac1d8 Merge pull request #2003 from debpalash/land/2002-inert-badge
feat(pronunciation): badge a stored-but-inert entry in the list (#1949)
2026-09-10 04:05:28 -07:00
Palash Debnath 24e0737e0d fix(pronunciation): badge only the entries the backend calls inert
Both review bots found the same thing independently: `e.type !== 'respelling'`
badged rows the user had switched OFF. A disabled entry is indeed not applied,
but for a reason the toggle already shows — labelling it "not applied yet"
reads as a defect rather than their own choice. `inert_entries_for_language`
excludes disabled rows for exactly that reason, so the badge now matches it.

Not taken: the suggestion to name `ipa` and `cmu` explicitly instead of testing
against respelling. The backend's rule is that everything which is not
respelling is inert today, and mirroring it keeps the two in step. An explicit
list would silently stop badging a notation added later — an entry that saves,
validates, toggles on and quietly does nothing, which is the invisibility #1949
exists to remove. A test pins that direction with an unfamiliar type.

Two tests, one per direction. The disabled case fails without the enabled gate.
2860 vitest tests green.
2026-09-10 03:38:44 -07:00
Palash Debnath 06f7c4af7b feat(pronunciation): badge a stored-but-inert entry in the list (#1949)
Takes the part of #2002 by @utkarsha741 that #1984 did not already cover.

An IPA or CMU row saves, validates and toggles on, and is then dropped before
term matching — Phase 1 only substitutes respelling. #1984 made that visible in
the "Test a sentence" preview, which the user sees only if they run a test. The
entry LIST is where they look at what they have saved, and there it still
looked like every other working row.

So the row carries the same fact: a warning badge next to the type and scope
badges, on IPA and CMU only. Badging a respelling row would be the opposite
lie — those do take effect.

The rest of #2002 is already on main under a different name: it re-added the
backend skip detection and the test-preview line as `skipped_terms`, where
`inert_entries_for_language` and `inert_entries` have shipped since #1984.
Landing that half would have been a second implementation of one behaviour with
two response fields for it.

String added to all 21 locales, not just en, so the badge is not an English
island in a translated panel. Fails before, passes after: with the badge
condition disabled the new test cannot find it. 2858 vitest tests, 529 locale
and CJK guard tests green.
2026-09-10 03:26:44 -07:00
Palash Debnath c9a587ea75 Merge pull request #2000 from debpalash/land/1998-powershell-key
docs(docker): make the PowerShell key URL-safe too (#1998)
2026-09-10 03:21:39 -07:00
Palash Debnath cef2b73e02 Merge remote-tracking branch 'origin/main' into land/1998-powershell-key 2026-09-10 02:52:35 -07:00
Palash Debnath 50b1184df3 Merge pull request #1996 from debpalash/fix/1933-port-holder
fix(backend): name who actually holds port 3900 (#1933)
2026-09-10 02:52:16 -07:00
Palash Debnath c48e8c4ff5 Merge remote-tracking branch 'origin/main' into land/1998-powershell-key 2026-09-10 02:22:57 -07:00
Palash Debnath 0c9f1bd7c4 Merge remote-tracking branch 'origin/main' into fix/1933-port-holder
# Conflicts:
#	CHANGELOG.md
2026-09-10 02:22:49 -07:00
Palash Debnath b6a0f96e90 Merge pull request #1992 from debpalash/fix/1900-attempt-id
fix(bootstrap): emit an attempt id so the splash stops guessing (#1900)
2026-09-10 02:22:28 -07:00
Palash Debnath 93771a0201 Merge pull request #2001 from debpalash/fix/worker-barrier-flake
test(worker): stop spinning the loop the awaited work needs
2026-09-10 02:22:22 -07:00
Palash Debnath a4f87bad6e Merge remote-tracking branch 'origin/main' into fix/1933-port-holder
# Conflicts:
#	CHANGELOG.md
#	frontend/src-tauri/src/backend.rs
2026-09-10 01:53:46 -07:00
Palash Debnath 703c665c6c Merge remote-tracking branch 'origin/main' into fix/worker-barrier-flake 2026-09-10 01:52:50 -07:00
Palash Debnath f301db1b02 Merge remote-tracking branch 'origin/main' into land/1998-powershell-key 2026-09-10 01:52:41 -07:00
Palash Debnath c90d32845a Merge remote-tracking branch 'origin/main' into fix/1900-attempt-id
# Conflicts:
#	CHANGELOG.md
2026-09-10 01:52:33 -07:00
Palash Debnath 9a7f5fd7ed Merge pull request #1994 from debpalash/fix/1850-crash-tail
fix(crash): capture the dying backend's last words, not the log so far (#1850)
2026-09-10 01:52:06 -07:00
Palash DebnathandClaude Opus 5 25393b4654 test(worker): stop spinning the loop the awaited work needs
Smoke (Windows) fails intermittently in
test_revocation_during_result_barrier_cannot_ack_published_bytes with a bare
TimeoutError. It hit two PRs in a row today, one of them documentation-only,
which rules out any change under review.

The wait is a busy loop:

    while not barrier_finished.is_set():
        await asyncio.sleep(0)

asyncio.sleep(0) yields to the loop but never sleeps, so this runs the loop
flat out on the one thread the upload task also needs to reach
_durable_replace and set the event. On a loaded Windows runner the waiter
starves the worker it is waiting for, and the 1 s cap fires with nothing
actually wrong — a failure with no signal in it, which is worse than no test.

_await_event parks the wait on a worker thread with asyncio.to_thread, leaving
the loop free. Deterministic, and faster: the test drops from a full second of
spinning to the time the work actually takes.

Deliberately narrow. The other spin-waits in this file sit inside
"assert elapsed < 0.2" blocks that exist to prove the gRPC loop stayed
RESPONSIVE during a blocking call — spinning is the measurement there, and
converting them would delete the assertion's meaning.

123 tests across both worker files pass; the target test passes three runs in
a row.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-10 01:42:15 -07:00
Palash DebnathandClaude Opus 5 e11270990b fix(backend): identify the port holder by the marker header, not a body sniff
CodeRabbit: running_backend_version accepts a /system/info body that merely
CONTAINS "model_checkpoint" or "data_dir". That is a substring sniff, and it is
fine for the decision it was written for — whether to attach to a healthy
same-version backend. It is not fine for this one, which ends in a message
naming a process for the user to kill. Any service can serve that body.

port_holder now requires the x-omnivoice-backend header that backend/main.py
stamps on every response, the same gate startup_progress already applies for
the same reason: a foreign process on our port must not narrate our UI, and it
certainly must not be the thing we point a user's kill command at. Unmarked
means Foreign, which keeps the conservative wording and offers no command.

Two tests against a real one-shot loopback responder: a spoofed body with no
marker is Foreign and gets no terminal command, and the marker is what makes a
responder ours. The first fails with the header check disabled.

244 lib tests green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-10 01:13:28 -07:00
Palash DebnathandClaude Opus 5 f21ad9a27d fix(crash): close the far end of a dead run's slice, and settle one at a time
Two more review findings, both real.

CodeRabbit: pinning the START of the dying run's slice was only half the fix. A
start with an unbounded end still does not identify one run — the replacement
writes BELOW those lines, and a tail reads the last N of the file, so the newer
run's healthy startup is exactly what the dead run's crash marker would get.
read_dead_run_tail closes the range: it is called after the settle, and takes
the end from wherever the current run now begins, which is either still the
pinned start (nothing replaced it) or the replacement's own offset — precisely
where this run's slice ends. An end that is not a usable boundary degrades to
the rest of the file, matching how an unusable start already degrades.

CodeRabbit: settle_err_log moved every handle out of the list and then waited
without that lock, so two callers could interleave — the second found an empty
list, concluded there was nothing to wait for, and read the log while the first
was still waiting for exactly the drainer it needed. A settlement lock makes
each caller's return mean the waiting is genuinely done.

Two tests: a dead run's slice stops where the replacement begins (and the
unbounded read really does return the newer run, so the assertion is not
vacuous), and an unusable end degrades rather than capturing nothing.

241 lib tests green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-10 01:11:46 -07:00
Palash Debnath fc45ec3b5b Merge remote-tracking branch 'origin/main' into land/1998-powershell-key 2026-09-10 01:08:11 -07:00
Palash Debnath 1eda03827d Merge remote-tracking branch 'origin/main' into fix/1900-attempt-id 2026-09-10 01:08:03 -07:00
Palash Debnath 555210bbdb Merge remote-tracking branch 'origin/main' into fix/1933-port-holder 2026-09-10 01:07:55 -07:00
Palash Debnath 78d6dbe802 Merge remote-tracking branch 'origin/main' into fix/1850-crash-tail 2026-09-10 01:07:46 -07:00
Palash Debnath e3efe4a39a Merge pull request #1999 from debpalash/fix/windows-backend-tests
test: make the isolated backend session pass on Windows, and gate it there
2026-09-10 01:07:27 -07:00
Palash DebnathandClaude Opus 5 36a9515320 docs(docker): make the PowerShell key URL-safe too
Lands #1998 by @yangfan-yf-yf. Correct finding: the PowerShell example I added
in #1993 generated the administrator key with `python -c`, and the whole point
of the Docker path is that the host does not need Python. On a Windows host
without it, the very first line of the setup fails.

One thing on top. The key is also accepted as an `?api_key=` query parameter
(core/auth.py), and raw Base64 carries `+`, `/` and `=`. A `+` in a query
string decodes to a space, so a user who pasted such a key into a URL would get
a silent mismatch with nothing to explain it. The Bash line next to it uses
`secrets.token_urlsafe` and never had this shape, so the two now agree:
trim the padding, map `+` to `-` and `/` to `_`.

Verified in Windows PowerShell 5.1 (5.1.26100): the block parses and runs, and
the key is 43 URL-safe characters — the same shape `secrets.token_urlsafe(32)`
produces. validate-install-docs.py and both docker/changelog test files pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-10 01:00:14 -07:00
Palash Debnath 9618f26f6e Merge remote-tracking branch 'origin/main' into fix/1900-attempt-id
# Conflicts:
#	CHANGELOG.md
2026-09-10 00:58:27 -07:00
Palash Debnath 9e12c7b181 Merge remote-tracking branch 'origin/main' into fix/1933-port-holder
# Conflicts:
#	CHANGELOG.md
2026-09-10 00:58:18 -07:00
Palash Debnath baaef34a4a Merge remote-tracking branch 'origin/main' into fix/1850-crash-tail
# Conflicts:
#	CHANGELOG.md
2026-09-10 00:58:09 -07:00
Palash Debnath 5b842280c8 Merge pull request #1997 from debpalash/fix/1931-blackwell-docs
docs+test: finish the RTX 50-series story (#1931)
2026-09-10 00:56:32 -07:00
Palash DebnathandClaude Opus 5 9d71c7cedd test: pin the port diagnosis to the matcher, not to one sentence
The backend-lifecycle harness asserted a literal — "is already in use, so the
backend could not" — while its own comment said the point was "the exact
phrasing BootstrapSplash.detectHints localizes". Those are not the same thing,
and the gap showed: rewording the message by who actually holds the port kept
the matcher firing and still failed the test.

It now asserts the real contract, the same one the Rust unit tests pin: the
message mentions a port, says it is in use after that, and names the port
number. Any wording that satisfies detectHints satisfies this; any that does
not, fails — which is the failure worth catching, because it silently costs
the user the localised hint.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-10 00:45:34 -07:00
Palash Debnath 770fe35da9 Merge pull request #1995 from debpalash/fix/1927-crash-hint
fix(crash): say what the exit code means in the crash details (#1927)
2026-09-10 00:36:16 -07:00
Palash DebnathandClaude Opus 5 db48c7851c test: make the isolated backend session pass on Windows, and gate it there
Four tests in backend/tests/ cannot pass on a stock Windows checkout. The
`test` job runs that session on Linux only, so all four were invisible to CI
and hit every Windows contributor on their first `pytest` run — with failures
that have nothing to do with whatever they changed. Same class as #1990.

  - test_contained_subprocess_waitid_fallback.py simulates macOS by deleting
    os.waitid, then drives the fallback with os.waitpid/os.WNOHANG and
    start_new_session. Windows has none of those; os.WNOHANG is an
    AttributeError before the first assertion. The module is POSIX-only by
    premise, so it says so.
  - test_invalid_or_missing_desktop_drain_fd_fails_safe asserts a RuntimeError
    that cannot be raised off POSIX: backend_drain_fd returns None there before
    it reads the environment. The file already had this skipif on its sibling.
  - test_mps_proxy_survives_fatal_child_exit_and_recovers raced the OS. The
    child calls os._exit and the parent raises the moment its pipe hits EOF —
    before the process is reaped. Asserting poll() on the next line is a race
    Linux won and Windows lost every time. It waits for the death now, which is
    what the test actually claims.

Then the reason all four survived: nothing runs this session on Windows. The
smoke matrix already does a full `uv sync` there, so the session costs forty
seconds and now runs as a step in it. Verified green on Windows before adding
the gate — 355 passed, 8 skipped — so this cannot break main.

Kept to Windows deliberately: that is the platform I can verify here, and a
gate added blind on macOS would be a guess about a host I cannot run.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-10 00:34:58 -07:00
Palash DebnathandClaude Opus 5 512c2fa7d6 fix(bootstrap): bind the attempt id to the work it labels
Four review findings on the attempt id, all real.

Greptile, P1 — the status snapshot could mismatch. The bump and the stage write
were separate, so a restart landing between them returned the PREVIOUS attempt's
stage stamped with the new attempt's id: the splash then recorded
`installing_deps` as work this attempt did, which is precisely the #1894
fabrication the id exists to remove. `begin_attempt_with` now takes the stage
lock across both writes, and `bootstrap_status` reads stage and attempt under
that same lock. The pair a reader observes is always self-consistent.

CodeRabbit, major — an output pump is a thread reading a pipe, and it outlives
the run it drains. It stamped each line with the counter's value at read time,
so a restart relabelled the dying run's trailing output as the new attempt's
evidence. `emit_log_for_attempt` takes the attempt explicitly, and all four
pumps (the backend's stdout and stderr, and both sides of `run_streaming`)
capture theirs when they start. Every other call site runs inside the attempt
it describes and keeps reading the counter.

CodeRabbit, minor — the tests that advance the process-global counter raced
each other under cargo's threaded runner, so one could read a value another had
just moved. They serialize on a lock now, like the env-var tests above them.

CodeRabbit, minor — the backfill-to-live seam deduplicated on stage plus text,
and installer output repeats itself constantly. Across a restart that is not a
replayed line, it is the new attempt's own evidence, and dropping it can remove
the only proof for a stage the poll never samples. The attempt is part of the
identity now.

Two new tests: a new attempt never carries the previous stage, and a repeated
line belonging to a different attempt is kept. The second fails against the
previous dedup key. 241 Rust lib tests and 2853 vitest tests green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-10 00:15:33 -07:00
Yang Fan 55e6d9a07b docs(docker): generate PowerShell keys without Python 2026-09-10 15:14:00 +08:00
Palash DebnathandClaude Opus 5 192c1f5127 fix(crash): pin the run slice before settling, and keep every drainer
Two review findings on the settle, both real.

Greptile, P1: settling can take up to two seconds, and a Retry arriving in that
window installs a new run and moves ERR_LOG_RUN_START past the dying run's
output. Reading "the current run" after the wait would then hand the dead
process's crash marker the REPLACEMENT's healthy startup — the cross-run
attribution #1510 exists to prevent, reintroduced through the wait added to fix
the tail. Every death path now pins the offset BEFORE settling and reads from
it, via read_error_log_tail_from.

CodeRabbit: a single drainer slot loses a timed-out handle the moment a new run
installs its own. Dropping a JoinHandle detaches the thread, so nothing can
ever wait for that run's output again and both guarantees quietly stop holding.
The slot becomes a list: a settle drains it, joins what finished, and puts back
what is still running, ahead of anything a concurrent spawn pushed.

Two tests: a pinned offset still names the dying run's slice after a respawn
moved the current one, and an unfinished drainer survives another run
installing its own. 239 lib tests green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-10 00:10:53 -07:00
Palash DebnathandClaude Opus 5 7610a0d86e fix(backend): show the listener before ending it, never a blind kill
Greptile, security, on the reclaim guidance: the convenient one-liner does not
preserve the identity port_holder established.

  - `lsof -ti tcp:3900` matches CONNECTED CLIENTS as well as the listener, so
    piping it into kill can end a process that merely talks to VoiceStudio.
  - Windows `findstr :3900` matches `:39001` and established connections too.

And the identity itself is a fact about the moment the message was written. By
the time a user runs a command it has to be re-established, and only they can
do that.

So both platforms now get two steps: a lookup restricted to the LISTENING
socket that prints the pid and process name, and a kill of that pid once the
user has confirmed what it is. A test pins that the guidance never pipes a
lookup into kill and always shows something to confirm.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-10 00:08:22 -07:00
Palash Debnath 2afea02c94 Merge remote-tracking branch 'origin/main' into fix/1933-port-holder
# Conflicts:
#	CHANGELOG.md
2026-09-10 00:05:45 -07:00
Palash Debnath 46b1fb2f57 Merge remote-tracking branch 'origin/main' into fix/1927-crash-hint
# Conflicts:
#	CHANGELOG.md
2026-09-10 00:05:39 -07:00
Palash Debnath ac427fb821 Merge remote-tracking branch 'origin/main' into fix/1850-crash-tail
# Conflicts:
#	CHANGELOG.md
2026-09-10 00:05:35 -07:00
Palash Debnath 924172e012 Merge pull request #1986 from debpalash/fix/1960-name-the-language
fix(dub): name the source language code that was rejected
2026-09-10 00:04:53 -07:00
Palash DebnathandClaude Opus 5 14d6b90836 docs+test: finish the RTX 50-series story (#1931)
The code half of #1931 landed already: `torchaudio.set_audio_backend()` is
guarded, so the torch 2.9.x upgrade a Blackwell card needs no longer trades one
`ml_imports` crash for another. Two things were still missing.

The changelog said the upgrade was documented. It was not — nothing in docs/
mentions sm_120, Blackwell, or the 50-series at all, so a user hitting a native
access violation inside `import torch` had the issue thread and nothing else.
troubleshooting.md now carries it: why the pinned torch 2.8.0 cannot work
(no sm_120 kernels in the wheel — not a setting, not a workaround), the trio
that has to move together, the verification command that proves the kernels
arrived, and the fact that the change is to the repo's own pins so a later pull
will undo it.

The part most likely to be missed is that there are TWO pin lists.
`constraint-dependencies` governs `uv sync`/`uv lock`/`uv run`;
deploy/torch-constraints.txt governs the `uv pip install` paths, which ignore
project-level uv settings. Editing one leaves the other behind, which is what
`RuntimeError: operator torchvision::nms does not exist` looks like from the
outside. Both are named.

The second gap: nothing protected the guard. CI runs the pinned torch 2.8.0,
where `set_audio_backend` still exists, so deleting the `hasattr` as a
"simplify this no-op" cleanup would pass every test in the suite and restore a
hard startup crash for every RTX 50-series user. tests/ now walks the backend
AST and fails on any reach for a torchaudio API that 2.9 removed unless
something proves it is there — a `hasattr`/`getattr` check or a `try`. Fails
with the guard removed, passes with it.

Not addressed here, because it is already fixed: the reporter's third
observation, that launching through the desktop shell hung inside `import
torch`'s native init, is the OpenBLAS/stdin-pipe deadlock closed under #1952.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-10 00:03:56 -07:00
Palash Debnath 2cde7663a1 Merge remote-tracking branch 'origin/main' into fix/1900-attempt-id
# Conflicts:
#	CHANGELOG.md
2026-09-10 00:00:42 -07:00
Palash Debnath 2bf922d9e5 Merge pull request #1993 from debpalash/land/1987-followup
docs(docker): finish the ARM64 Compose guidance (#1987)
2026-09-10 00:00:11 -07:00
Palash Debnath d52a4c89a7 Merge pull request #1991 from debpalash/fix/windows-symlink-tests
test: let a stock Windows checkout run the symlink tests (#1990)
2026-09-09 23:59:58 -07:00
Palash DebnathandClaude Opus 5 6be80a4b3d fix(backend): name who actually holds port 3900 (#1933)
The port-conflict failure asserted "already in use by another application"
without ever asking who held the port. In the reports behind #1933 (and its
duplicates #1935, #1936, #1937 — same machine, same 45-minute window) the
holder was the user's OWN orphaned backend from an earlier run. So the app
told them to quit a copy of VoiceStudio that has no window, and there was no
action in the message that could have worked.

@Chang-Jin-Lee diagnosed this precisely on #1936, including the observation
that the identity check already exists: `running_backend_version(port)` asks
`/system/info` who is there, and is already trusted for the more consequential
decision of whether to attach to a healthy same-version backend. It simply was
not consulted on this path.

So it is now. `port_holder()` returns one of three answers, and
`port_conflict_message()` words the failure from it:

  - our own backend at this version (or one too old to report one) — say so,
    say it has no window to quit, and give the terminal command that ends it;
  - our own backend at a different version — name the version, which is what
    identifies it, and give the same command;
  - anything else — the existing wording, now actually justified.

The terminal command is only ever offered for a listener that identified
itself as ours. An unidentified one keeps the conservative wording: a user must
never be told to go kill a process that may not be theirs. A listener that
accepts a connection but does not answer `/system/info` counts as
unidentified, which is the reading that cannot do harm.

All three sites that reported this — take-ownership, respawn, and the
early-exit path on EXIT_PORT_IN_USE — go through the one builder now.

What is deliberately unchanged: `kill_orphan_on_port` still refuses to signal
a PID discovered through lsof/netstat. That refusal is correct — the reuse race
is real, and a matching foreign service must never be terminated. This changes
what the user is told, not what the app is willing to kill.

Five Rust tests, one per branch plus the suffix behaviour, and one that pins
every wording against the `detectHints` matcher — that regex is what turns
these English strings into the localised `bootstrap.hint_port`, and an earlier
draft of one message silently lost the translation by saying "is held by". The
frontend test that pinned the old literals now pins the new ones.

241 Rust lib tests and 2851 vitest tests green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 23:59:09 -07:00
Palash DebnathandClaude Opus 5 f67e5da289 fix(crash): say what the exit code means in the crash details (#1927)
The report in #1927 is a Windows access violation 13 seconds after "Loading
VoiceStudio model on device: cuda" — a native fault inside the compute stack,
which produces no Python traceback because the process is executing bad machine
code. What the user was shown was "Backend died (exit code -1073741819)", a
timestamp, an uptime, and a log ending mid-startup. The issue they filed has an
empty description, which is the honest response to being handed a number and no
next step.

The classification already existed and is good: `crashCauseHint` distinguishes
a native fault (a GPU driver disagreeing with the bundled CUDA runtime, or a
partially downloaded weight file), an exit 78 port conflict, an OOM kill and a
half-built Python environment, and names concrete actions including the
crash-isolated engines. It just never reached this surface — the only place it
rendered was the message on a stream dropped by a crash, and a crash with no
request in flight has no stream to drop.

So the details dialog renders it. A sentinel marker is deliberately excluded:
it cannot know a crash happened at all (sleep, force-quit and a stopped VM
leave the same trace), so it has no cause to explain, and asserting one would
be the #1375 fabrication in a new place.

Three tests: the access violation gets the compute-stack guidance, a port
conflict gets its own rather than the GPU one, and a sentinel gets none. The
first two fail against the previous component.

2853 vitest tests green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 23:51:50 -07:00
Palash Debnath b945ddd163 Merge remote-tracking branch 'origin/main' into tmp/1986
# Conflicts:
#	CHANGELOG.md
2026-09-09 23:48:36 -07:00
Palash Debnath 525a2809eb Merge pull request #1989 from debpalash/land/1981-structure
docs: refresh STRUCTURE.md and pin its counts to the tree (#1981)
2026-09-09 23:48:11 -07:00
Palash DebnathandClaude Opus 5 1b7fcf92c3 fix(crash): capture the dying backend's last words, not the log so far (#1850)
The crash report in #1850 carries a stderr tail that stops 58 seconds before
the death it is meant to explain. That is not a quiet backend — it is a race.

`wait()` returns the moment the child exits, but stderr is drained by a
separate Rust thread reading a pipe and appending to backend_err.log. The two
crash-marker sites read that file immediately on detecting death, so the
drainer's in-flight lines — the traceback that names the cause — land after the
tail is taken. The report then shows a log that simply stops, and the crash is
undiagnosable no matter how good the rest of the capture is. Every silent
"exit code 1" report is a candidate for this.

The machinery to wait already existed for a different reason: #1510 joins the
drainer before a respawn records its start offset, so a dying run's buffered
tail cannot be attributed to the new run. It was just never applied to the
death paths. `join_previous_err_drainer` becomes `settle_err_log`, called from
the crash-marker sites in both the startup and supervisor paths as well as
before a respawn.

One behaviour change while it moves: when the bound expires the handle is now
handed back rather than dropped. Dropping detaches the thread, and every later
caller — including the respawn that #1510 protects — silently loses the ability
to wait for that run's output at all. Bound stays at 2 s, so a wedged pipe still
cannot stall crash recording.

Regression tests: a drainer that writes a traceback 120 ms after death (the
tail contains it now, contains only "steady state" before), and a wedged
drainer that outlives the bound (the slot still holds it). The three tests that
install into the process-global drainer slot now serialize on a lock — they
were racing each other under cargo's threaded runner.

238 lib tests green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 23:47:18 -07:00
Palash DebnathandClaude Opus 5 78a6c489c9 docs(docker): finish the ARM64 Compose guidance (#1987)
@yangfan-yf-yf pushed two more commits to #1987 after the first pass landed.
Two things in them were worth taking:

  - an explicit `compose pull` step, so the platform override is proven before
    `up -d` rather than discovered when the pull inside it fails; and
  - a PowerShell form. An ARM64 Windows host cannot use `export`, and the
    surrounding page only ever shows Bash — so the guidance did not actually
    reach the users most likely to need it.

Not taken: the same commits also moved `--platform linux/amd64` into the
default `docker pull` / `docker run` quick start. That is a no-op for the
amd64 majority and contradicts the Architecture section directly above, which
introduces the flag as the conditional ARM64 step. The canonical command stays
the one almost everyone should run.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 23:41:44 -07:00
Palash Debnath 5e4f863c4d Merge pull request #1988 from debpalash/land/1987-docker-arch
docs(docker): document the amd64-only images and the ARM64 workaround (#1987)
2026-09-09 23:39:41 -07:00
Palash Debnath 12794f3dae Merge pull request #1985 from debpalash/fix/1773-classic-error-class
fix(errors): carry the backend error class onto a classic 500
2026-09-09 23:39:30 -07:00
Palash DebnathandClaude Opus 5 0ce5cca1b5 fix(bootstrap): emit an attempt id so the splash stops guessing (#1900)
The first-run splash decided which bootstrap attempt a piece of evidence
belonged to by inferring attempt boundaries from the `bootstrap_status` stage,
which is sampled about once a second. Inference from a sampled signal cannot be
airtight, and two routes slipped through it:

  - a retry that goes failed -> checking -> starting_backend inside one sample
    window, where the poll sees no restart stage at all; and
  - the supervisor's own venv rebuild, which re-enters `checking` with no
    `failed` stage and no click behind it. If the poll samples the same stage
    name on either side of it, the sequence is `installing_deps` ->
    `installing_deps` — literally no signal that anything restarted, and the
    previous attempt's completed steps stayed on screen as this attempt's work.
    That is the #1894 fabrication arriving by a route stage inference cannot
    close.

The producer knows the answer exactly, so it now says so. `ATTEMPT` is a
monotonic counter bumped wherever the bootstrap really restarts —
`respawn_backend`, which both retry commands and the scoped reset funnel
through, and the automatic venv rebuild. `bootstrap_status` returns it beside
the stage (a flattened `BootstrapStatus`, so the wire shape the frontend
already reads is unchanged), and every `bootstrap-log` line carries it too.

The splash scopes stage evidence by equality on that id and the boundary
heuristics are gone: `RESTART_STAGES`, the leaving-`failed` rule, the
wall-clock `attemptStart`, and the `selfInitiatedRef` guard that existed only
to stop the poll re-stamping a boundary the UI had already opened. `beginAttempt`
is now presentation only — it clears the visible log for a retry the user asked
for.

Two new tests cover what only an id can carry: a Rust-side restart the poll
cannot see at all, and a log line from the previous attempt that must not count
toward this one. Both fail against the previous component and pass now. Rust
side: 240 lib tests green, including four on the counter and the status shape.
Frontend: 2847 vitest tests green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 23:38:39 -07:00
Palash Debnath 744a0550d3 Merge remote-tracking branch 'origin/main' into tmp/1986
# Conflicts:
#	CHANGELOG.md
2026-09-09 23:25:50 -07:00
Palash DebnathandClaude Opus 5 56e9e42ac2 test: let a stock Windows checkout run the symlink tests (#1990)
Creating a symlink on Windows needs SeCreateSymbolicLinkPrivilege, which a
normal account does not hold unless Developer Mode is on. GitHub's hosted
Windows runners hold it, so seven unguarded call sites passed in CI and failed
only on a contributor's own machine, with WinError 1314 and no connection to
whatever they were working on:

  tests/backend/services/test_audiocpp_backend.py  (5)
  tests/test_exports_api.py                        (1)
  tests/test_storage_report.py                     (1)

The repo already knew about this — tests/test_hf_cache_repair.py carries a
private _symlink_or_skip helper whose docstring describes exactly this failure.
The pattern simply never reached the other files, which is the whole class of
the bug: a convention that lives in one module's private helper gets rewritten
from scratch, or forgotten, at every new call site.

So the helper is now a `symlink_or_skip` fixture in tests/conftest.py, and
tests/test_symlink_guards.py walks the AST of every test module and fails on a
raw symlink_to / os.symlink that has no way to skip. Guarded means the fixture,
a try, a skipif marker (module-level pytestmark included), or a test that has
already run a skipping helper — the three legitimate existing patterns, which
it recognises rather than forcing a rewrite.

Coverage is unchanged: the full pytest job runs on Linux, where nothing skips.
Fails before (7 errors, then the guard reports the offending files), passes
after.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 23:25:16 -07:00
Palash Debnath c2f27c39d2 Merge remote-tracking branch 'origin/main' into tmp/1985
# Conflicts:
#	CHANGELOG.md
2026-09-09 23:24:18 -07:00
Palash Debnath 60b696f37f Merge pull request #1984 from debpalash/fix/1949-phoneme-visible
fix(pronunciation): say when an IPA/CMU entry is stored but not applied
2026-09-09 23:23:18 -07:00
Palash DebnathandClaude Opus 5 5237f7849a docs: keep STRUCTURE.md's README annotation in English
tests/test_no_hardcoded_cjk.py rejects CJK outside frontend/src/i18n/, and the
refreshed tree annotated README_CN.md with the characters themselves. The file
name already says which language it is; the annotation does not need to be in
it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 23:22:58 -07:00
Palash DebnathandClaude Opus 5 a5f4d61eda docs: keep STRUCTURE.md's counts honest with a test
Lands #1981 by @Dawcraft, which refreshes docs/STRUCTURE.md to match the tree
as it actually is — the old file still described a root-level layout that the
2026-07-12 cleanup removed, and pointed at a tests/services/ mirror that has
not existed since the tests/backend/ reorganisation.

Verified every path, directory and CI claim in the refreshed file against the
repo: the router auto-include list, the isolated backend/tests/ pytest step,
the smoke-matrix job and its HF_HUB_OFFLINE guard, and every file the tree
names. One number was off — backend/services/ holds 78 modules, not 79.

Off-by-one in a doc is the symptom; the class is a count nothing checks, which
is wrong the week after it is written. tests/test_structure_doc.py now pins
the router count, the service count and the engine-adapter list to the tree,
so the next module to land fails the suite with the line to update instead of
quietly aging the doc. Fails before the fix (79 != 78), passes after.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 23:06:59 -07:00
Palash Debnath c7d0e314d9 Merge branch 'pr/1981' into land/1981-structure 2026-09-09 23:03:14 -07:00
Palash DebnathandClaude Opus 5 c4f214858b docs(docker): cover Compose in the ARM64 guidance
Lands #1987 by @yangfan-yf-yf, which closes #1921.

The published images are linux/amd64 only, and the quick start reached image
resolution before saying so — an ARM64 user met "no matching manifest for
linux/arm64/v8" with no explanation. Verified against docker.yml, which says
so in its own comment: "only building linux/amd64".

One gap in the original: the platform override was documented for docker pull
and docker run, but Compose has no per-command --platform flag, so the
recommended Compose command still resolved the missing ARM64 manifest and
failed exactly as before. DOCKER_DEFAULT_PLATFORM covers it, with the same
caveat the rest of the section makes — emulation, not native support, and only
the CPU profile makes sense under it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 23:00:44 -07:00
Palash Debnath 7aa2333823 Merge remote-tracking branch 'origin/pr/1987' into land/1987-docker-arch 2026-09-09 23:00:14 -07:00
Palash Debnath fe012ad3a5 Merge remote-tracking branch 'origin/main' into fix/1960-name-the-language
# Conflicts:
#	CHANGELOG.md
2026-09-09 22:58:31 -07:00
Palash Debnath 1b7e858886 Merge remote-tracking branch 'origin/main' into fix/1773-classic-error-class
# Conflicts:
#	CHANGELOG.md
2026-09-09 22:58:26 -07:00
Palash Debnath fd74865f7c Merge remote-tracking branch 'origin/main' into fix/1949-phoneme-visible
# Conflicts:
#	CHANGELOG.md
2026-09-09 22:58:22 -07:00
Palash Debnath 0f237a9b25 Merge pull request #1983 from debpalash/fix/1847-bootstrap-log-file
fix(bootstrap): keep the first-run install log after setup finishes
2026-09-09 22:57:53 -07:00
Yang Fan ae25a6a594 docs: clarify Docker image architecture requirements 2026-09-10 13:51:58 +08:00
Palash DebnathandClaude Opus 5 aa984075a7 test(dub): pair each rejected code with its own response
The two requests in this case send different bad codes; asserting one string
against both bodies passed on whichever happened to match.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 22:46:12 -07:00
Palash DebnathandClaude Opus 5 80e0b91ce8 test(dub): assert the substance of the rejection, not its exact wording
The existing case pinned the literal string "Invalid source language code",
which the #1960 fix replaces with a message that names the offending code. It
now asserts what the test is actually about — a 400 that identifies the code —
so improving the guidance again does not fail it for the wrong reason.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 22:44:48 -07:00
Palash DebnathandClaude Opus 5 d1e4c847cb fix(dub): name the source language code that was rejected
Closes #1960.

The report was "400 Bad Request: Invalid source language code" and nothing
else. That cannot be acted on or triaged: it does not say which of the ninety
or so codes was wrong, so neither the user nor a maintainer reading the
auto-filed issue can tell whether the picker offered something the backend does
not accept, or a stale preference from an older build is still being sent.

I could not determine the cause from the report, which is exactly the problem.
Naming the code makes the next one answerable instead of guessing at this one.

The value is a language code chosen from a menu, not private data, and the
engine validator a few lines away already echoes its input the same way.

Also adds the check I actually wanted while investigating: a test that reads
the picker's own LANG_CODES and asserts the backend accepts every one of them,
so a code added to the menu cannot silently become a 400. It passes today —
the menu and the allowlist do agree — which is how I ruled that out as the
cause rather than assuming it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 22:42:27 -07:00
Palash Debnath 91515310f0 Merge remote-tracking branch 'origin/main' into fix/1773-classic-error-class
# Conflicts:
#	CHANGELOG.md
2026-09-09 22:40:35 -07:00
Palash Debnath 6087085d43 Merge remote-tracking branch 'origin/main' into fix/1949-phoneme-visible
# Conflicts:
#	CHANGELOG.md
2026-09-09 22:40:30 -07:00
Palash Debnath 2f66e95958 Merge remote-tracking branch 'origin/main' into fix/1847-bootstrap-log-file
# Conflicts:
#	CHANGELOG.md
2026-09-09 22:40:26 -07:00
Palash Debnath f905230fd8 Merge pull request #1982 from debpalash/fix/1974-dev-port-ownership
fix(dev): reclaim the port from a backend the app itself left running
2026-09-09 22:39:58 -07:00
Palash DebnathandClaude Opus 5 b6ed598770 fix(errors): carry the backend error class onto a classic 500
Closes #1773.

The 500 handler has always put error_class in the response body, but nothing
lifted it onto the Error object — and the auto bug reporter reads the Error. So
every unclassified 500 filed "VoiceStudio hit an internal error; check the
backend log for details." and nothing else: identical reports, none of them
triageable, with the distinguishing datum sitting unused in the payload that
produced them.

#1956 did exactly this for the streaming path. The classic path had been
carrying the field on the wire the whole time; it just never survived the hop
onto the exception.

Only a string is kept. A 404 or a validation error has no class, and an empty
one would put a blank line in every report; a non-string is ignored rather than
stringified. Both pinned.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 22:25:56 -07:00
Palash Debnath ac09da3c24 Merge remote-tracking branch 'origin/main' into fix/1949-phoneme-visible
# Conflicts:
#	CHANGELOG.md
2026-09-09 22:22:37 -07:00
Palash Debnath ef8636ee78 Merge remote-tracking branch 'origin/main' into fix/1847-bootstrap-log-file
# Conflicts:
#	CHANGELOG.md
2026-09-09 22:22:31 -07:00
Palash Debnath 72249a8d8e Merge remote-tracking branch 'origin/main' into fix/1974-dev-port-ownership
# Conflicts:
#	CHANGELOG.md
2026-09-09 22:22:26 -07:00
Palash Debnath 8e2928ca56 Merge pull request #1980 from debpalash/fix/1858-shortcut-registration
fix(dictation): say when another app already owns the shortcut
2026-09-09 22:22:01 -07:00
Palash DebnathandClaude Opus 5 de962d164a fix(pronunciation): say when an IPA/CMU entry is stored but not applied
Closes #1949.

Settings offers three notations. Only Respelling substitutes text today; IPA
and CMU rows save cleanly, are validated, get a badge and can be toggled on,
then get dropped before term matching and are never read again.

That much is Phase 1 behaving as designed. The defect is that it was INVISIBLE:
"Test a sentence" answered "No entries match — spoken as written" for a term
that does match. Not a degraded answer, a wrong one — and it sent the user off
to re-type an entry that was already correct, or to convert it to Respelling,
where a phoneme string is then read as graphemes.

docs/specs/01-expressive-tts.md asked for exactly the opposite: such entries
"passed through and flagged 'phoneme not honored on this engine' (parity-rule:
visible degradation)". That flag was never implemented. This is it.

The dry run reports inert entries separately, and the panel names them. The
substitution path is deliberately untouched — this does NOT start feeding raw
phoneme strings into the grapheme stream, which is the thing Phase 1 refuses on
purpose, and a test pins that it still refuses.

Not Phase 2. Lowering IPA/CMU to engine markup is a real feature per engine and
stays open; what changes here is that the gap is now honest rather than silent.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 22:11:05 -07:00
Palash Debnath 3d76f1ca26 Merge remote-tracking branch 'origin/main' into fix/1847-bootstrap-log-file
# Conflicts:
#	CHANGELOG.md
#	frontend/src-tauri/src/bootstrap.rs
2026-09-09 22:06:20 -07:00
Palash Debnath 6203fe41e9 Merge remote-tracking branch 'origin/main' into fix/1974-dev-port-ownership
# Conflicts:
#	CHANGELOG.md
2026-09-09 22:04:53 -07:00
Palash Debnath 8e87755845 Merge remote-tracking branch 'origin/main' into fix/1858-shortcut-registration
# Conflicts:
#	CHANGELOG.md
2026-09-09 22:04:48 -07:00
Palash Debnath 3013cdc241 Merge pull request #1979 from debpalash/fix/1898-windows-quit
fix(windows): stop reporting every deliberate quit as a crash
2026-09-09 22:04:19 -07:00
Palash DebnathandClaude Opus 5 939ed4b12d fix(bootstrap): keep the first-run install log after setup finishes
Closes #1847.

The splash is the only surface with a Show/Copy affordance for these lines, and
it unmounts the moment the stage flips to ready — so on a successful first run
the whole install log was gone for good, with no completion pause and nowhere
to retrieve it. A user who wanted to check what had just been installed, or
attach it to a bug report, had nothing.

The lines are written to bootstrap.log beside backend.log now, so everything
about a run is in one directory and a bug report does not have to hunt in two.

Truncated once per process rather than appended forever: a bootstrap is a
single episode and the useful question is always "what happened this time".
That also bounds the file across repeated retries without needing a hook on
every restart path. The docs say so, and say to copy it first if you need a
superseded attempt.

Best effort throughout — a log that cannot be written must never take the
bootstrap down with it, and a test pins that it does not.

The counter half of this issue (Activity frozen at 200) was already fixed on
main by #1918; I verified that before starting rather than assuming the whole
issue was open.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 21:48:53 -07:00
Palash Debnath 9e768c9552 Merge remote-tracking branch 'origin/main' into fix/1974-dev-port-ownership
# Conflicts:
#	CHANGELOG.md
2026-09-09 21:45:27 -07:00
Palash Debnath 18d2d1e076 Merge remote-tracking branch 'origin/main' into fix/1858-shortcut-registration
# Conflicts:
#	CHANGELOG.md
2026-09-09 21:45:22 -07:00
Palash Debnath 8d0b826c92 Merge remote-tracking branch 'origin/main' into fix/1898-windows-quit
# Conflicts:
#	CHANGELOG.md
2026-09-09 21:45:17 -07:00
Palash Debnath 939bdc7248 Merge pull request #1978 from debpalash/fix/1857-reduced-motion
feat(a11y): add an in-app Reduce motion switch
2026-09-09 21:44:50 -07:00
DawcraftandClaude Opus 5 71d4114354 docs: correct the CI and mirror-path claims in STRUCTURE.md
Both points from the review are right:

- The three test homes do not each get their own CI job. `ci.yml` runs all
  three as steps of the single `test` job (`Run pytest`, `Run pytest
  (backend/tests, isolated)`, `Run Vitest`); what makes `backend/tests/`
  separate is the pytest session, not the job.
- `tests/backend/services/test_dub_pipeline*.py` does not exist — that
  regression test is flat, at `tests/backend/test_dub_pipeline_wav.py`.
  The mirroring example now uses a path that exists
  (`backend/services/ffmpeg_utils.py` ->
  `tests/backend/services/test_ffmpeg_utils.py`) and says that
  backend-wide and cross-cutting suites stay flat.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LDyC6prbjFydox9XQGhyny
2026-09-10 13:32:07 +09:00
Palash DebnathandClaude Opus 5 5f7df6ac52 fix(dev): reclaim the port from a backend the app itself left running
Closes #1974.

The dev launcher only treated a port holder as ours when it ran out of the git
checkout. A backend the Tauri shell spawned lives under a per-app directory
named after the bundle id instead, so the launcher saw its OWN orphaned backend
as a stranger, refused to free port 3900, and aborted the run with "Refusing to
stop unrelated process" and no way forward but Task Manager.

Ownership now also accepts the app's reverse-DNS identifier in the executable
path or the command line. A bundle id is specific enough to be safe: nothing
else on the machine carries it, which is the point of the namespace.

The guard itself is unchanged in spirit — a foreign listener on the port is
still refused, and a test pins that widening ownership did not widen it to
everything, including a process from some other vendor's bundle.

Known limit, since I hit it in this repo: on Windows the check is given the
command line and executable path but not the working directory, so a backend
started by hand from an arbitrary interpreter — a bare `uvicorn` whose only
link to the checkout is a relative --app-dir — is still not recognised. That is
a different shape from the reported one and needs the cwd, which this code path
does not currently have.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 21:31:19 -07:00
Palash Debnath 12216ecc9a Merge remote-tracking branch 'origin/main' into fix/1858-shortcut-registration
# Conflicts:
#	CHANGELOG.md
2026-09-09 21:27:39 -07:00
Palash Debnath 1339fa6814 Merge remote-tracking branch 'origin/main' into fix/1898-windows-quit
# Conflicts:
#	CHANGELOG.md
2026-09-09 21:27:38 -07:00
Palash Debnath 4b5b19ba47 Merge remote-tracking branch 'origin/main' into fix/1857-reduced-motion
# Conflicts:
#	CHANGELOG.md
#	frontend/src/i18n/locales/ar.json
#	frontend/src/i18n/locales/de.json
#	frontend/src/i18n/locales/es.json
#	frontend/src/i18n/locales/fr.json
#	frontend/src/i18n/locales/hi.json
#	frontend/src/i18n/locales/id.json
#	frontend/src/i18n/locales/it.json
#	frontend/src/i18n/locales/ja.json
#	frontend/src/i18n/locales/ko.json
#	frontend/src/i18n/locales/nl.json
#	frontend/src/i18n/locales/pl.json
#	frontend/src/i18n/locales/pt.json
#	frontend/src/i18n/locales/ru.json
#	frontend/src/i18n/locales/sv.json
#	frontend/src/i18n/locales/th.json
#	frontend/src/i18n/locales/tr.json
#	frontend/src/i18n/locales/uk.json
#	frontend/src/i18n/locales/vi.json
#	frontend/src/i18n/locales/zh-CN.json
#	frontend/src/i18n/locales/zh-TW.json
2026-09-09 21:27:37 -07:00
Palash Debnath 7d1f44f8bd Merge pull request #1977 from debpalash/land/1975-light-theme
fix(a11y): land the light theme, with one token raised to clear WCAG AA
2026-09-09 21:26:39 -07:00
Palash DebnathandClaude Opus 5 647ddc842b fix(dictation): say when another app already owns the shortcut
Closes #1858.

Whichever app registers a global shortcut first wins, and the default collides
with 1Password Quick Access on macOS — so for a large share of installs the
hotkey the onboarding screen advertises silently does nothing.

Registration failure was a Rust-side log line and nothing else. There was no
publish on the error path, so the frontend kept reporting whatever accelerator
had been REQUESTED, with no way for any screen to know the OS had refused it.
The failure is published now, carrying the outcome in `backend` and still
naming the accelerator so the UI can say WHICH combination is taken.

Surfaced as its own state rather than folding into the existing "no hotkey
registered" badge. That one means "not checked yet"; this means "this exact
combination belongs to another app, pick a different one" — different
situations needing different actions.

Detection rather than a new default, deliberately. Any default can collide with
something, so changing the value would move the problem rather than remove it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 21:20:32 -07:00
DawcraftandClaude Opus 5 638392994a docs: refresh STRUCTURE.md to match the tree as it is today
STRUCTURE.md still described the April layout: it was missing
backend/engines, worker, mcp_shim, speech_client, migrations, plugins,
hooks and config; the frontend e2e suites, i18n and src-tauri packaging
inputs; and the bin, skills, .agents/skills, notebooks, omnivoice-gallery
and .github/workflows top-level entries. Stale docs are bugs.

Three corrections beyond the missing entries:

- "all tests live here, no exceptions" was wrong. There are three homes
  (tests/, backend/tests/, co-located vitest) and the split is deliberate:
  pyproject testpaths, a separate ci.yml job, and the sys.modules-stub
  hazard documented in backend/tests/conftest.py. Replaced the claim with
  a table that records why each home exists.
- .env.example does not exist and the app never reads a repo-local .env;
  the durable user env file is ~/.config/omnivoice/env
  (backend/core/user_env.py), written by the Settings panel.
- .agents/ was listed as deleted, but it is back with a different job:
  the canonical skill copies pinned by skills-lock.json.

Also fixes the dead blob/main/STRUCTURE.md URL in the backlink script --
the file has lived in docs/ since the cleanup pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LDyC6prbjFydox9XQGhyny
2026-09-10 13:19:44 +09:00
Palash DebnathandClaude Opus 5 dba3074376 fix(windows): stop reporting every deliberate quit as a crash
Closes #1898.

On Windows the shell terminates the backend's job object with no graceful
phase — a console-less GUI child has no reliable control event — so the
backend never runs its lifespan shutdown and never clears its own run
sentinel. Every deliberate quit came back on the next launch as "The backend
did not shut down cleanly last run — it likely crashed or was killed". The
backend-side fix in #1895 only helps platforms where teardown actually begins.

A process about to be killed cannot record its own intent, so the shell records
it: the sentinel is retired immediately before the tree is terminated, on the
one path that knows the stop is deliberate. Anything that dies WITHOUT passing
through that path still leaves its sentinel behind and is still reported as a
crash, which is the property worth keeping.

Best effort by design. The data directory comes from the running backend, so if
it cannot be reached the file stays and the next launch reports a crash — the
same behaviour as before, never worse. A test pins that specifically: silently
erasing evidence of a real crash would be worse than a false positive.

Split into a pure file-level half and the port lookup so the behaviour is
testable without standing up a stub server. Verified on Windows with a real
toolchain: 233 Rust tests pass, including the three new ones.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 21:16:13 -07:00
Palash DebnathandClaude Opus 5 d0422b8913 feat(a11y): add an in-app Reduce motion switch
Closes #1857.

The CSS honours prefers-reduced-motion in about a dozen separate blocks, but
that is the OS switch and nothing else. Someone who wants a calm app without
turning motion off system-wide had no way to ask for it, and someone whose OS
setting is not respected by their environment had no recourse at all.

Settings → Appearance → Reduce motion sets data-motion="reduce" on the root,
and one blanket rule covers the whole tree including pseudo-elements. That
shape is deliberate: a per-component list is what let the header status dot
keep pulsing under Reduce Motion (Part B of the same issue, fixed separately),
and a single rule cannot have that gap.

Additive by design. The media query is left untouched and keeps working on its
own, so turning this off never re-enables motion for someone whose system asked
for less. A test pins that the two stay independent.

Durations go to 0.01ms rather than none: a zero duration skips animationend /
transitionend, which strands anything waiting on them. Imperceptible, still
fires. Also pinned.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 21:11:13 -07:00
Palash DebnathandClaude Opus 5 a31b50c5cb fix(a11y): land the light theme, with one token raised to clear WCAG AA
Closes #1973. Lands #1975 by @CoDe-ReDz.

The app shipped six themes, all dark, and "auto" stayed dark on a light-mode
OS — so a user looking for a light mode found nothing. Light text on a dark
background causes halation for people with astigmatism, which makes this an
accessibility gap rather than a preference.

One correction to the contributor's palette: --chrome-fg-muted at #586e75 gives
4.39:1 against --chrome-bg #eee8d5, just under the 4.5:1 AA threshold for
normal text. Raised to #4d5f66 (5.45:1) in both the explicit light block and
the prefers-color-scheme mirror, keeping it in the Solarized family.

For the record, the two contrast failures the review bot flagged as P1 are not
real: --color-fg-subtle measures 6.66:1 and --chrome-fg-dim 5.86:1, both
comfortably AA. The token that actually failed was one it did not mention.

Everything else the bots raised was already handled on the branch: both theme
labels go through t() with real translations in all 21 locales, and the
header's white-to-grey gradient is overridden for the explicit light theme and
the auto mirror alike.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 21:06:19 -07:00
Palash Debnath cb4aaa1580 Merge remote-tracking branch 'origin/pr/1975' into land/1975-light-theme 2026-09-09 21:04:07 -07:00
Palash Debnath d0ab15c376 Merge pull request #1972 from debpalash/fix/1826-input-too-short
fix(errors): explain a too-short input instead of quoting torch's conv error
2026-09-09 20:59:29 -07:00
CoDe-ReDz 212a1afb69 fix(i18n): replace english placeholder labels with localized translations 2026-09-09 19:55:46 -07:00
CoDe-ReDz 58a4674316 fix(a11y): address bot review feedback (contrast, header, i18n, tests) 2026-09-09 19:43:30 -07:00
CoDe-ReDz bcc47882e9 a11y: Add Solarized Light theme and wire OS auto-sync
Resolves #1973. Addresses eye strain halation by adding a WCAG AA compliant light theme and exposing the Auto preference.
2026-09-09 19:08:39 -07:00
Palash Debnath 355f7465c8 Merge remote-tracking branch 'origin/main' into fix/1826-input-too-short
# Conflicts:
#	CHANGELOG.md
2026-09-09 16:29:07 -07:00
Palash Debnath 9426006d3c Merge pull request #1971 from debpalash/fix/1849-uiscale-order
fix(setup): offer the text-size control before first run, not after it
2026-09-09 16:28:44 -07:00
Palash Debnath f82ec3f579 Merge remote-tracking branch 'origin/main' into fix/1826-input-too-short
# Conflicts:
#	CHANGELOG.md
#	backend/core/failure.py
2026-09-09 16:12:00 -07:00
Palash Debnath b4fc4cb53f Merge remote-tracking branch 'origin/main' into fix/1849-uiscale-order
# Conflicts:
#	CHANGELOG.md
2026-09-09 16:11:23 -07:00
Palash Debnath c6d7a19f42 Merge pull request #1970 from debpalash/fix/1879-clone-reference
fix(errors): say 'no reference clip' instead of naming library parameters
2026-09-09 16:10:58 -07:00
Palash DebnathandClaude Opus 5 c902a42f6b fix(errors): explain a too-short input instead of quoting torch's conv error
Closes #1826.

A degenerately short generation reaches a convolution whose kernel is wider
than the tensor it was handed, and torch reports that in its own terms —
"Calculated padded input size per channel: (1). Kernel size: (2). Kernel size
can't be greater than actual input size". It arrived doubly wrapped in
"Underlying error:" and named nothing the user could change, when the fix on
their side is simply to type more than one character.

It is worth classifying for a second reason: this is not transient. The generic
wrapper told the user to "retry once", and this class fails identically on
every retry, so the advice actively wasted their time. The new remedy says so.

Matched on torch's own wording, which nothing else produces, so it is safe on
the context-free surfaces — and it needs to be, because that is exactly how it
reaches the user, through the generic 500 and the streaming error frame.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 15:55:38 -07:00
Palash Debnath 7a24b459bc Merge remote-tracking branch 'origin/main' into fix/1849-uiscale-order
# Conflicts:
#	CHANGELOG.md
2026-09-09 15:52:55 -07:00
Palash Debnath 0862b3efed Merge remote-tracking branch 'origin/main' into fix/1879-clone-reference
# Conflicts:
#	CHANGELOG.md
2026-09-09 15:52:51 -07:00
Palash Debnath ac63eff33d Merge pull request #1969 from debpalash/fix/1931-torchaudio-backend
fix(startup): guard the torchaudio API removed in 2.9, and document the Blackwell path
2026-09-09 15:52:29 -07:00
Palash DebnathandClaude Opus 5 f92e33f8e3 fix(setup): offer the text-size control before first run, not after it
Closes #1849.

UiScaleSetup is a client-side zoom — it makes no backend calls at all — but it
was gated on backendReady. So on a clean install the user watched the entire
bootstrap, and answered the macOS Accessibility prompt, at whatever size the
app had guessed, and was offered the size control only once all of that had
finished. Someone who cannot comfortably read the UI had to get through the
least readable part of the product first.

The gate now runs as soon as the store has hydrated, which is its only real
prerequisite: uiScaleConfigured lives in the store, and reading it earlier
would flash the screen at someone who had already chosen a scale.

Pinned at the source level. Rendering App in jsdom to observe the ordering
would need the whole backend, store and Tauri surface mocked — a far more
fragile test than the two facts it pins.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 15:41:03 -07:00
Palash Debnath 70aecf7ad0 Merge remote-tracking branch 'origin/main' into fix/1879-clone-reference
# Conflicts:
#	CHANGELOG.md
2026-09-09 15:36:52 -07:00
Palash Debnath 164534016a Merge remote-tracking branch 'origin/main' into fix/1931-torchaudio-backend
# Conflicts:
#	CHANGELOG.md
2026-09-09 15:36:47 -07:00
Palash Debnath 7b7b491ba0 Merge pull request #1968 from debpalash/fix/small-batch-1
fix(errors): point a generation timeout at Settings, not an environment variable
2026-09-09 15:36:25 -07:00
Palash DebnathandClaude Opus 5 0a019b5d7c fix(errors): say 'no reference clip' instead of naming library parameters
Closes #1879.

mlx-audio raises a bare ValueError in its own vocabulary — "No conditionals
available. Either provide audio_prompt/audio_prompt_sr for voice cloning, or
ensure conds.safetensors is in the model directory." — and the generate route
passed it straight through as the 400 detail. The user was told to supply an
argument they have no way to name and to check for a file they have never heard
of, when what happened is simply that they asked to clone with nothing to clone
from.

Classified now, with a remedy in the user's terms: pick a profile that has a
saved reference clip, or record one. It also notes that a designed voice with
no saved reference cannot be cloned from, which is the case that produces this.

The route still passes through every ValueError it cannot classify. Most are
VoiceStudio's own validation messages and are exactly what the user should
read, so replacing them wholesale would have been a regression — tests pin four
of them as untouched.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 15:24:12 -07:00
Palash Debnath 4da62e664d Merge remote-tracking branch 'origin/main' into fix/1931-torchaudio-backend
# Conflicts:
#	CHANGELOG.md
2026-09-09 15:20:05 -07:00
Palash Debnath 508943ae71 Merge remote-tracking branch 'origin/main' into fix/small-batch-1
# Conflicts:
#	CHANGELOG.md
2026-09-09 15:20:00 -07:00
Palash Debnath 42b4bf856f Merge pull request #1967 from debpalash/fix/1866-engine-reason
fix(engines): say why an engine is unavailable instead of reporting a failed check
2026-09-09 15:19:40 -07:00
Palash DebnathandClaude Opus 5 c119afb023 fix(startup): guard the torchaudio API removed in 2.9, and document the Blackwell path
Refs #1931.

torchaudio 2.9 removed set_audio_backend(). soundfile has been the only backend
since 2.0, so the call was already a no-op — but unguarded it raises
AttributeError inside the ml_imports startup phase, and a failure there takes
the whole backend down: the desktop app sits on "starting backend" forever and
/health stays 503.

The group hitting it is not hypothetical. RTX 50-series (Blackwell, sm_120)
cards have no kernels in the pinned torch 2.8.0, so those users MUST move to
torch 2.9.x, which brings torchaudio 2.9 with it. Being forced to upgrade and
then crashing on a line that does nothing is the whole defect.

This does NOT raise the torch pin. Doing that changes the CUDA build on every
platform, in Docker and in CI, so it is the owner's call rather than something
to slip into a bug fix — the issue stays open for it. What lands here is the
half that is safe: the guard, plus a troubleshooting section with the exact
upgrade recipe and the command to confirm the card is visible, so an affected
user has a supported path today.

The guard is tested at the source level: reproducing it needs a real torchaudio
2.9 in the environment, which the pinned test env does not have. One test also
pins that the guard actually WRAPS the call, since a hasattr elsewhere in the
file would satisfy a naive substring check while the real call stayed bare.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 15:06:18 -07:00
Palash Debnath 0ba91e6d82 Merge remote-tracking branch 'origin/main' into fix/small-batch-1
# Conflicts:
#	CHANGELOG.md
2026-09-09 15:03:10 -07:00
Palash Debnath 28d9d2fbe8 Merge remote-tracking branch 'origin/main' into fix/1866-engine-reason
# Conflicts:
#	CHANGELOG.md
2026-09-09 15:03:05 -07:00
Palash Debnath 5069872752 Merge pull request #1966 from debpalash/fix/1845-setup-pill
fix(dictation): stop the Accessibility prompt owning the screen indefinitely
2026-09-09 15:02:45 -07:00
Palash DebnathandClaude Opus 5 030436a549 fix(errors): point a generation timeout at Settings, not an environment variable
Closes #1808.

#1797 moved the compute-time budget into Settings → Performance & Device, but
three branches of _timeout_guidance still told the user to raise
OMNIVOICE_GENERATE_TIMEOUT_S. That sends someone to set an environment variable
for a value the app now exposes as a control — and on Windows, setting one
durably is the trap this project's own docs warn against.

Nothing about the mechanism changed: the variable still works and still takes
precedence over the setting. Only which of the two the message names.

Two existing tests asserted the env var appears in that text. They predate
#1797 and were pinning the behaviour this issue reports as wrong, so they now
assert the control instead. A third test guards the whole class rather than the
three instances, so a branch added later cannot quietly reintroduce it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 14:50:58 -07:00
Palash Debnath b9324b84b3 Merge remote-tracking branch 'origin/main' into fix/1866-engine-reason
# Conflicts:
#	CHANGELOG.md
2026-09-09 14:45:56 -07:00
Palash Debnath 353cc40fdc Merge remote-tracking branch 'origin/main' into fix/1845-setup-pill
# Conflicts:
#	CHANGELOG.md
2026-09-09 14:45:52 -07:00
Palash Debnath a4cb4afe37 Merge pull request #1965 from debpalash/fix/1856-dictation-step
fix(setup): stop the last onboarding step failing three times with no model
2026-09-09 14:45:32 -07:00
Palash DebnathandClaude Opus 5 075ab7b68b fix(engines): say why an engine is unavailable instead of reporting a failed check
Closes #1866.

Model Catalogue → Engines showed "Engine unavailable. Check installation and
configuration." and "Last error: A previous engine check failed." for engines
the user had simply never installed. Neither names a missing package, a missing
step, or a next action, and the second reads like a crash or a poisoned cache
rather than "you have not installed this yet" — so a normal, expected state
looked like a fault.

The probe's own sentence still cannot cross the boundary: it carries exception
text, local paths and sometimes credentials, which is why it was replaced in
the first place. What changed is that the private diagnostic is now CLASSIFIED
into a VoiceStudio-owned category — package not installed, needs configuring,
file missing or unreadable — exactly the shape _public_routing_reason already
uses for routing. Anything unrecognised keeps the old generic sentence rather
than asserting a cause the probe never gave.

test_docs_url_survives_the_public_metadata_scrub pinned the generic wording
while testing something else; it now asserts what it is actually about, that no
private text survives.

Also skips the exec-bit placeholder test on Windows, where os.access(X_OK) is
true for any existing file so the assertion cannot fail — it errored the whole
module on a Windows checkout. Pre-existing, unrelated to this change, and in
the way of running these tests at all.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 14:37:27 -07:00
Palash Debnath e5a0a553e9 Merge remote-tracking branch 'origin/main' into fix/1845-setup-pill
# Conflicts:
#	CHANGELOG.md
2026-09-09 14:27:16 -07:00
Palash Debnath b7eb5428c7 Merge remote-tracking branch 'origin/main' into fix/1856-dictation-step
# Conflicts:
#	CHANGELOG.md
2026-09-09 14:27:12 -07:00
Palash Debnath bb4e99a336 Merge pull request #1964 from debpalash/fix/1957-untrusted-mount
fix(errors): explain a Windows untrusted-mount failure instead of echoing WinError 448
2026-09-09 14:26:49 -07:00
Palash DebnathandClaude Opus 5 accef57865 fix(dictation): stop the Accessibility prompt owning the screen indefinitely
Closes #1845. Closes #1886.

The widget window is created always-on-top, and the setup state had no time
limit at all. On a clean macOS install the pill sat over the first-run setup
window — covering the disk-space line and the Start installation button — and
over every other application, until Accessibility was granted or the user
dismissed it by hand. There was no cap and no safety net: the stranded-pill
reconcile only runs while idle, and this state is not idle.

A permission the user has not granted yet does not outrank what they are
actually doing, and mid-setup they usually cannot grant it yet anyway. The
prompt now gets a bounded claim on the screen and then steps aside.

Polling deliberately continues after the window hides, so granting
Accessibility later still returns the widget to idle on its own — what expires
is the pill's claim on the screen, not the reconciliation. The hide is latched
so it fires once rather than fighting anything that legitimately shows the
window again; both properties have a test.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 14:07:53 -07:00
Palash Debnath d07fa1ffff Merge remote-tracking branch 'origin/main' into fix/1957-untrusted-mount
# Conflicts:
#	CHANGELOG.md
2026-09-09 14:04:34 -07:00
Palash DebnathandClaude Opus 5 d313045b13 fix(setup): stop the last onboarding step failing three times with no model
Closes #1856.

The mandatory-only install path ships no speech-to-text model, and the
dictation step rendered its three script cards regardless. Every card came up
red with "No speech-to-text model is installed", and the step's own copy
invited the user to press the hotkey or hit Replay, neither of which can
transcribe anything. That is the final screen of first-run setup, so the last
thing a new user saw was three failures they were told to cause.

The step now checks readiness the same way the component already checks for
its bundled sample WAVs, and when no model is installed it offers the model
chooser in place of the cards — the same picker the Transcriptions page uses,
so the user installs one and continues rather than reading an error three
times. A model already on disk can be selected without a download.

`checking` deliberately keeps the cards: the probe resolves in well under a
second, and flashing the install panel first would be worse than the wait.
A test pins that.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 14:03:03 -07:00
Palash Debnath 6a44733297 Merge pull request #1962 from debpalash/land/queue2
Land the reviewed PR queue, part two: log panel, bootstrap mirror, setup diagnostics
2026-09-09 13:58:18 -07:00
Palash DebnathandClaude Opus 5 fd7d2d94dd fix(errors): explain a Windows untrusted-mount failure instead of echoing WinError 448
Closes #1957.

A download failed with nothing but the OS sentence: "[WinError 448] The path
cannot be traversed because it contains an untrusted mount point". That is a
Windows rule about the VOLUME — Dev Drives, mounted VHD/ReFS volumes and
junctions into another user profile all trigger it — so retrying the same link
can never work, and the message names nothing the user can change.

Classified now, with a remedy that points at Settings → Storage and gives the
fsutil escape hatch for a folder that has to stay put. Matched on the numeric
code first, since Windows translates the sentence, with the English phrase as a
fallback. Allowlisted for context-free surfaces because it arrives through the
global 500 handler, which otherwise attaches no hint at all — and its trigger
is unmistakable, so it cannot land on an unrelated failure.

A test pins that the offending path never comes back in the payload.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 13:47:51 -07:00
Palash Debnath f82f35ee97 Merge pull request #1963 from debpalash/land/queue3
Land the reviewed PR queue, part three: zh-CN locale and null capture timings
2026-09-09 13:43:45 -07:00
Palash Debnath 1c37c479be Merge remote-tracking branch 'origin/main' into land/queue2
# Conflicts:
#	CHANGELOG.md
2026-09-09 13:43:21 -07:00
Palash DebnathandClaude Opus 5 b55098f044 fix: repair the Colab cell edit and point the clear test at the split resolver
Two CI failures, both mine to fix.

The warning I added to the Colab ASR cell used \n escapes inside the notebook
JSON, and they landed as real newlines, so the cell's Python had an
unterminated string and tests/test_colab_asr_setup.py could not exec it. The
block prints line by line now, with no escapes to get wrong.

test_tauri_log_clear_reports_truncate_failure patched _tauri_log_candidates,
but #1925 moved Clear onto _tauri_plugin_log_candidates, so the patch no longer
reached the code under test and the real resolver was consulted instead. It
passed on a machine with a shell log on disk and failed on a clean runner.
Patches both halves, matching the fixture in test_tauri_log_clear.py.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 13:43:17 -07:00
Palash Debnath 854609e459 Merge pull request #1952 from debpalash/feat/local-workspace-dictation-polish
Improve dictation controls and creative workspace layouts
2026-09-09 13:41:19 -07:00
Palash DebnathandClaude Opus 5 7d46563ea8 fix(i18n): finish the zh-CN locale and make its own parity suite pass
#1877 completes the zh-CN translation and drops its ratchet to zero, but the
PR never ran today's gates — it has been conflicting, so CI reported nothing —
and the file it lands does not pass tests/test_locale_parity.py.

Three things fixed here:

- Twelve keys were declared twice inside the same object (timing_concise,
  autofit_quality, the plan_* set, the role_* set). Python's parser rejects a
  duplicate key outright, so the whole suite errored rather than failing one
  assertion. Deduped keeping the first occurrence, which is the block #1877
  actually translated.
- The `player` section appeared twice: the complete new one and an older
  two-key stub. JSON keeps the LAST, so the stub silently won and six keys
  vanished at runtime. The stub is gone.
- `settings.hf_source_*_label` appeared twice with slightly different wording.

The file is rewritten as canonical JSON (indent 2, non-ASCII preserved), which
is byte-identical to how en.json already serialises, so the format matches the
other locales exactly. zh-CN now has zero keys missing and zero beyond en.

Also fixes the review finding on #1959: the capture route picks its engine from
a `mode` form field, not an `accurate` flag, so parametrising on `accurate`
sent a field the route ignores and ran the default fast path twice. Both
engines are exercised now.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 13:24:06 -07:00
Palash Debnath b6143cce08 Merge remote-tracking branch 'origin/pr/1959' into land/queue3 2026-09-09 13:18:49 -07:00
Palash Debnath 512aad5c48 Merge remote-tracking branch 'origin/main' into land/1952
# Conflicts:
#	frontend/src/pages/AudiobookTab.jsx
2026-09-09 13:17:13 -07:00
Palash Debnath 8526ff56f7 Merge remote-tracking branch 'origin/main' into land/queue2
# Conflicts:
#	CHANGELOG.md
2026-09-09 13:15:23 -07:00
Palash Debnath a68f85c51b Merge pull request #1958 from debpalash/land/queue1
Land the reviewed PR queue: audiobook, engines, bootstrap, setup and download fixes
2026-09-09 13:13:25 -07:00
Palash DebnathandClaude Opus 5 df7dab43b6 fix(i18n): keep the China-mirror comments out of the CJK guard
tests/test_no_hardcoded_cjk.py fails on any non-English text outside the
translation layer, allowlist aside, and #1892 put the mirror region's Chinese
label into two Rust doc comments. The comments only quote what the UI shows, so
naming the region in English says the same thing and keeps the guard green
without widening the allowlist for a comment.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 13:12:22 -07:00
Palash DebnathandClaude Opus 5 f48a33edcf fix: address the review findings on the PRs landed here
Bot review raised one blocking and several real findings across these PRs.
Each is fixed here rather than merged and followed up.

#1892 — apply_pypi_index_env() now runs for EVERY uv invocation, and with the
default region "auto" it called the UNCACHED auto_detect_region(), racing two
live network probes with a 4s timeout per uv call. On a blocked or offline
network that is a repeated multi-second stall, and it multiplies the outbound
calls a local-first app makes unasked. The probe is memoised for the life of
the process. It also now clears UV_INDEX_URL before setting it, so a stale
ambient value cannot outrank the region the user picked.

#1925 — backend.rs trimmed OMNIVOICE_LOG_DIR for its emptiness guard but built
the path from the RAW value, while the Python reader strips it. A padded value
therefore had the writer and the reader looking at different directories, which
is the divergence the PR exists to close.

#1920 — the rotation walk caught bare OSError, so a PermissionError or a real
I/O failure was swallowed and the panel silently rendered less. Only the race
the guard exists for (a file that rolled away, and on Windows the handler's own
sharing violation) is skipped now; anything else surfaces.

#1951 — the fix was right but shipped no tests and no changelog entry. Both
added, including a case pinning that the wizard preflight and the diagnostic
route the same host the same way, since they carry separate copies of the
branch.

#1923 — the cell hardcodes the CTranslate2 model, but if the cuDNN 8 step
failed the backend falls back to PyTorch Whisper and downloads a second
multi-gigabyte model. The cell now says so while the download it just spent is
still on screen.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 13:09:12 -07:00
Palash DebnathandClaude Opus 5 791a46d9dd fix(errors): match WebKit's space-labelled frames so the filter works on Safari
The frame matcher required non-whitespace from line start up to the `@`,
which is right for rejecting a V8 header posing as a frame but wrong for
JSC: it labels top-level frames `global code@url`, `eval code@url` and
`module code@url`. Those are exactly the frames an injected extension
script throws from, so on WKWebView — the macOS desktop shell — and Safari
no frame matched, the origin came back unknown, and the extension's error
still offered "Report this bug". #1901 was fixed on Chromium only.

The three labels are enumerated rather than allowing spaces generally, so
the header false positive the anchoring exists for stays closed; a test
pins that. Each WebKit case uses a distinct message because shouldShow()
throttles by message text and a shared one would pass on the throttle
instead of the frame match.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 13:02:24 -07:00
Palash Debnath 61eb27dbba Merge remote-tracking branch 'origin/pr/1892' into land/queue2 2026-09-09 13:02:15 -07:00
Palash Debnath 19d371f9d6 Merge remote-tracking branch 'origin/pr/1951' into land/queue2 2026-09-09 13:02:15 -07:00
Palash Debnath c760347339 Merge remote-tracking branch 'origin/pr/1925' into land/queue2
# Conflicts:
#	CHANGELOG.md
#	backend/api/routers/system.py
2026-09-09 13:02:15 -07:00
Palash Debnath ee8a8fb928 Merge remote-tracking branch 'origin/pr/1924' into land/queue2
# Conflicts:
#	CHANGELOG.md
2026-09-09 13:01:46 -07:00
Palash Debnath d7177be66c Merge remote-tracking branch 'origin/pr/1923' into land/queue2
# Conflicts:
#	CHANGELOG.md
2026-09-09 13:01:46 -07:00
Palash Debnath 88e59326fd Merge remote-tracking branch 'origin/pr/1920' into land/queue2
# Conflicts:
#	CHANGELOG.md
2026-09-09 13:01:45 -07:00
Palash Debnath f02880cc5c Merge remote-tracking branch 'origin/pr/1897' into land/queue2
# Conflicts:
#	CHANGELOG.md
2026-09-09 13:01:45 -07:00
Palash Debnath f9ff185a22 Merge remote-tracking branch 'origin/main' into land/1952
# Conflicts:
#	CHANGELOG.md
2026-09-09 12:58:49 -07:00
Palash Debnath cc96de27b8 Merge remote-tracking branch 'origin/main' into land/queue1 2026-09-09 12:58:32 -07:00
Palash DebnathandClaude Opus 5 e8af4fae12 fix(engines): give audiocpp its docs link and pin docs_url in the registry shape
#1917 adds a Learn more link to the unavailable-engine row, driven by
_ENGINE_DOCS, and a guard that every registered engine has a doc page. It was
written before audiocpp landed on main, so against today's main the guard
failed on audiocpp and the registry shape test failed on the new docs_url key
— PR-green under an older base, main-red on merge.

docs/engines/audio-cpp.md already existed; only the id-to-path mapping was
missing. The shape test now expects docs_url, with a note pointing at the
guard so the next engine added without a doc fails loudly rather than
quietly dropping its link.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 12:58:29 -07:00
Palash Debnath e0309be21f Merge pull request #1955 from debpalash/fix/windows-backend-watchdog-hang
fix(backend): stop Windows desktop launches freezing at "Loading ML runtime"
2026-09-09 12:56:20 -07:00
Chang-Jin-LeeandClaude Opus 5 2e4465a3f4 fix(capture): pass a null segment end through instead of rounding it
`round(s.get("end", 0), 2)` does not defend against a stored None: the key is
present, so `.get` returns the None rather than the default, and `round` raises

    TypeError: type NoneType doesn't define __round__ method

`max(s.get("end", 0) for s in segments)` on the line above raises first when any
other segment is timed:

    TypeError: '>' not supported between instances of 'NoneType' and 'float'

Two engines reach these builders with end=None. `_sherpa_result` sets
duration=None when it cannot derive one from the sample rate, and sherpa is the
first capture engine. `OpenAICompatASRBackend._adapt_response` emits end=None for
every plain-text response, which is what a server that rejects verbose_json
returns, and that backend is selectable as the active one used by accurate mode.

Measure the duration from the segments that carry a number, and pass the nulls
through. That is the shape the segment list already renders since #1904 — it
shows whichever half of the range is known — and it keeps the honest null the
producers deliberately write instead of inventing a zero.

capture_ws.py has the same two lines and gets the same treatment; it also emits
end=None itself in five of its own streaming payloads.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-10 04:33:18 +09:00
Palash Debnath 9ffc9d52d7 Merge remote-tracking branch 'origin/main' into land/1952
# Conflicts:
#	CHANGELOG.md
#	bun.lock
#	frontend/package.json
#	frontend/src/components/CaptureWidget.jsx
#	frontend/src/pages/Transcriptions.jsx
2026-09-09 12:31:06 -07:00
Palash Debnath cea6678ea7 Merge pull request #1956 from debpalash/fix/1800-stream-error-class
fix(errors): make an unclassified failure report say something true and specific
2026-09-09 12:30:09 -07:00
Palash Debnath 40199e39cf Merge remote-tracking branch 'origin/main' into work/1955
# Conflicts:
#	CHANGELOG.md
2026-09-09 12:29:36 -07:00
Palash DebnathandClaude Opus 5 c21696b9ae style: format the two files #1930 left unformatted
`bun run format:check` is a CI gate and SetupWizard.jsx plus its test came in
unformatted. No behaviour change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 12:28:05 -07:00
Palash Debnath 67817b89bf Merge remote-tracking branch 'origin/pr/1942' into land/queue1
# Conflicts:
#	CHANGELOG.md
2026-09-09 12:25:35 -07:00
Palash Debnath 20bc24c312 Merge remote-tracking branch 'origin/pr/1930' into land/queue1 2026-09-09 12:25:35 -07:00
Palash Debnath 810abf9187 Merge remote-tracking branch 'origin/pr/1919' into land/queue1
# Conflicts:
#	CHANGELOG.md
2026-09-09 12:25:35 -07:00
Palash Debnath cfb318c50b Merge remote-tracking branch 'origin/pr/1918' into land/queue1
# Conflicts:
#	CHANGELOG.md
#	frontend/src/components/BootstrapSplash.jsx
2026-09-09 12:25:34 -07:00
Palash Debnath 2e1e52f26e Merge remote-tracking branch 'origin/pr/1917' into land/queue1
# Conflicts:
#	CHANGELOG.md
2026-09-09 12:24:12 -07:00
Palash Debnath 2f663011e5 Merge remote-tracking branch 'origin/pr/1916' into land/queue1
# Conflicts:
#	CHANGELOG.md
2026-09-09 12:24:11 -07:00
Palash Debnath 773c4728c8 Merge remote-tracking branch 'origin/pr/1915' into land/queue1
# Conflicts:
#	CHANGELOG.md
2026-09-09 12:24:11 -07:00
Palash Debnath 6b68c4d9fe Merge remote-tracking branch 'origin/pr/1914' into land/queue1
# Conflicts:
#	CHANGELOG.md
2026-09-09 12:24:11 -07:00
Palash Debnath 5f5bb04f41 Merge remote-tracking branch 'origin/pr/1912' into land/queue1
# Conflicts:
#	CHANGELOG.md
2026-09-09 12:24:10 -07:00
Palash Debnath cea00a4889 Merge pull request #1908 from psiberfunk/codex/fix-synthesis-progress-indeterminate
fix(studio): show honest synthesis progress
2026-09-09 12:22:07 -07:00
Palash Debnath 6268eacf35 Merge pull request #1903 from psiberfunk/codex/fix-transcriptions-dictation
fix(dictation): make Transcriptions capture actionable
2026-09-09 12:22:01 -07:00
Palash Debnath a2653824ce Merge pull request #1896 from psiberfunk/fix/bootstrap-splash-observed-stages-1894
fix(bootstrap): stop showing first-run install steps on warm starts
2026-09-09 12:21:55 -07:00
Palash Debnath 71056bcdb4 Merge pull request #1890 from psiberfunk/fix/widget-pill-shadow-clip
fix(dictation): stop clipping the widget pill's drop shadow into a rectangle
2026-09-09 12:21:49 -07:00
Palash Debnath b5441bea36 Merge pull request #1888 from psiberfunk/fix/macos-dock-reopen
fix(desktop): handle Dock-icon reopen on macOS
2026-09-09 12:21:44 -07:00
Palash Debnath d7751ad7ce Merge pull request #1885 from psiberfunk/fix/capture-pill-setup-tooltip
fix(dictation): give the setup-state pill label a hover tooltip
2026-09-09 12:21:38 -07:00
Palash Debnath 2b027cb54a Merge branch 'main' into fix/1859-launchpad-scroll-shrink 2026-09-09 12:20:27 -07:00
Palash Debnath d2fb292217 Merge pull request #1938 from debpalash/dependabot/npm_and_yarn/frontend/vitest-4.1.11
chore(deps-dev): bump vitest from 4.1.9 to 4.1.11 in /frontend
2026-09-09 12:18:24 -07:00
Palash DebnathandClaude Opus 5 7afb82bb43 style: format the four files this branch left unformatted
`bun run format:check` is a CI gate and these four came in unformatted. No
behaviour change — running the formatter in write mode touches nothing else
in the tree.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 12:14:47 -07:00
Palash DebnathandClaude Opus 5 d630db29f5 fix(errors): stop a context-free failure borrowing another stage's remediation
Closes #1943.

A macOS mlx-audio text-to-speech failure returned a 500 advising the user
that "the connection to the video server dropped mid-download". No video was
involved. VIDEO_DOWNLOAD_NETWORK triggers on bare phrases — "timed out",
"connection reset", "broken pipe" — so any unrelated failure carrying one
is handed a confidently wrong next step, which is worse than no hint at all.

failure._CONTEXT_FREE_HINT_CLASSES already existed for exactly this, and its
own comment names VIDEO_DOWNLOAD_NETWORK as the class that must never appear
on a stageless surface. Only append_hint honoured it; public_exception_response
took over the 500 path without carrying the rule across, and the streaming
error frame then inherited the same gap through it.

The filter now lives in public_exception_response, so every context-free
caller gets it. MODEL_CACHE_CORRUPT joins the allowlist — its trigger is a
VoiceStudio-authored sentence, no library can produce it, and the 500 handler
is the surface a corrupt cache actually reaches.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 12:13:25 -07:00
Palash DebnathandClaude Fable 5.1 f49d31d5b3 test(backend): only accept positive startup evidence in the Windows watchdog test
The poll loop treated any status other than "starting" as success, so a
backend that stayed alive but reported a failed startup would pass the
very test meant to catch a broken start (CodeRabbit + Greptile on #1955).
Succeed only when the ML import step is done or status is ready; fail
loudly on any other terminal status or error. Also give the child an
empty HF_HUB_CACHE so it never reads the developer's populated cache.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HCDZcBpP6QQa4dzUa8z6rh
2026-09-09 12:06:46 -07:00
Palash DebnathandClaude Opus 5 4f4d21ff5b fix(errors): name the backend error class on an unclassified streaming failure
Closes #1800.

Every engine failure the taxonomy cannot classify renders one floor message,
"Generation failed. Check the selected engine and try again." The auto bug
reporter puts that message and a stack of minified bundle frames into the
issue, so unrelated faults arrive as byte-identical reports — roughly a dozen
of the open issues are that same report filed again, and none of them can be
told apart, let alone triaged.

The streaming error frame now carries the exception's TYPE NAME, the frontend
keeps it on StreamingPreviewError, and the report prints it as "Backend error
class: …". A MemoryError and a FileNotFoundError stop being the same issue.

Only the class name — no substring of the exception message is copied, so the
response-safety contract still holds and a test pins that a path in the
exception never reaches the payload. This is the same datum the dub routes
already put on the wire as error_class and the analytics allowlist already
treats as content-free.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 12:06:40 -07:00
Palash DebnathandClaude Opus 5 b82205fbab fix(deps): regenerate the workspace lockfile for the vitest bump
frontend/ is a bun workspace, so its package.json is locked by the
repo-root bun.lock. Dependabot bumped only the manifest, so
`bun install --frozen-lockfile` — which CI and deploy/Dockerfile both
run — rejected the tree and the Tests job never got past install.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 12:01:45 -07:00
Palash DebnathandClaude Opus 5 7601f0f1a8 fix(dictation): drop the token border the picker's nesting rail reintroduced
tests/test_no_literal_borders.py guards the app-wide border removal: a
`border-[var(--chrome-border…)]` renders a stray hairline the moment that
token stops resolving transparent. The picker's indent rail used one, which
failed the guard. The indent and padding already carry the nesting, so the
rail keeps its width as border-transparent and shows nothing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 12:00:42 -07:00
Palash DebnathandClaude Fable 5.1 5c7f8a8e7a test(backend): Windows integration regression for the desktop stdin watchdog hang
Spawns the real backend the way the desktop shell does (containment marker
plus a piped stdin) and asserts startup gets past the ML import. On the
pre-fix watchdog it times out after 180 s; on the fix it passes in ~4 s.
Windows-only, since the deadlock is a Windows loader-lock interaction and
CI's backend job runs on Linux.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HCDZcBpP6QQa4dzUa8z6rh
2026-09-09 11:51:17 -07:00
Palash DebnathandClaude Opus 5 7dcb88452c fix(deps): regenerate the root lockfile for this branch's refreshed pins
frontend/package.json moved but the workspace-root bun.lock did not, so
`bun install --frozen-lockfile` — what CI and deploy/Dockerfile both run —
rejected the tree. Plain `bun install` tolerates the drift, so a green local
run said nothing about it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 11:49:29 -07:00
Palash Debnath db50111c54 fix(sidebar): restore project rename, lost when the Dub landing became history-only
The Dub landing used to carry a WorkspaceProjects panel, and that panel was
the only caller of the project rename endpoint. Making the landing
history-only removed the panel and left rename unreachable from the entire
UI, while the rename route, the project list and the inline-rename CSS all
stayed. App.jsx's renameProject became an unused variable, which is what
failed CI lint — the lint error was the symptom, the lost capability was the
bug.

Projects now live only in the sidebar rail, so the affordance moves there:
inline rename on each project row, commit on Enter or Save, abandon on
Escape, empty and unchanged names ignored, and the button hidden when no
handler is wired. The orphaned WorkspaceProjects component is deleted.

Also fixes a Windows-only failure in initialLoadRetry.test.js: it took
.pathname off a file:// URL, which on Windows yields "/C:/..." and made
readFileSync resolve "C:\C:\...", so the file ENOENT'd on every Windows
checkout. Uses fileURLToPath instead.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
(cherry picked from commit 0a164add119335c3a150725cfe4c4ce8959c50a5)
2026-09-09 11:48:22 -07:00
Palash Debnath 6b7c2bac8f feat(transcriptions): let the user pick which dictation model to install
The missing-model empty state offered exactly one action: download the
recommended Whisper Tiny. The six other catalogue models — the more accurate
English Parakeet, the 25–44 MB streaming models that show text while you
speak, the bilingual zh/en ones — were only reachable through Settings, and
a user who already had one on disk was still told to download Whisper Tiny.

The page now lists the whole sherpa-onnx catalogue grouped by the trade-off
the user is actually choosing between (best accuracy vs lowest latency),
with languages and download size on every row. Any model can be installed
in one click, an installed one can be switched to without a download, and
the progress bar names the model that was picked. If the catalogue cannot
be read the single recommended-download button remains as the fallback.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
(cherry picked from commit 9c4ba2bab2a2253fbf4f82bf082db530267ddadc)
2026-09-09 11:47:38 -07:00
Palash DebnathandClaude Opus 5 48d1b22fd9 feat(dictation): model picker in the engine quick-switch, and a recoverable Windows dev stack
Adds the sherpa-onnx dictation model picker under the Transcription engine
row so the model the hotkey loads is switchable without opening Settings,
routes the Sherpa transcription path through that same preference, and makes
the Windows desktop dev stack recover instead of demanding Task Manager.
Refreshes the Tauri and npm dependency pins that went with it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ypcgSsh5j2PEonSJiAU1S
2026-09-09 11:47:31 -07:00
Palash DebnathandClaude Fable 5.1 6a6dd83efa docs(changelog): note the Windows backend startup hang fix (#1955)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HCDZcBpP6QQa4dzUa8z6rh
2026-09-09 11:40:13 -07:00
Palash DebnathandClaude Fable 5.1 09a260bb26 fix(backend): stop Windows desktop launches freezing at "Loading ML runtime"
Every backend spawned by the Windows desktop shell hung forever in the
startup worker's `import torch`, inside the loader for numpy's OpenBLAS
DLL. The desktop parent-liveness watchdog (0a20aeb0) parks a synchronous
read on the stdin pipe the shell hands the backend, and that pending read
deadlocks the DLL initializer. The identical command from a terminal, with
no stdin pipe and no watchdog, starts in seconds — which is why it only
reproduced under the app.

Bisected outside the app by spawning the backend with the shell's exact
env, pipes, creation flags and job object: a watchdog thread that merely
sleeps is harmless; a pending ReadFile, via the C runtime or straight to
the kernel, hangs it every time. Native stacks (py-spy --native) show the
watchdog in NtReadFile and the importer waiting on a critical section from
inside the OpenBLAS initializer.

Fix: on Windows the watchdog polls PeekNamedPipe and reads only bytes that
are already buffered, so no I/O is ever outstanding on the pipe. It still
exits the instant the desktop closes its end (ERROR_BROKEN_PIPE), and a
non-pipe stdin keeps the shared blocking reader. Verified: the app-style
spawn goes from an indefinite hang to ready in ~3 s, and the desktop-prod
build boots and loads the model.

Not in v0.5.1; the watchdog landed 2026-08-30 on main.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HCDZcBpP6QQa4dzUa8z6rh
2026-09-09 11:39:50 -07:00
Palash Debnath a754faec04 docs: link dictation changes to PR 1952 2026-09-09 18:58:27 +05:30
Palash Debnath 8fc003ad7c Merge remote-tracking branch 'origin/main' into feat/local-workspace-dictation-polish 2026-09-09 18:55:28 +05:30
Palash Debnath 99a534882c feat: improve dictation controls and creative workspaces 2026-09-09 18:55:19 +05:30
Chang-Jin-LeeandClaude Opus 5 81f889f3ff fix(errors): anchor the JSC frame pattern so a header cannot pose as one
Greptile on #1924: the second alternative in FRAME_LINE was unanchored, so a
V8 HEADER whose message happens to read `... user@chrome-extension://...`
matched as a JSC frame. FRAME_URL then took the message's URL as the throw
site and suppressed the report -- the same false positive the previous commit
fixed, one layer down.

The round-1 test missed it because its message carried a chrome-extension://
URL with no `@` before it, so the header never matched either alternative.

A JSC frame is `fn@url` and a function name has no spaces, so the `@` must be
reachable from the line start through non-whitespace only: `^\s*\S*@`. A V8
header is `Name: message`, so the space after the colon stops the match. Both
stack dialects still work, including an anonymous Firefox frame that begins
with the `@`.

Two tests: our error whose MESSAGE contains `user@chrome-extension://` with
our frames below is still reported (red before), and a bare
`Y@chrome-extension://...` with no header line at all is still recognised as a
frame, so the anchor does not cost the Safari/Firefox shape.

Full suite 328 files / 2740 tests.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Chang-Jin-Lee <ckdwls525@gmail.com>
2026-09-09 22:13:00 +09:00
michaelhuamanfloresandClaude Sonnet 5 693a43b26c fix(setup): stop misreporting low-VRAM caveat as kernel-launch risk
The GPU routing "accelerated" caveat branch in preflight and diagnose
always showed the driver/arch "may fail at kernel launch" fix hint,
even when the actual reason was a low-VRAM advisory unrelated to
drivers or torch. Gate that message on KERNEL_RISK_MARKER and show an
accurate VRAM-appropriate hint otherwise.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-09 07:47:18 -05:00
Chang-Jin-Lee d848c2eb3b Merge remote-tracking branch 'upstream/main' into fix/1847-bootstrap-log-retention 2026-09-09 12:55:59 +09:00
Chang-Jin-Lee d5d28ddabf Merge remote-tracking branch 'upstream/main' into fix/1866-engine-unavailability-reason 2026-09-09 12:55:59 +09:00
Chang-Jin-Lee 3622102ace Merge remote-tracking branch 'upstream/main' into fix/1848-bidi-start-truncation 2026-09-09 12:55:59 +09:00
Chang-Jin-Lee 31d7b4d251 Merge remote-tracking branch 'upstream/main' into fix/1859-launchpad-scroll-shrink 2026-09-09 12:55:59 +09:00
Chang-Jin-Lee 5e3af17d34 Merge remote-tracking branch 'upstream/main' into fix/1901-extension-error-reports 2026-09-09 12:55:59 +09:00
Chang-Jin-Lee 67ef5e22eb Merge remote-tracking branch 'upstream/main' into fix/tauri-clear-preserves-backend-stderr 2026-09-09 12:55:06 +09:00
Chang-Jin-Lee a84dc9e8ef Merge remote-tracking branch 'upstream/main' into fix/system-logs-rotation 2026-09-09 12:54:56 +09:00
marreiradigital b15fa1209a fix(download): log nao promete um fallback que ainda nao aconteceu
Achado do CodeRabbit (fora do diff) no PR #1942. Depois de desacoplar os dois
sinais, a mensagem passou a ser escolhida so por `_segmented_off` — mas na
penultima tentativa o plano devolve (True, True): o acelerador esta esgotado E
a tentativa re-lanca, entao o `snapshot_download` so entra na PROXIMA. O log
dizia "falling back to snapshot_download" enquanto na verdade ia retentar.

Sao tres estados distintos e ler so um sinal funde dois deles. A frase virou o
helper puro `_segmented_retry_note(disable, reraise)`, testado nos tres ramos —
inclusive o (True, True), que e o que a revisao pediu para cobrir.
2026-09-08 23:47:42 -04:00
marreiradigital 8a2c9a4828 Merge branch 'main' into fix/windows-dev-stack-and-download-resume
Conflito unico em `install_model`: a `main` (#1926) acrescentou
`and not allow_patterns` a condicao do acelerador, e este branch trocou
`_attempt == 1` por `not _segmented_off`. As duas guardas valem e foram
mantidas juntas.

O comentario acima da condicao ainda dizia que qualquer falha cai no
snapshot_download; atualizado para a regra atual (falha nao-transitoria, ou a
ultima tentativa), com ponteiro para `_segmented_retry_plan`.
2026-09-08 23:28:28 -04:00
marreiradigital adebe98e0f test(download): resolve tambem o import pre-existente em runtime
O `_segmented_enabled` no topo do arquivo viola a mesma instrucao de caminho
que o CodeRabbit apontou nos testes novos. Deixar metade do arquivo fora da
regra so garante que a proxima revisao aponte de novo.
2026-09-08 23:25:47 -04:00
marreiradigital 97e0e70bf2 fix(download): entrega o caminho simples so na ultima tentativa
Achado P1 do Greptile no PR #1942: com `disable` e `reraise` amarrados um ao
outro, a tentativa 4 de 5 desligava o acelerador E ja caia no
`snapshot_download` na mesma iteracao. Resultado: o acelerador ficava com 3
tentativas em vez de 4, e uma nova queda abandonava o manifesto reaproveitavel
uma tentativa antes do necessario, recomecando por um arquivo separado — que e
exatamente o que este helper existe para evitar.

Os dois sinais agora sao independentes: a tentativa que esgota o acelerador
ainda re-lanca, entao o caminho simples comeca na ULTIMA tentativa. Acelerador
fica com 1-4, `snapshot_download` com a 5.

Tambem blindei o caso de o acelerador falhar ja na ultima tentativa: ali nao ha
para onde re-lancar, entao a decisao vira "caminho simples agora" em vez de
estourar o laco sem nunca ter tentado o fallback.

Os testes do helper passaram a resolver o modulo da app em tempo de execucao,
como pede a instrucao de caminho para tests/**/*.py (import de modulo da app no
topo fica velho se um teste anterior sujar o sys.modules) — apontado pelo
CodeRabbit no mesmo round.
2026-09-08 23:25:30 -04:00
marreiradigital 66f7ef8cfe fix(download): reentra no acelerador na proxima tentativa apos queda
Achados do CodeRabbit no PR #1942.

O mais grave: com o erro classificado como transitorio, o codigo mantinha o
acelerador ligado mas caia direto no `snapshot_download` na MESMA tentativa. Se
esse download desse certo, o laco terminava e o manifesto do `.part` nunca era
reusado — exatamente o recomeco-do-zero que a correcao existe para impedir.

Agora o erro transitorio e propagado para o retry externo, cuja proxima
tentativa reentra no `_segmented_snapshot` e retoma do manifesto. A decisao
virou o helper puro `_segmented_retry_plan`, testavel direto (o laco mora dentro
de `install_model`, uma rota de ~200 linhas). A ultima tentativa fica reservada
para o caminho simples, entao o acelerador continua sem poder ser o motivo de um
install falhar de vez.

Tambem deste round de revisao:

- `Invoke-CimMethod ... Terminate` tinha o retorno descartado com `$null =`. O
  Win32_Process.Terminate reporta falha pelo ReturnValue, nao lancando: um kill
  negado por permissao era reportado como sucesso e a porta seguia presa. Agora
  o ReturnValue e validado, com exit 4 proprio e a mensagem carregando o codigo.
- O teste de concorrencia era vazio: o handler sincrono do MockTransport retorna
  antes de qualquer outra task rodar, entao `peak` nunca passava de 1 e a
  asserção `peak <= 4` passava sem exercitar o semaforo. Passou a segurar as
  requisicoes abertas com um asyncio.Event e a exigir `peak == 4` (verificado:
  com o semaforo afrouxado para 1000, o teste acusa 31).
- A doc dizia que OMNIVOICE_DOWNLOAD_MAX_WORKERS limita as faixas e que origem
  sem Range cai no snapshot_download. Nenhum dos dois: `_segmented_snapshot` nao
  passa `num_connections` (usa as 8 padrao) e origem sem Range vira stream unico
  dentro do proprio acelerador.
- Entradas de Highlights do CHANGELOG sem o `(#NNNN)` exigido.
2026-09-08 23:12:14 -04:00
marreiradigital d01fb5e7cc docs(changelog): aponta as entradas para as issues corretas
As issues #1940 (downloader segmentado sem progresso em conexao instavel) e
#1941 (stack de dev irrecuperavel no Windows) foram abertas para estas
correcoes; substitui os refs emprestados de #1224 e #1690.
2026-09-08 22:49:58 -04:00
marreiradigital bc22276fec docs(changelog): registra as correcoes de download e de dev no Windows
Entradas referenciadas a #1224 (truncamento de corpo no download) e #1690
(supervisor do backend de dev), que sao as issues que estas correcoes
estendem. Nao ha issue propria aberta para elas ainda.
2026-09-08 22:46:56 -04:00
marreiradigital db9e9d7fa1 fix(dev): permite destravar porta de dev presa no Windows
`canStop: !windows` fazia o script recusar qualquer parada no Windows com
"stop it in Task Manager and retry". O motivo original é legítimo: `taskkill
/pid` mira um PID reutilizável, e um PID reciclado entre o inspect e o kill
derrubaria um processo alheio.

Só que isso deixava o `bun run dev` permanentemente travado sempre que um
backend ficasse órfão — exatamente o cenário do commit anterior sobre a árvore
de processos. O predev falhava e não havia caminho de recuperação automático.

A parada agora é presa à INSTÂNCIA do processo: um único PowerShell busca a
instância CIM, confere o CreationDate contra a identidade já inspecionada e só
então chama Terminate NAQUELA instância. O terminate age sobre o objeto que a
checagem validou, não sobre um PID buscado de novo depois — a corrida some.
PID reciclado devolve exit 3 e é deixado em paz, em vez de falhar a execução.
2026-09-08 22:46:48 -04:00
marreiradigital e098d1280c fix(dev): normaliza caminho POSIX sem vazar a semantica do host
`belongsToCheckout(..., windows = false)` respeitava a flag na hora de montar
a string, mas normalizava o caminho com `resolve()` do host. Rodando no
Windows, "/work/VoiceStudio" virava "C:\work\VoiceStudio" e não casava com
nada numa linha de comando POSIX — o mesmo valia para o separador `sep`.

Efeito prático: o teste "command ownership requires a checkout path boundary"
já falhava na `main` limpa em qualquer máquina Windows, passando só no CI
Linux. Passa a usar `path.posix` quando a flag diz POSIX.
2026-09-08 22:46:29 -04:00
marreiradigital 2127aa7716 fix(dev): mata a arvore de processos do backend no Windows
O supervisor faz `spawn("uv", ...)` e o uv sobe o uvicorn como filho dele.
Windows não tem sinais: `child.kill()` vira TerminateProcess só no filho
DIRETO, então matar o `uv` deixava o uvicorn neto vivo segurando a porta 3900.
O spawn seguinte falhava com `[Errno 10048]`, o supervisor contava como crash,
e três desses derrubavam a stack inteira de dev — inclusive o Vite, via
`--kill-others-on-fail`.

`killProcessTree` usa `taskkill /T` no win32 e mantém o envio de sinal no
POSIX. Como o kill forçado devolve exit não-zero e sinal nulo, o reload que nós
mesmos pedimos passaria por crash; isso é tratado olhando se o tree-kill de
fato aconteceu, e não a plataforma — um crash de verdade durante um reload
continua indo para a recuperação de crash (coberto por teste que já existia).
2026-09-08 22:45:44 -04:00
marreiradigital 0d3fb07c1f fix(download): segmenta em blocos limitados e retoma o acelerador
O downloader segmentado gravava progresso no manifesto apenas quando um
segmento INTEIRO terminava, e dimensionava os segmentos como
tamanho/num_connections. Num blob de 806 MB isso dava 8 segmentos de ~100 MB:
numa conexão que cai a cada ~50 MB nenhum segmento jamais completava, o
manifesto nunca era escrito e cada tentativa recomeçava do zero.

Pior, o acelerador só rodava na PRIMEIRA tentativa (`_attempt == 1`), então
depois da primeira queda todas as retentativas iam para o `snapshot_download`
e o `.part` acumulado ficava órfão para sempre.

Agora os segmentos são limitados a 16 MB e a concorrência passa a ser
controlada por semáforo (antes vinha da própria contagem de segmentos), e o
acelerador é preservado entre tentativas quando o erro é de rede — reusando
`_is_retryable_download_error`, que já é a fonte única dessa classificação.
Ele só é desligado de vez quando a falha NÃO é transitória, ou seja, quando o
acelerador de fato não serve naquele host.

Reproduzido em rede real: `peer closed connection without sending complete
message body (received 54260979, expected 100708200)`.
2026-09-08 22:45:31 -04:00
dependabot[bot] 3ad31feccf chore(deps-dev): bump vitest from 4.1.9 to 4.1.11 in /frontend
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 4.1.9 to 4.1.11.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Changelog](https://github.com/vitest-dev/vitest/blob/main/docs/releases.md)
- [Commits](https://github.com/vitest-dev/vitest/commits/v4.1.11/packages/vitest)

---
updated-dependencies:
- dependency-name: vitest
  dependency-version: 4.1.11
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-09 00:18:48 +00:00
Palash Debnath 18f56a7940 Merge pull request #1926 from debpalash/feat/audiocpp-gpu-routing
feat(audiocpp): route native GPU backends
2026-09-08 23:53:34 +05:30
Palash Debnath 870b6f93ba fix(audiocpp): harden GPU runtime routing 2026-09-08 23:33:40 +05:30
Som 4c0bf2e010 fix(i18n): correct grammatical agreement in de/es/fr/pt/ru/sv consent.desc
CodeRabbit review on this PR caught real agreement errors in the
translations added for consent.desc (and de's try_dictation_desc
register):

- de: try_dictation_desc used informal du/deine while every other
  setup.* string in this locale uses formal Sie/Ihre — switched to match.
- es/fr/pt: adjectives after the anonymous-stats noun (feminine plural
  in each language) didn't agree in gender/number.
- ru: predicate adjectives didn't agree with the feminine noun
  "статистика".
- sv: adjectives didn't agree with "statistik" (en-gender noun).
2026-09-08 15:38:20 +00:00
Som 7d6f5c5b0c fix(setup): give the dictation step its own distinct rail label
Removing the redundant SectionHead (previous commit) left one more
duplicate on the dictation onboarding step: the step rail and
DictationDemo's own heading both said "Try dictation"/"Try Dictation" —
flagged by Greptile review on this PR.

Give the rail a genuinely distinct short label
(setup.dictation_step_label, "Dictation"), mirroring the consent step's
already-correct pattern (rail label vs. card title are different
strings). Translated into all 21 locales to hold the locale-parity
ratchet. Added a new test that renders the real DictationDemo (not
mocked to null, unlike the existing consent test) to prove the rail
label and the card's own title are distinct and each render exactly
once — the gap that let this ship undetected.
2026-09-08 15:36:54 +00:00
Palash Debnath 4f4dc7e068 fix(audiocpp): budget unknown GPU memory safely 2026-09-08 21:02:44 +05:30
Som 56a420a898 fix(setup): stop repeating the consent and dictation step titles
STEP_SUBTITLES.consent and STEP_SUBTITLES.dictation reused the exact
same i18n key as the step's title/label, and each step's body then
rendered a SectionHead with that same key again, on top of the step's
own content component rendering its own heading — showing the same
phrase 2-3 times on screen.

Give both steps a genuine short description (consent.desc,
setup.try_dictation_desc) for the header subtitle, matching the
system/models steps' existing pattern, and drop the now-redundant
SectionHead in each step's body since the content component
(AnalyticsConsentCard, DictationDemo) already renders its own title.

The two new keys are translated into all 21 locales to hold the
locale-parity ratchet (tests/test_locale_parity.py) at its current
baseline.

Closes #1855
2026-09-08 15:26:11 +00:00
Palash Debnath d5c0fa6f75 fix(worker): derive every engine capacity 2026-09-08 20:52:24 +05:30
Palash Debnath fe53e02693 fix(audiocpp): harden async and worker routing 2026-09-08 19:45:48 +05:30
Palash Debnath 56f8b616cc test(audiocpp): make CPU thread assertion portable 2026-09-08 19:10:44 +05:30
Palash Debnath f1016cdedd fix(audiocpp): budget low-memory Vulkan GPUs 2026-09-08 18:42:32 +05:30
Palash Debnath 68194c004d docs(changelog): note audio.cpp GPU routing 2026-09-08 18:32:46 +05:30
Palash Debnath 23dd8728d1 fix(audiocpp): preserve GPU routing across workers 2026-09-08 18:30:12 +05:30
Chang-Jin-LeeandClaude Opus 5 22ab31e0c7 fix(system): correct the Linux log path in the docstring, and follow the writer's override
CodeRabbit: the docstring said $XDG_STATE_HOME/VoiceStudio where the code says
OmniVoice. Checked against the writer rather than guessing which side was
wrong -- backend.rs::backend_log_path() joins "OmniVoice" on Linux, so the
code was right and the docstring was a pre-existing error. It matters because
that docstring is what gets read when telling a Linux user where the file is.

Reading backend_log_path() to settle it turned up something worth fixing in
the resolver this PR introduced: Rust checks OMNIVOICE_LOG_DIR before any
per-OS default, and nothing on the Python side knew about it. The backend is a
child of the shell, so an ambient override reaches both processes -- a
resolver that ignored it would look in the per-OS default while the writer
wrote somewhere else. That is the same divergence class as the desktop Logs
panel in #1782, and leaving a newly added resolver knowingly wrong was not an
option.

Two tests: the override moves both candidates, and a whitespace-only value
falls back to the default, matching the writer's !dir.trim().is_empty() guard.
The platform parity test now also clears OMNIVOICE_LOG_DIR so it stays a
statement about the defaults.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Chang-Jin-Lee <ckdwls525@gmail.com>
2026-09-08 21:46:35 +09:00
Palash Debnath fc237d3929 fix(audiocpp): harden native GPU routing 2026-09-08 18:10:51 +05:30
Palash Debnath 260519d4ee Merge branch 'main' into feat/audiocpp-gpu-routing
# Conflicts:
#	CHANGELOG.md
#	backend/engines/audiocpp/__init__.py
#	backend/engines/audiocpp/bootstrap.py
2026-09-08 17:29:25 +05:30
psiberfunk 9b1f2149ec Merge upstream main into fix/bootstrap-splash-observed-stages-1894 2026-09-08 07:23:38 -04:00
psiberfunk 311ff43de0 Merge upstream main into fix/run-sentinel-clear-before-slow-shutdown-1895 2026-09-08 07:22:34 -04:00
Palash Debnath 8f140e550d Merge pull request #1891 from debpalash/work/local-audiocpp-catalogue
feat(audiocpp): add CPU Breeze-TTS-2 backend and responsive catalogue rows
2026-09-08 16:43:12 +05:30
Palash Debnath 25c41e630c fix(audiocpp): gate readiness on model 2026-09-08 16:29:28 +05:30
Palash Debnath ffc5c07949 fix(audiocpp): require explicit model install 2026-09-08 16:21:08 +05:30
Palash Debnath 503407272e feat(audiocpp): route native GPU backends 2026-09-08 15:05:23 +05:30
Palash Debnath 6b2683eb32 fix(audiocpp): replace stale model aliases 2026-09-08 14:51:42 +05:30
Chang-Jin-LeeandClaude Opus 5 4999bac7a8 fix(system): stop the Tauri tab's Clear from wiping the backend's stderr
/system/logs/tauri/clear iterated every entry in _tauri_log_candidates() and
truncated each one, including backend_err.log -- the spawned backend's stderr.
Three things make that data loss rather than a tidy-up.

The tab that owns the button does not show it. On desktop the Frontend/Tauri
panel goes through the Rust read_log_tail command, whose tauri_log_path()
resolves tauri.log and nothing else, so the user truncates a file they were
never shown.

backend.rs::open_err_log_for_run() opens it APPEND-ONLY so "a respawn must not
destroy the previous run's evidence" (#1510) and rotates it to .1 rather than
truncating. It manages its own size; clearing it from here only undoes that
design. The same file's spawn diagnostics are described there as "retained in
backend_err.log across runs and lands verbatim in bug reports".

A native death -- a Windows access violation, a SIGSEGV -- writes nothing to
the Python log by construction, so this file is the only record it happened.
#1777 and #1782 are both threads where the maintainer had to ask a reporter
for it by hand.

Clear is narrowed to the shell's own log. The READ path is unchanged: the
candidate list was split into two halves and recomposed, and a parametrized
test pins that /system/logs/tauri still reaches all four files in the same
order on darwin, linux and win32 -- the recompose is where a slip would
silently hide a log.

Refs #1510

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Chang-Jin-Lee <ckdwls525@gmail.com>
2026-09-08 18:04:05 +09:00
Palash Debnath 132fdf313e fix(audiocpp): support cross-filesystem model aliases 2026-09-08 14:34:00 +05:30
Palash Debnath 9bfa3ec751 fix(audiocpp): ship verified CPU runtime 2026-09-08 14:27:19 +05:30
Chang-Jin-LeeandClaude Opus 5 c637166f02 fix(errors): read the origin off the first stack FRAME, not the header
Both bots caught the same defect from opposite sides, and both were right.
`err.stack` starts with a header line carrying the message, and the regex
scanned the whole string for the first URL -- so a URL in the MESSAGE was
mistaken for the throw site.

Greptile's half: an extension error reading "Failed to fetch
https://example.com" reported the message's URL as its origin and escaped the
filter. The bug this PR exists to fix, surviving inside the fix.

CodeRabbit's half, and the worse one: one of OUR failures that happens to
quote a chrome-extension:// URL in its text was suppressed as if an extension
had thrown it. A false positive here silences a real bug, which is strictly
worse than the noise it saves.

Frame detection now covers both stack dialects -- V8's "    at fn (url:1:2)"
after a header, and JSC/SpiderMonkey's "fn@url:1:2" with no header at all --
and reads the URL off the FIRST frame only. When that frame names no URL (a
native or anonymous throw site) the origin is unknown and the report IS
offered: walking deeper would attribute the error to a frame that did not
throw it.

Three tests added, all three red against the previous commit; against
upstream/main the two original extension cases and Greptile's are red, while
the two "still reports" ones pass there because upstream offers a report for
everything.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Chang-Jin-Lee <ckdwls525@gmail.com>
2026-09-08 16:58:27 +09:00
Chang-Jin-LeeandClaude Opus 5 658269d42f fix(errors): stop offering to report a browser extension's exception
A browser extension injected into the page throws into the page's own error
channel, so window.onerror surfaced it with a "Report this bug" action and a
user filed it. #1901 is one such report: the stack is entirely
chrome-extension://eppiocemhmnlbhjplcgkofciiegomcon/executors/200.js with no
VoiceStudio frame in it, and the message ("Cannot read properties of
undefined") gives a maintainer nothing to tell it apart from a real bug.

IGNORE_PATTERNS matches on the message and cannot help here -- an extension's
TypeError reads exactly like one of ours. The existing `Script error.` entry
covers only the opaque cross-origin case; an extension's script is not opaque,
so it arrives with a full stack and goes straight through.

Filter on the THROW SITE: `e.filename` when the event carries one, else the
first stack frame naming a URL. Deliberately not "any frame mentions an
extension" -- an extension that patches a built-in leaves its frame in the
middle of a stack whose fault is genuinely ours, and dropping those would
silence real bugs, which is worse than the noise it saves. A test pins that
case.

consoleBuffer still records these into Settings -> Logs -> Frontend. What is
suppressed is only the offer to file them against this project.

Closes #1901

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Chang-Jin-Lee <ckdwls525@gmail.com>
2026-09-08 16:50:18 +09:00
nidhi-singh02 ae85dd36e4 fix(colab): install ASR model before transcription and dubbing 2026-09-08 13:17:49 +05:30
Chang-Jin-LeeandClaude Opus 5 17fda0d79f fix(system): survive a rollover racing the read, and stop trusting the scan
Three review findings, all applied.

Greptile P1, read race: a rollover can rename a candidate between the
existence check and the open, and the handler exposes no lock a route can
take. Per-file OSError now skips that file instead of 500ing the whole panel
-- which is what the single-file version did in the same situation, so this is
strictly better than before rather than a new guarantee. A roll landing
mid-walk can still shift which chunk a file holds, so a tail taken at that
instant may repeat or miss a block; the panel re-polls every 5s and the next
read is clean. Buying strict consistency would mean reaching into logging's
internals from a route.

Greptile P1, clear race: enumerating first left a window where a rollover
created a backup after the scan and its history survived a Clear that
reported success. Clear now works off the fixed name set -- every name the
handler can write is known up front, so there is nothing to enumerate and no
snapshot to go stale.

CodeRabbit: the CHANGELOG lines ended in (#1782), which reads as "this fixes
#1782" when the desktop path defect that thread is about is untouched. Now
(#1920).

Two tests added, both red before: a candidate vanishing mid-walk still fills
the request from the next file, and a Clear whose scan reported nothing still
empties the backups.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Chang-Jin-Lee <ckdwls525@gmail.com>
2026-09-08 16:46:18 +09:00
Palash Debnath c6fbedbecb fix(audiocpp): resolve security review findings 2026-09-08 13:09:56 +05:30
Palash Debnath e2b5b3d6ed fix(audiocpp): validate the real pinned runtime 2026-09-08 13:02:35 +05:30
Chang-Jin-LeeandClaude Opus 5 15c6cc698d fix(launchpad): constrain the readiness checklist too
CodeRabbit was right: the invariant had a hole. `<ReadinessChecklist compact />`
is a fifth direct child of `.launchpad`, rendered when profiles or studio
projects exist -- which is the state the #1859 reporter was in. The first pass
gave shrink-0 to the three unconditional blocks and missed it, and the test
could not have caught it: the fixture rendered the EMPTY page, where that
branch does not mount.

Wrapped rather than passing the class down. ReadinessChecklist takes no
className, is mounted twice (nested inside the empty state as well as here),
and shrink-0 is a fact about this parent's flex column, not about the
component.

The test now runs the invariant over BOTH page states, because they render
different direct children -- empty gives the flex-1 empty state, populated
gives the checklist -- so checking one leaves the other unconstrained. The
ReadinessChecklist stub renders a marker node instead of null so the wrapper
the page owns is still findable.

Against upstream/main 3 of the 4 in this file are red; against the previous
commit, the two populated-page ones.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Chang-Jin-Lee <ckdwls525@gmail.com>
2026-09-08 14:42:19 +09:00
Chang-Jin-LeeandClaude Opus 5 3beebc6d57 fix(system): tail the backend log across a rollover, and clear the backups
main.py rolls omnivoice.log at 2 MB into .1/.2/.3, and /system/logs read only
the current file. For the minutes after a rollover the Backend tab showed a
handful of lines while up to 6 MB of history sat in omnivoice.log.1. Measured
with 3 lines in the current file and 500 in each of two backups: tail=200
returned 3 lines and reported total_lines: 3.

That is the panel CONTRIBUTING and the engine guides tell a reporter to paste
from, so the gap costs a round trip on every bug report that lands near a
roll.

The tail now reaches into the rotated siblings, but only when the current file
cannot satisfy the request -- the panel polls every 5s and opening 6 MB of
backups on each call would be a bad trade for a case that only matters right
after a roll. The response gains a `paths` list so a report can say whether
its tail crossed a boundary.

Clear is in the same commit because the two are coupled: it truncated only
omnivoice.log, so it freed almost nothing, and once the tail can see the
backups a Clear that leaves them looks like it did nothing at all.

Found while reading #1782, and it does NOT close it. That thread's blank panel
is the desktop path, which never reaches this route -- details in a comment
there.

Refs #1782

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Chang-Jin-Lee <ckdwls525@gmail.com>
2026-09-08 14:39:49 +09:00
Chang-Jin-LeeandClaude Opus 5 a9d90936ce fix(launchpad): let the page scroll instead of compressing its own hero
`.launchpad` is grid row 2 of `.app-container` and is itself a flex column
with `overflow-y: auto`. Opening the log panel grows grid row 4 and shrinks
row 2, which the shell is built for -- row 2 is supposed to hand the shortfall
to its own scrollbar.

It did not, because a flex item shrinks before its container scrolls. The
three content blocks under `.launchpad` carried the default flex-shrink: 1, so
they absorbed the shortfall: the hero is overflow-hidden, so it clipped its
own heading mid-line, and the deck moved up into the hero's artwork. That is
exactly what #1859 describes.

Measured in headless Chromium 153, 720px window, same nesting as the shell,
log panel at 560px:

  variant                       hero box/natural  clipped  deck top vs h1 bottom
  footer collapsed (28px)            145/145        no            +59
  current                             64/145       YES            -22
  + min-height:0 on .launchpad        64/145       YES            -22
  + shrink-0 on the children         145/145        no            +59

The third row answers the lead #1859 flagged as unconfirmed. The missing
min-height: 0 on `.launchpad` -- its two siblings, .app-container >
.main-content and .studio-panel, both set it -- is inert: overflow-y: auto
already zeroes a grid item's automatic minimum size, so the track was
shrinking correctly all along. Not adding it, because a rule that looks like
the fix and is not would mislead the next reader.

The test states the invariant rather than the three class names: a
`.launchpad` child either protects a height (shrink-0) or is deliberately
elastic (flex-1, which is what the empty state is). A fourth block cannot be
added unlabelled.

Not touched: the bell-icon-opens-a-log-console labelling mismatch the report
mentions as a separate observation.

Closes #1859

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Chang-Jin-Lee <ckdwls525@gmail.com>
2026-09-08 14:27:54 +09:00
Chang-Jin-LeeandClaude Opus 5 4b601ee6c1 fix(bootstrap): hold the run in a ref, and dedup only the handover seam
Two CodeRabbit Major findings, both applied.

O(n^2) retention was mine, introduced in the previous commit. Keeping the full
run in `logs` state meant `prev.concat([entry])` copied the whole array on
every event, so a 5000-line install did ~12.5M element copies and could
stutter the splash on exactly the verbose runs that need it. The run now lives
in `allLogsRef` and is pushed to (O(1)); `logs` state is back to holding only
the rendered tail, so the one array copied per event is bounded by
VISIBLE_LOG_LINES again. `totalLines` is what re-renders on a new line. Copy
reads the ref, and the two full-run scans (detectHints, isUnrecoverableFailure)
read it behind `isFailed`, when nothing is arriving any more.

Permanent dedup was pre-existing and does lose real output: installer text
repeats constantly, and any line matching one of the last five was dropped, so
the counter undercounted and Copy lost lines. The overlap it guards can only
happen on the first live event after backfill, so it now runs until the first
accepted line and never again. Telling a true repeat from a replayed one for
the whole run would need a sequence number from the Rust side; narrowing the
window to where the ambiguity actually is does not.

Three tests added: a repeated line survives, the backfill seam is still
deduped (regression guard for the narrowing), and the rendered state stays at
200 across a 5000-line stream, which is the invariant that keeps the append
cheap. Against upstream main 6 of the 7 in this file are red; the seam test is
a guard, not a fail-before.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Chang-Jin-Lee <ckdwls525@gmail.com>
2026-09-08 14:15:58 +09:00
Chang-Jin-LeeandClaude Opus 5 03c1396b14 fix(bootstrap): keep the whole first-run log, render only the tail
MAX_LOG_LINES = 200 capped the `logs` state itself, so on a cold install every
line past the 200th destroyed an earlier one. Four consumers read that array
and all four degraded once a real install ran past the cap:

- the Activity heading renders logs.length, so the counter sat pinned at 200
  for the rest of a multi-minute bootstrap while lines kept streaming. Live
  progress read as stalled when it was not. This is what #1847 reported.
- handleCopyLogs serializes the same array, so Copy could only ever return the
  newest 200 lines -- and this splash is the only place in the app with a
  copy-log affordance at all.
- detectHints(message, logs) scans for actionable failure markers. A failure
  early in a long install lost its marker, so the card fell back to
  hint_default and told the user nothing specific. This is the severe one: the
  screen still looks helpful while saying nothing.
- isUnrecoverableFailure(message, logs) runs off the same scan.

Only the <pre> needed the cap -- it is a DOM budget, not a retention policy.
Keep the run in state, slice at the one place that writes DOM, and rename the
constant to VISIBLE_LOG_LINES so the next reader cannot make the same mistake.

The array is bounded by one bootstrap: both retry paths clear it and App.jsx
unmounts the splash when the stage flips to 'ready'. The two full-array scans
are behind `isFailed`, so they never run while lines are streaming.

Not fixed here: the other half of #1847, that the splash vanishes on success
with no completion state and the log is then unrecoverable. That needs either
a lifecycle change in App.jsx or a Rust-side persisted stream, and the report
frames the two as separable.

Refs #1847

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Chang-Jin-Lee <ckdwls525@gmail.com>
2026-09-08 14:03:04 +09:00
Chang-Jin-LeeandClaude Opus 5 276bf626da docs(changelog): match the narrowed health-log wording
The entry said the log records "what kind of failure it was", which is the
overclaim Greptile flagged on the field itself. It records whether the probe
raised, and nothing about the cause.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Chang-Jin-Lee <ckdwls525@gmail.com>
2026-09-08 13:44:36 +09:00
Chang-Jin-LeeandClaude Opus 5 09a582c65a fix(engines): narrow the health log field to what the probe did
Greptile P1: `failure=unavailable` reads as a classification of the cause, but
SubprocessBackend.health_check() swallows its own exceptions by contract, so a
dead sidecar and a package that was never installed both return (False, msg)
and land in the same bucket. Rename to `probe=`, with `raised:<Class>` and
`returned-unavailable` as the two values, so the field states what the probe
did and claims nothing about why. The limitation and what it would take to fix
it properly (structured failure metadata from the probes) are named in the
comment and the test docstring.

Greptile P2: drop the trailing arrow glyph from the Learn more button. It sat
outside t(), and a bare "→" points the wrong way once the app switches to an
RTL locale. InfoHint hardcodes the same glyph and would want the same
treatment, but that is not this PR.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Chang-Jin-Lee <ckdwls525@gmail.com>
2026-09-08 13:43:36 +09:00
Chang-Jin-LeeandClaude Opus 5 adfe7b8588 fix(engines): give an unavailable engine row somewhere to send the user
Model Catalogue -> Engines can only ever say "Engine unavailable. Check
installation and configuration." and "Last error: A previous engine check
failed." for an engine whose package is not importable. That is by design:
public_backends() replaces reason and last_error because an availability probe
can carry exception text, a local path or a credential, and two of the shipping
is_available() implementations do interpolate an exception into their message.

So the row cannot explain itself. docs/engines/<engine>.md can -- accurate,
and for cosyvoice CI-guarded against the installer registry -- but nothing in
frontend/src referenced docs/engines at all, so the point of failure was a dead
end. #1746 is that dead end reaching the tracker.

Add a registry-authored docs_url next to install_hint and setup_snippet. It is
a VoiceStudio-owned constant keyed on the engine id, not probe output, so the
public scrub leaves it intact by construction rather than by classification --
which is what keeps the security boundary where the maintainer put it. The row
renders it with the same "Learn more" affordance MCPBindingsPanel and
RemoteBackendPanel already use, so no new i18n key is needed.

The health log line said "Engine health check failed; details withheld" and
named neither the engine nor the kind of failure, while the response tells the
user to check the backend log and docs/engines asks them to copy that engine's
lines. Log the registry id and a stable exception class -- the same class=
shape core.public_errors.public_failure() already logs. The diagnostic text
stays out and the id is flattened to one token, so
tests/test_response_safety.py's existing log-injection test passes unchanged.

Not touched: publishing the computed reason itself. That is the product
decision the reporter flagged, and the log line is deliberate, not an
oversight -- test_engine_health_route_logs_but_does_not_return_private_
diagnostic pins it.

Refs #1866

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Chang-Jin-Lee <ckdwls525@gmail.com>
2026-09-08 13:29:57 +09:00
Chang-Jin-LeeandClaude Opus 5 d3eb502395 fix(setup): isolate start-truncated paths from the bidi algorithm
The preflight detail line and the storage-path row set dir="rtl" purely to
move the ellipsis to the start of the line, so a long path keeps its tail
visible. That also makes the line an RTL paragraph, and the Unicode bidi
algorithm places a leading run of European numbers or neutrals at the visual
right edge of one. Every detail starting with a digit or a "/" therefore
rendered with its head at the end:

  48.0 GB total                 -> GB total 48.0
  /home/user/.cache/huggingface -> home/user/.cache/huggingface/

Letter-first details were unaffected, which is the signature of bidi
reordering rather than bad data; the backend emits these strings correctly
ordered.

Wrap the text in <bdi> at both call sites. The isolate is dir="auto", so the
run is ordered by its own content while the box keeps direction: rtl for the
ellipsis side. Measured in headless Chromium 153: "48.0" moves from x=49 to
x=0 and "total" from x=20 to x=46, and an overflowing path still has its head
clipped off the start (x=-142), so the start-side ellipsis survives.

jsdom resolves no bidi, so the regression test pins the DOM shape instead, and
a source scan fails any future dir="rtl" element that owns its text directly.

Closes #1848

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Chang-Jin-Lee <ckdwls525@gmail.com>
2026-09-08 12:28:28 +09:00
psiberfunk a88ad00bdf fix(audiobook): show the recovery manifest path 2026-09-07 23:02:36 -04:00
psiberfunk ceef6d66bd docs: place OmniVoice fix in highlights 2026-09-07 22:37:19 -04:00
psiberfunk 035add4c5c fix(audiobook): keep recovery actions available 2026-09-07 22:36:25 -04:00
psiberfunk 31abce74b6 test(engines): cover hidden MPS compatibility 2026-09-07 22:33:41 -04:00
psiberfunk 7668d045fa fix(audiobook): refresh resumable jobs after resume 2026-09-07 22:03:02 -04:00
psiberfunk 7157fd0fbe fix(engines): preserve hidden MPS compatibility state 2026-09-07 21:56:46 -04:00
psiberfunk fb98bbfaf6 fix(audiobook): surface interrupted renders 2026-09-07 21:55:40 -04:00
psiberfunk a935c08d6a fix(audiobook): scale chapter timeouts 2026-09-07 21:45:55 -04:00
psiberfunk 8d60929236 fix(engines): hide redundant OmniVoice MPS sidecar 2026-09-07 21:43:58 -04:00
psiberfunk 6e651ecbbd test(studio): cover progress prop forwarding 2026-09-07 20:16:38 -04:00
psiberfunk 4a53fd2668 fix(studio): show honest synthesis progress 2026-09-07 20:08:50 -04:00
psiberfunk 955c62e671 test(dictation): pin timeout completion race 2026-09-07 18:26:10 -04:00
psiberfunk 89c5d46660 test(dictation): cover acknowledgement failure 2026-09-07 18:15:40 -04:00
psiberfunk 70091bf97c fix(dictation): close delivery races 2026-09-07 18:11:12 -04:00
psiberfunk 0189b2a84f fix(dictation): report capture acceptance 2026-09-07 18:06:15 -04:00
psiberfunk 0d7625ee1a fix(dictation): make transcription capture actionable 2026-09-07 17:41:04 -04:00
psiberfunkandClaude Opus 5 5d99271865 style(test): satisfy oxfmt on the widget pill shadow test
"Tests (backend + frontend)" was failing on this branch: the backend suite
passed (7059 tests) and the frontend suite passed, but `bun run format:check`
flagged src/test/widgetPillShadowClip.test.jsx. Formatting only — no
behavioural change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 15:20:16 -04:00
psiberfunkandClaude Opus 5 b5879343a0 fix(bootstrap): treat leaving failed as a new attempt
Review finding on 5e9538a0. The reset keyed only off arriving at a restart
stage, so a retry whose restart stage the poll never sampled did not reset at
all: failed -> checking -> starting_backend inside one ~1s window surfaces as
failed -> starting_backend, leaving the FAILED attempt's stages in
polledStages and rendering its install chrome as this attempt's completed
work. Not merely a late boundary — no boundary.

retry_bootstrap / clean_and_retry_bootstrap are the only exits from `failed`,
so leaving that stage is itself proof a new attempt began. Keying off it as
well as off restart stages closes the case without new producer state.

Regression test fails against 5e9538a0, passes here. Suite green (25 tests).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 14:05:19 -04:00
psiberfunkandClaude Opus 5 5e9538a049 fix(bootstrap): open the attempt boundary when a retry starts, not when polled
Review finding on ece08bd7. The attempt boundary was stamped when the ~1s
status poll first reported `checking` — which lands after the Rust side has
already emitted the new attempt's first log lines. Those lines were then
filtered out as belonging to the previous attempt, so a fast stage that the
poll also missed stayed pending: the exact evidence loss the log union was
added to prevent.

Retries we initiate now open the attempt in beginAttempt(), at initiation, so
their boundary is exact. A guard stops the stage-transition effect from
re-stamping a boundary we already set a poll interval earlier — without it
the fix would have been undone one tick later.

The effect remains the fallback for restarts begun on the Rust side, where
the poll is the only signal available. That window is documented rather than
hidden: it fails toward showing a step pending (conservative and honest)
rather than done (the fabrication this PR removes). Closing it entirely needs
a Rust-provided attempt id — a new IPC surface, deliberately out of scope.

Regression test fails against ece08bd7, passes here. Suite green (24 tests).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 14:02:15 -04:00
psiberfunkandClaude Opus 5 ece08bd790 fix(bootstrap): derive observed stages from logs, and reset them on retry
Two review findings on #1896, both real:

1. Polling misses completed stages. `bootstrap_status` is sampled ~1/s, so a
   stage that starts and finishes between samples was never recorded — on a
   fast disk `creating_venv` routinely does — and would render pending
   forever even though it ran. The stage-tagged `bootstrap-log` stream is
   emitted as the work happens, so a line tagged with a stage is independent
   proof that stage ran. The observed set is now the union of the two; the
   comment claiming the poll "guarantees" a stage lands at least once was
   wrong and is gone.

2. Retry kept stale stages. The observed set was add-only and the splash
   stays mounted across a Retry, so a stage the failed attempt reached would
   still render done in the new attempt even when that attempt skipped it —
   the exact fabrication this change exists to remove. Arriving back at a
   restart stage from anywhere else now starts a fresh attempt. Keyed off the
   stage transition rather than our own Retry buttons, so a Rust-side restart
   resets it too. Log evidence is filtered to the current attempt; the
   visible log is deliberately left alone (clearing it would destroy the
   user's context, cf. #1847).

Regression tests added for both; each fails against 1c344bf9 and passes here.
Full BootstrapSplash suite green (6 files, 23 tests).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 13:57:02 -04:00
psiberfunkandClaude Opus 5 e3e8e80888 fix(lifecycle): scope the sentinel-clear comment honestly for Windows
Greptile P1 on #1897: the comment claimed the moved clear_sentinel() sits
"comfortably inside any shutdown deadline, including Windows' effectively-zero
one". That is false. On Windows tools.rs terminates the job object with no
graceful phase, so lifespan teardown never begins and this line is never
reached — a deliberate quit is still misreported as a crash there.

The code change is unaffected and still correct for the platforms where
teardown does begin. Only the claim was wrong, so only the claim changes.
Windows needs the shell to signal deliberate intent before the hard kill,
which is a Rust-side change tracked separately.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 13:52:42 -04:00
psiberfunkandClaude Opus 5 4ad5aa2831 fix(lifecycle): clear the run sentinel before the slow shutdown work
Measured on macOS build 0.5.2-153: a backend given SIGTERM directly
completes graceful shutdown in 5.25s and clear_sentinel() runs
correctly. But the desktop shell's quit path
(frontend/src-tauri/src/bootstrap.rs:388) grants only a 2s grace
before force_terminate()+kill(), and Windows
(frontend/src-tauri/src/tools.rs:522-528) grants no graceful phase at
all. clear_sentinel() used to be the LAST statement of lifespan
shutdown (backend/main.py:1213), behind ~50s of bounded waits and
model unload/free_vram()/gc.collect()/httpx close — so a deliberate,
clean quit routinely got SIGKILLed before reaching it, leaving
run_sentinel.json behind for the next launch to misreport as a crash.

Move the sentinel clear to the TOP of the shutdown block, immediately
after `yield`: once uvicorn has begun graceful shutdown the exit is
deliberate by definition, so the sentinel has already done its job.
One os.remove is comfortably inside any shutdown deadline, including
Windows' effectively-zero one. The later clear_sentinel() call is
removed (not duplicated) so a later failure in this function can't
mask the early result; the truthful "Shutdown: done."/degraded log at
the end now reads that earlier return value instead of re-clearing.

Adds a regression test that forces a later shutdown step
(model_loads_begin_shutdown) to raise, simulating the kill hitting
mid-teardown, and asserts the sentinel is already gone and
detect_unclean_shutdown() reports no crash. Confirmed fail-before /
pass-after against this change.

Fixes #1895

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 13:48:37 -04:00
psiberfunkandClaude Opus 5 1c344bf9ec fix(bootstrap): stop showing first-run install steps on warm starts
BootstrapSplash derived step "done" state purely from STEPS.indexOf(stage),
so a warm start (bootstrap.rs finds the venv healthy and jumps straight from
Checking to StartingBackend) rendered downloading_uv/creating_venv/
installing_deps as fabricated green DONE ticks, including the "first run,
5-10 min." label. A repair sync (venv exists, only InstallingDeps runs) hit
the same fabrication, and JourneyRail hardcoded Setup=done/Installing=active
regardless of stage.

Track which stages are actually observed (sticky, via the ~1s
bootstrap_status poll) and derive doneness and journey-chrome visibility from
that instead of list position. Journey rail, the "Installing" heading, the
step list, and the resume note stay hidden until a genuine install stage
(downloading_uv/creating_venv/installing_deps/awaiting_setup) is observed;
the masthead, live stage label, progress meter, and activity log are
unaffected. No new user-facing strings.

Fixes #1894

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 13:48:18 -04:00
杨月政andCursor 37aea507a4 fix(setup): lengthen HF connectivity probe timeouts to 8s
China / high-latency paths often need 3–5s just for TCP to
huggingface.co or hf-mirror.com; the previous 2s/3s probes
falsely reported Unreachable on port 443 and could hard-fail
older preflight builds.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-07 23:18:33 +08:00
杨月政andCursor 9979f1a84e fix(bootstrap): apply China PyPI mirror on repair uv sync
Repair previously called apply_uv_env without UV_INDEX_URL, so China
region installs still hit pypi.org for hatchling and failed with
tls handshake eof while the UI showed 中国 (镜像). Fold index selection
into apply_uv_env so first-run, drift, repair, and pip repairs share it.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-07 23:04:24 +08:00
Palash Debnath af216d8411 docs: reference local work draft PR in changelog 2026-09-07 20:21:47 +05:30
Palash Debnath 65ea0dc376 feat: preserve audio.cpp backend and responsive catalogue work 2026-09-07 20:20:54 +05:30
psiberfunkandClaude Opus 5 3105647afb test(capture): assert the error detail, not just a differing title
CodeRabbit: the previous assertions passed for any non-empty title that
differed from the visible text, so a fallback to the label would have
satisfied them — they did not prove `errorInfo.message` takes precedence.

Match on "audio group", which lives only in capture.mic_hint_linux and never
in the label, so a fallback or an unrelated tooltip fails the test.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 10:07:14 -04:00
psiberfunkandClaude Opus 5 50be1944b4 test(capture): cover the error branch of the pill title
CodeRabbit: only the setup title was covered. Add the error branch that
carries a message, asserting the title is strictly more than the visible
clipped text. The no-message branch falls through to `label` and is covered
by the setup-state test.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 10:02:23 -04:00
psiberfunkandClaude Opus 5 e014d63253 test(widget): pin the pill's content width instead of bounding it
CodeRabbit: the max-width assertion used `<=`, so a future cap of 200px
would pass while silently narrowing the pill and clipping more of the label
— the truncation #1884 is about. Assert equality with the real content box
(WINDOW_WIDTH - GUTTER * 2) so the required width is pinned, not just
bounded.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 10:00:58 -04:00
psiberfunkandClaude Opus 5 55bcfbdb6a test(macos): make the pill-visible reopen case actually discriminating
CodeRabbit correctly flagged the regression test as tautological: with a
single `main_window_visible` argument, `should_restore_on_reopen(false)`
passes under the aggregate `has_visible_windows` rule too, so the test gave
no protection against the bug it was written for.

Take Cocoa's aggregate flag as a second, deliberately-ignored parameter and
pass it from the event arm. That lets the test state the contract that
matters — main window hidden, pill visible, still restore — and it now fails
if the body ever reverts to deciding on the aggregate.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 10:00:26 -04:00
psiberfunkandClaude Opus 5 12b398b662 fix(dictation): stop clipping the widget pill's drop shadow into a rectangle
The `widget` Tauri window is exactly 300x64 with an 8px body padding on
every edge around the 48px pill, leaving only an 8px gutter before
`overflow: hidden` clips anything painted outside it. `.capture-pill`'s
shared shadow (`0 8px 32px` + `0 2px 8px`, ~40px of needed clearance) had
nowhere to go there, so it hard-clipped into a straight edge at the
window boundary — a rounded capsule sitting inside a hard-edged dark
rectangle instead of floating free over the desktop. The recording/
transcribing state shadows had the same problem and fully override the
base shadow, so the clip would reappear the instant dictation started.

Scope a tighter shadow to `html[data-window='widget']` for the base pill
and both state variants, each layer verified to keep
`|y-offset| + blur + spread <= 8` (the gutter), and cap `max-width` to
the window's 284px content box (the shared 340px value is wider than the
window itself). The main-window `.capture-pill-host` path is untouched —
it has real clearance and its shadow already renders correctly there.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 09:43:32 -04:00
Palash Debnath 9790d28922 Merge pull request #1883 from debpalash/codex/fix-windows-nonadmin-smoke
fix(ci): prepare hosted Windows policy for non-admin MSI smoke
2026-09-07 18:43:14 +05:30
psiberfunkandClaude Opus 5 7736e9cc60 fix(macos): key Reopen on the main window, not any visible window
The first revision of this handler gated the Dock-icon restore on Cocoa's
`has_visible_windows`. That is too coarse for this app: the dictation pill
is a second, always-on-top window (`widget`) shown and hidden independently
of the main window, and its Accessibility-setup state stays on screen until
the permission is granted.

So with the main window closed and the pill up, Cocoa reports
`has_visible_windows: true`, the guard returns false, and clicking the Dock
icon still does nothing — the exact failure this handler was added to fix.

Ask the main window directly instead. `is_visible()` fails only if the
window is gone, and a redundant show is harmless next to a Dock icon that
stays dead, so an error is treated as "not visible".

Adds a regression test naming the pill case so the coarse predicate cannot
come back.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 09:09:34 -04:00
psiberfunkandClaude Opus 5 fdeb8a40fc fix(desktop): handle Dock-icon reopen on macOS (#1887)
Closing the main window with the traffic light hides it (CloseRequested
never destroys it, by design) but the app.run() loop only handled
ExitRequested — there was no RunEvent::Reopen arm anywhere in the
crate, so clicking the Dock icon with no visible windows did nothing.
The window was only recoverable via the tray's "Show VoiceStudio" item
or a full quit/relaunch.

Add a macOS-gated RunEvent::Reopen arm that runs the same
show/unminimize/focus sequence as the tray's "show" handler, now
factored into a shared show_and_focus_main_window() so both recovery
paths can't drift apart. The restore decision (skip when a window is
already visible) is split into a pure should_restore_on_reopen() helper
so it's unit-testable outside the real Cocoa event loop, following the
file's existing with_noactivate_style/is_app_origin pattern.

Scope: macOS-only implementation of a macOS-only platform convention.
Does not touch CloseRequested's hide-instead-of-close behavior, and
does not add multi-window support (out of scope per #1887).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 09:06:09 -04:00
psiberfunkandClaude Opus 5 ebbe74b14b fix(dictation): give the setup-state pill label a hover tooltip
The pill's label <span> only ever set `title` for state === 'error';
every other state, including 'setup', rendered `title={undefined}`.
The 300x64 widget window leaves ~284px for the label after padding and
the status dot/button, so `capture.a11y_setup` ("Allow Accessibility
so dictation can type for you") clips to "Allow Acc…" with nothing to
reveal the rest on hover.

Reuse the already-localized `label` as the tooltip for every state,
keeping the richer error message where one exists. No new strings, no
locale changes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 09:00:12 -04:00
Palash Debnath 6a733a4c52 docs: reference installer smoke fix in changelog 2026-09-07 18:21:21 +05:30
Palash Debnath 5cde34c113 fix(ci): prepare hosted Windows policy for non-admin MSI smoke 2026-09-07 18:20:43 +05:30
Palash Debnath bd84169ff2 Merge pull request #1881 from debpalash/codex/fix-per-user-resource-snapshot
fix(windows): preserve frontend resources during per-user MSI build
2026-09-07 17:13:27 +05:30
Palash Debnath 4486b479a1 test: run generated asset hook inside MSI fixture 2026-09-07 16:44:14 +05:30
Palash Debnath 74aa444485 docs: reference installer resource fix PR 2026-09-07 16:43:01 +05:30
Palash Debnath e1e96ae5a2 fix: preserve frontend resources during per-user MSI build 2026-09-07 16:41:20 +05:30
Palash Debnath 0d39a5b283 test: exercise MSI build hooks with changing resource filenames 2026-09-07 16:40:12 +05:30
Palash Debnath 33ce88e465 Merge pull request #1874 from debpalash/codex/pr-queue-integration
chore(integration): land reviewed app, lifecycle and installer fixes
2026-09-07 15:51:52 +05:30
Palash Debnath 10a0fc27f0 Merge commit '63ade08b' into codex/pr-queue-integration 2026-09-07 15:30:30 +05:30
Palash Debnath 63ade08b6f fix(i18n): reuse translated token cleanup error 2026-09-07 15:30:09 +05:30
Palash Debnath fc7021e2b4 Merge commit '1038a487' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 15:26:02 +05:30
Palash Debnath 1038a487a8 fix(auth): gate onboarding replacement on known token state 2026-09-07 15:25:01 +05:30
Palash Debnath 19b9b4a136 Merge commit 'd9bf2516' into codex/pr-queue-integration 2026-09-07 15:09:06 +05:30
Palash Debnath d9bf251665 test(auth): exercise token paths on native backend hosts 2026-09-07 15:08:24 +05:30
Palash Debnath 5bc9f7856a Merge commit '8428517d' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 15:04:50 +05:30
Palash Debnath 8428517d95 fix(auth): preserve local Hugging Face token paths and cleanup 2026-09-07 15:03:12 +05:30
Palash Debnath 6caabf3b0b Merge commit '6b802bea' into codex/pr-queue-integration
# Conflicts:
#	tests/test_locale_parity.py
2026-09-07 14:29:30 +05:30
Palash Debnath 6b802beaf9 fix: complete compact engine family locale labels 2026-09-07 14:28:45 +05:30
yearthmain e059c4f330 docs(changelog): note the zh-CN locale completion (#1877)
Signed-off-by: yearthmain <yearthmain@gmail.com>
2026-09-07 16:56:13 +08:00
yearthmain 8998faa98b fix(i18n): translate all 486 missing zh-CN keys, tighten parity ratchet to 0
zh-CN.json was missing 486 of en.json's 3,057 leaf keys (baseline 486 in
_MISSING_BASELINE), so Settings / Models / Engines / Dictation surfaces
rendered English fallback. Translate every missing key following the ko
overhaul in #1776: brand and technical terms verbatim (Tauri, Discord,
Hugging Face, LLM, FFmpeg, torch.compile, DELETE), {{placeholders}}
preserved on all 70 keys that carry them, i18next tags (<1>, <code>,
<issueLink>) intact, existing translations and key order untouched.

Tighten _MISSING_BASELINE['zh-CN'] from 486 to 0 — zh-CN now matches
ko at full parity, verified with tests/test_locale_parity.py (248
passed).

Signed-off-by: yearthmain <yearthmain@gmail.com>
2026-09-07 16:47:30 +08:00
Palash Debnath 2ed38c476e Merge commit '99f93164' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
#	tests/test_locale_parity.py
2026-09-07 14:16:01 +05:30
Palash Debnath 078bc06428 Merge commit 'af245a45' into codex/pr-queue-integration 2026-09-07 14:15:11 +05:30
Palash Debnath 99f93164be fix: translate Hugging Face token source labels 2026-09-07 14:14:29 +05:30
Palash Debnath af245a45ee fix: complete workspace playback and engine translations 2026-09-07 14:14:28 +05:30
Palash Debnath dbbad3d58e Merge commit 'bcd2e531' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
#	docs/install/macos.md
2026-09-07 13:48:19 +05:30
Palash Debnath 8667b34ca5 Merge commit 'f18a7add' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
#	docs/install/macos.md
2026-09-07 13:47:50 +05:30
Palash Debnath bcd2e53175 fix(lifecycle): verify root exit after Darwin signal permission errors 2026-09-07 13:46:59 +05:30
Palash Debnath f18a7adddf fix(lifecycle): verify root exit after Darwin signal permission errors 2026-09-07 13:46:06 +05:30
Palash Debnath a968bc57b3 Merge commit 'f2cfdaa4' into codex/pr-queue-integration 2026-09-07 13:31:45 +05:30
Palash Debnath 7ac5e5ab3d Merge commit 'a768e84f' into codex/pr-queue-integration 2026-09-07 13:31:35 +05:30
Palash Debnath f2cfdaa430 test: assert first-sound Chinese taxonomy normalization 2026-09-07 13:31:12 +05:30
Palash Debnath a768e84ffe test: enforce device-neutral Confucius catalog label 2026-09-07 13:31:11 +05:30
Palash Debnath 4648c23256 Merge commit '24252712' into codex/pr-queue-integration 2026-09-07 13:19:19 +05:30
Palash Debnath 1e96748402 Merge commit '30307ae8' into codex/pr-queue-integration
# Conflicts:
#	.gitignore
2026-09-07 13:19:19 +05:30
Palash Debnath 169e36d5b6 Merge commit '0e7ee3d9' into codex/pr-queue-integration 2026-09-07 13:18:56 +05:30
Palash Debnath 135dd0a3a7 Merge commit '9dbf45ca' into codex/pr-queue-integration 2026-09-07 13:18:49 +05:30
Palash Debnath ef51c6b75d Merge commit 'e32bc942' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 13:18:49 +05:30
Palash Debnath 24252712d2 fix(moss): use declared device identifiers in install hint 2026-09-07 13:18:27 +05:30
Palash Debnath b49d2954d5 Merge commit '4008499e' into codex/pr-queue-integration 2026-09-07 13:18:20 +05:30
Palash Debnath bf8da941d1 Merge commit '3b64692e' into codex/pr-queue-integration 2026-09-07 13:18:11 +05:30
Palash Debnath ca3bf8367f Merge commit 'fc8db259' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 13:18:11 +05:30
Palash Debnath 0c255dfabd Merge commit '9afc9db2' into codex/pr-queue-integration 2026-09-07 13:17:45 +05:30
Palash Debnath 4008499ea5 fix(confucius): list supported device codes in the install hint 2026-09-07 13:17:37 +05:30
Palash Debnath e32bc94248 fix: preserve conversion state and finish workspace labels 2026-09-07 13:17:00 +05:30
Palash Debnath fc8db259a9 fix(bootstrap): prevent stale timeout after retry invalidation 2026-09-07 13:16:43 +05:30
Palash Debnath 0921292319 fix(confucius): keep catalogue hardware metadata accurate 2026-09-07 13:15:07 +05:30
Palash Debnath 9afc9db287 test(budget): resolve application modules at test runtime 2026-09-07 13:14:14 +05:30
Palash Debnath 3b64692eed fix(moss): align catalog install hint with accelerator routing 2026-09-07 13:13:49 +05:30
Palash Debnath 30307ae883 chore: ignore generated Windows MSI diagnostic artifacts 2026-09-07 13:13:36 +05:30
Palash Debnath 9dbf45ca2c test(onboarding): resolve the current runtime validator 2026-09-07 13:12:52 +05:30
Palash Debnath 0e7ee3d912 test(release): isolate cleanup module instances per test 2026-09-07 13:12:52 +05:30
Palash Debnath 140e9262b9 Merge commit '18a0c11c' into codex/pr-queue-integration 2026-09-07 12:47:40 +05:30
Palash Debnath 18a0c11c23 test(devices): clear mocked live probe cache 2026-09-07 12:44:32 +05:30
Palash Debnath a0b84a6b61 Merge commit '8c67b109' into codex/pr-queue-integration 2026-09-07 12:42:34 +05:30
Palash Debnath 8c67b10942 test(devices): patch the active capability module after reloads 2026-09-07 12:42:13 +05:30
Palash Debnath 760e9e5ac7 Merge commit '25498dd1' into codex/pr-queue-integration 2026-09-07 12:31:58 +05:30
Palash Debnath 25498dd17b docs(devices): explain optional DirectML fallback 2026-09-07 12:31:33 +05:30
Palash Debnath 16020c2178 Merge commit 'a41e66e0' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 12:28:46 +05:30
Palash Debnath e4471008b4 Merge commit 'df46b71b' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 12:28:27 +05:30
Palash Debnath 2823d6a8ea Merge commit '57150ede' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 12:28:06 +05:30
Palash Debnath 57150ede64 fix(moss): recover from accelerator probe failures 2026-09-07 12:26:04 +05:30
Palash Debnath df46b71be2 fix: tolerate Confucius and DOTS accelerator probe failures 2026-09-07 12:24:42 +05:30
Palash Debnath a41e66e0f0 docs: note capture widget hide permission repair 2026-09-07 12:23:48 +05:30
Palash Debnath 2b2bfe1a7f fix(capture): allow the widget window to hide after recording 2026-09-07 12:23:32 +05:30
Palash Debnath f728071819 Merge commit '59a487e7' into codex/pr-queue-integration 2026-09-07 12:13:44 +05:30
Palash Debnath 59a487e742 test: start upload watchdog at the blocked write 2026-09-07 12:13:29 +05:30
Palash Debnath ef9bda2e17 Merge commit 'e8a69508' into codex/pr-queue-integration 2026-09-07 12:09:10 +05:30
Palash Debnath e8a6950898 fix: allow exact nonsecret dubbing pane storage key 2026-09-07 12:08:47 +05:30
Palash Debnath 43d47f4d36 Merge commit '93bbfd64' into codex/pr-queue-integration 2026-09-07 12:04:25 +05:30
Palash Debnath 93bbfd64ea docs(device): explain optional accelerator probe fallbacks 2026-09-07 12:03:38 +05:30
Palash Debnath c973b1c983 Merge commit 'b4b10c14' into codex/pr-queue-integration 2026-09-07 12:03:21 +05:30
Palash Debnath c4530b4919 Merge commit '99218e2c' into codex/pr-queue-integration
# Conflicts:
#	frontend/src/components/Header.jsx
2026-09-07 12:03:21 +05:30
Palash Debnath b4b10c1431 fix(header): satisfy native Mac detection lint gate 2026-09-07 12:02:35 +05:30
Palash Debnath 99218e2c34 fix(header): satisfy native Mac detection lint gate 2026-09-07 12:02:15 +05:30
Palash Debnath b759ae7749 Merge commit 'ee3e1474' into codex/pr-queue-integration 2026-09-07 11:58:24 +05:30
Palash Debnath b2f5de328e Merge commit 'af7f1ceb' into codex/pr-queue-integration 2026-09-07 11:58:16 +05:30
Palash Debnath f2dd6c95db Merge branch 'codex/fix-per-user-msi' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 11:58:16 +05:30
Palash Debnath ee3e147401 test: prove upload revocation without scheduling threshold 2026-09-07 11:57:04 +05:30
Palash Debnath af7f1ceb3d test: construct heartbeat backend with lifecycle state 2026-09-07 11:56:16 +05:30
Palash Debnath 0cc22ad803 test: reject unresolved MSI authoring and invalid component identity 2026-09-07 11:56:13 +05:30
Palash Debnath 62b0e05c1d fix(windows): preserve registry separators during template expansion 2026-09-07 11:55:42 +05:30
Palash Debnath aed50121b4 docs: reference per-user MSI repair PR (#1873) 2026-09-07 11:54:25 +05:30
Palash Debnath 079be2fbe5 docs: describe automatic Windows MSI authoring validation 2026-09-07 11:52:41 +05:30
Palash Debnath f463276ca5 ci: validate both Windows MSI scopes with a tiny payload 2026-09-07 11:52:22 +05:30
Palash Debnath 5a1ada0757 fix(windows): give binary registry keypaths explicit stable GUIDs 2026-09-07 11:51:55 +05:30
Palash Debnath 6396cc2b3f style: format Windows installer authoring and regression tests 2026-09-07 11:49:37 +05:30
Palash Debnath 997ba9e673 fix(windows): author per-user MSI file keypaths and folder cleanup 2026-09-07 11:48:20 +05:30
Palash Debnath a438f5db0e Merge branch 'codex/fix-sidecar-timeout-reap' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 11:45:27 +05:30
Palash Debnath f72ab3a3b2 fix(sidecar): quarantine timeout owners until bounded cleanup succeeds 2026-09-07 11:41:18 +05:30
Palash Debnath 1d30a50c1c docs: reference sidecar recovery PR (#1872) 2026-09-07 11:30:21 +05:30
Palash Debnath c36df0ddf0 Merge branch 'codex/fix-sidecar-timeout-reap' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 11:29:26 +05:30
Palash Debnath 85cb7242ea fix(sidecars): finish timeout cleanup before allowing recovery 2026-09-07 11:28:13 +05:30
Palash Debnath c547da351c Merge branch 'codex/consolidate-1809' into codex/pr-queue-integration 2026-09-07 11:22:48 +05:30
Palash Debnath 602be02a17 Merge branch 'codex/review-1862' into codex/pr-queue-integration 2026-09-07 11:22:48 +05:30
Palash Debnath f395c90aa1 Merge branch 'codex/review-dialog-resolution' into codex/pr-queue-integration 2026-09-07 11:22:48 +05:30
Palash Debnath 01cb810c65 test(bootstrap): release launch gate before timeout assertion 2026-09-07 11:22:18 +05:30
Palash Debnath f4e5d7b9ab Merge branch 'codex/review-1806' into codex/pr-queue-integration 2026-09-07 11:22:11 +05:30
Palash Debnath caedcde0c6 Merge branch 'codex/review-logs-state' into codex/pr-queue-integration 2026-09-07 11:22:11 +05:30
Palash Debnath 2a36a24612 Merge branch 'codex/consolidate-1831' into codex/pr-queue-integration 2026-09-07 11:22:11 +05:30
Palash Debnath 610303ec11 Merge branch 'codex/consolidate-1830' into codex/pr-queue-integration 2026-09-07 11:22:11 +05:30
Palash Debnath 3a114d62dd test(header): isolate visual fixture system polling 2026-09-07 11:21:55 +05:30
Palash Debnath 65e6c275c6 fix(workers): retain conservative budgets for legacy missing workers 2026-09-07 11:21:39 +05:30
Palash Debnath 9a90fe41be test(vite): exercise conditional dialog alias configuration 2026-09-07 11:21:32 +05:30
Palash Debnath d55838542e fix(confucius): preserve legacy torch device selection 2026-09-07 11:21:13 +05:30
Palash Debnath 9c0a5469cc fix(moss): retain older manually provisioned torch environments 2026-09-07 11:21:12 +05:30
Palash Debnath c7a8d24af6 fix(logs): report failed refresh after clearing logs 2026-09-07 11:19:51 +05:30
Palash Debnath 7d963cf297 Merge branch 'fix/release-rerun-asset-collisions' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 11:19:07 +05:30
Palash Debnath b9cb6c204f Merge branch 'codex/review-1865' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
#	frontend/src/components/Header.jsx
2026-09-07 11:18:50 +05:30
Palash Debnath 6157c1717b Merge branch 'codex/review-1863' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 11:18:28 +05:30
Palash Debnath c3b54393c4 docs: record release retry recovery fix (#1871) 2026-09-07 11:17:30 +05:30
Palash Debnath f0bb3fb8b2 Merge branch 'codex/consolidate-1810' into codex/pr-queue-integration 2026-09-07 11:17:24 +05:30
Palash Debnath 157f2987dc fix(api): retain Node ESM compatibility for abortable delay imports 2026-09-07 11:17:24 +05:30
Palash Debnath 426bd1ecea fix(desktop): preserve macOS window behavior with native controls 2026-09-07 11:17:17 +05:30
Palash Debnath d34490fd15 docs: explain retrying partially published releases 2026-09-07 11:16:29 +05:30
Palash Debnath 9b9d4d6579 fix(header): reserve traffic-light space only in native Mac windows 2026-09-07 11:16:24 +05:30
Palash Debnath eee35ab771 Merge branch 'codex/consolidate-1831' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 11:16:00 +05:30
Palash Debnath 0095c4a089 Merge branch 'codex/consolidate-1830' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 11:15:51 +05:30
Palash Debnath ef30dbece7 fix(release): clear target asset collisions before retry uploads 2026-09-07 11:15:40 +05:30
Palash Debnath a9062c2fa1 Merge branch 'codex/review-logs-state' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
#	frontend/src/test/LogsFooterNotifications.test.jsx
2026-09-07 11:15:38 +05:30
Palash Debnath b7ebd6e54d Merge branch 'codex/review-hf-onboarding' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 11:15:16 +05:30
Palash Debnath cd58bbded0 fix(moss): align accelerator detection and routing status 2026-09-07 11:13:33 +05:30
Palash Debnath b9183bb2a6 fix(engines): align accelerator metadata and DOTS runtime precision 2026-09-07 11:12:38 +05:30
Palash Debnath e9495beb8b fix(auth): inspect token presence locally until explicit validation 2026-09-07 11:12:26 +05:30
Palash Debnath 409dd016ce fix(logs): require successful current snapshots before all-clear 2026-09-07 11:11:46 +05:30
Palash Debnath db10e4b70f Merge branch 'codex/review-1862' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
#	frontend/src/test/visual/specs.jsx
2026-09-07 11:10:42 +05:30
Palash Debnath 3613b3d39b Merge branch 'codex/review-1861' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 11:10:11 +05:30
Palash Debnath 4277859a44 Merge branch 'codex/review-ui-1841' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 11:10:11 +05:30
Palash Debnath eefc45ec49 Merge branch 'codex/review-1821' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 11:10:11 +05:30
Palash Debnath 2f5a52f9eb Merge branch 'codex/review-1819' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 11:10:11 +05:30
Palash Debnath 729cad8912 Merge branch 'codex/review-1806' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 11:10:11 +05:30
Palash Debnath 86f9eda65f Merge branch 'codex/consolidate-1810' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 11:10:11 +05:30
Palash Debnath 32c96eeee4 Merge branch 'codex/consolidate-1809' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 11:10:11 +05:30
Palash Debnath f5d52e479e Merge branch 'codex/review-dialog-resolution' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 11:10:11 +05:30
Palash Debnath eafd94d0a6 Merge branch 'codex/review-oom-order' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 11:10:11 +05:30
Palash Debnath 2b5e3cdbc6 Merge branch 'codex/consolidate-1799' into codex/pr-queue-integration
# Conflicts:
#	CHANGELOG.md
2026-09-07 11:10:11 +05:30
Palash Debnath 2229a68cfc fix(gallery): calibrate preview guard against shipped speech fixtures 2026-09-07 11:07:16 +05:30
Palash Debnath 0581fb69fd Merge current main into PR #1819 2026-09-07 11:07:16 +05:30
Palash Debnath 85a368a08b test(header): verify reduced motion and responsive status visibility 2026-09-07 11:06:37 +05:30
Palash Debnath a8c57c816b test(onboarding): validate first-sound request against engine taxonomy 2026-09-07 11:05:30 +05:30
Palash Debnath 360d1d29c8 docs: record connection diagnostics fix under Unreleased 2026-09-07 11:04:51 +05:30
Palash Debnath 7366555c95 docs: record startup fix under Unreleased 2026-09-07 11:04:50 +05:30
Palash Debnath b8ff2721a5 fix(tts): normalize complete signed ranges without rewriting chains 2026-09-07 11:04:44 +05:30
Palash Debnath da26a240e2 Merge current main into PR #1821 2026-09-07 11:04:44 +05:30
Palash Debnath fb3d9b7139 fix(bootstrap): preserve retry cancellation across lifecycle acquisition 2026-09-07 11:03:42 +05:30
Palash Debnath 6c47ae7b21 fix(api): honor cancellation throughout transport diagnostic waits 2026-09-07 11:03:05 +05:30
Palash Debnath fda73384f0 fix(workers): retain granted deadlines across disconnects and restart 2026-09-07 11:02:45 +05:30
Palash Debnath 84add8b279 Merge current main into PR #1806 2026-09-07 11:02:27 +05:30
Palash Debnath 8b510d73db fix(ui): address workspace review findings and restore CI 2026-09-07 11:02:18 +05:30
Palash Debnath b1194c6223 test: cover nested and hoisted dialog dependency resolution 2026-09-07 11:02:06 +05:30
Palash Debnath 75f8924222 Merge remote-tracking branch 'origin/main' into codex/review-dialog-resolution
# Conflicts:
#	CHANGELOG.md
2026-09-07 11:00:31 +05:30
Palash Debnath 2a6d089f4a Merge remote-tracking branch 'origin/main' into codex/consolidate-1810 2026-09-07 11:00:17 +05:30
Palash Debnath 5d134f22ec test: enforce VRAM reclaim before clone prompt retry 2026-09-07 10:59:09 +05:30
Palash Debnath 08af0a971e Merge remote-tracking branch 'origin/main' into codex/review-oom-order 2026-09-07 10:58:32 +05:30
Palash Debnath ff0ce4d37d docs: keep pending transcription fix under Unreleased 2026-09-07 10:58:08 +05:30
Palash Debnath 1ab03067cf Merge remote-tracking branch 'origin/main' into codex/consolidate-1809 2026-09-07 10:58:01 +05:30
Palash Debnath 7a2f86066b fix(transcriptions): consolidate safe clipboard handling and regression tests 2026-09-07 10:57:08 +05:30
Palash Debnath d91beef0fd docs: credit Windows console help fix (#1815) 2026-09-07 10:56:19 +05:30
Palash Debnath 574b634688 Merge remote-tracking branch 'origin/main' into codex/review-cp1252 2026-09-07 10:55:45 +05:30
Palash Debnath 62ab62fc57 Merge remote-tracking branch 'origin/main' into codex/consolidate-1799 2026-09-07 10:55:05 +05:30
电车司机小李 ecbd152c43 fix(logs): avoid false all-clear state
Signed-off-by: 电车司机小李 <39351936+motodriver@users.noreply.github.com>
2026-09-07 11:51:02 +08:00
psiberfunkandClaude Sonnet 5 fec2e7b5f3 docs(changelog): credit the contributor for #1864
Greptile flagged the Unreleased entry as missing the contributor
credit the changelog convention requires for community PRs.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-06 21:02:33 -04:00
psiberfunkandClaude Sonnet 5 04bc9cedac fix(header): hide the custom window controls on macOS
macOS draws its own native traffic-light cluster even with
decorations:false (tauri.conf.json's titleBarStyle:"Overlay" still
overlays it), but Header.jsx's showWindowControls only checked
whether the app was running under Tauri, not which OS — so the
custom Windows-style minimize/maximize/close row rendered on macOS
too, duplicating the native controls.

Gate it on platform using the same navigator.platform check already
used in HotkeyTab.jsx / SettingsSearch.jsx. Windows/Linux keep the
custom row since decorations:false gives them no chrome otherwise.

Fixes #1864.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-06 20:51:38 -04:00
psiberfunkandClaude Opus 5 e397e10d64 test(header): restore navigator.platform after mac-inset tests
CodeRabbit flagged that setPlatform() redefined navigator.platform as
an own property but nothing ever restored it, so after this file's
tests run the global stays pinned to whichever platform ran last
('Linux x86_64') — order-dependent and able to leak into any later
test in the same environment that reads navigator.platform. Capture
the original descriptor (undefined, since it's an inherited jsdom
getter) and restore it — or delete the own-property override — in
afterEach.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 20:33:58 -04:00
psiberfunkandClaude Opus 5 8e1da3c22f fix(firstrun): send a voice-design-safe instruct instead of omitting it
Greptile flagged that omitting `instruct` from the first-sound request
fixes OmniVoice (whose `_resolve_instruct` rejected the old free-text
prose) but breaks a different engine: mlx-audio's Qwen3 VoiceDesign
backend requires a truthy `instruct` and raises ValueError without one
(`_is_voice_design()` in backend/services/tts_backend.py), so a user who
picked that engine during onboarding would still get silent first-sound
failure — same bug class, different engine.

Send 'middle-aged, low pitch' instead of omitting the field: it's the
exact taxonomy string the backend's own "Narrator" personality preset
uses (backend/core/personalities.py), so it's valid vocabulary for
OmniVoice's `_resolve_instruct` and a non-empty description for any
voice-design engine. Rewrote firstSoundInstruct.test.js, which
previously asserted instruct was absent entirely (passing for the wrong
reason); it now asserts a non-empty, taxonomy-only instruct is sent and
cross-checks its value against personalities.py's narrator preset so the
two can't silently drift apart.

Also credited the community contributor in CHANGELOG.md per the repo's
own convention (Greptile P2) and promoted the entry to Highlights,
matching every other credited entry in the file.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 20:32:25 -04:00
psiberfunkandClaude Opus 5 b92cc3bb79 fix(setup): keep the overwrite warning visible on narrow screens
CodeRabbit flagged that the hf_token_replace_warning text shared the
same `max-[560px]:hidden` class as the dismissable "add a token" pitch,
so a user replacing an already-active token on a narrow viewport (mobile
width, or a small first-run window) never saw the warning that doing so
clobbers the working token. Only the pitch should hide at that width —
the overwrite warning is safety copy and must always render. Added a
regression test asserting the warning's className never carries the
responsive-hide class.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 20:26:33 -04:00
psiberfunkandClaude Opus 5 d757f160fa fix(header): inset the breadcrumb clear of macOS traffic lights
tauri.conf.json sets decorations:false + titleBarStyle:"Overlay" on
every platform, so on macOS the native traffic-light cluster is drawn
on top of the web content instead of getting its own row; Windows and
Linux draw nothing there. The header's left block (status dot +
kicker) had no inset at all for that zone, so on macOS the traffic
lights sat on top of it.

Fix, macOS-only: detect macOS the same way HotkeyTab.jsx /
SettingsSearch.jsx already do (navigator.platform), and apply a new
.header-area__left--mac-inset class that completes header-area's own
16px left padding to the same flat 64px-from-window-edge total that
.header-area--tabs already reserves for the identical cluster. Windows
and Linux get no inset, so no space is wasted where nothing is
overlaid.

Fixes #1860.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 19:53:18 -04:00
psiberfunkandClaude Opus 5 a9ac8b1b46 fix(header): stop the status dot pulsing under Reduce Motion
Header.jsx's status dot animates via the hqPulse keyframes, applied as
a Tailwind arbitrary [animation:...] utility. None of index.css's
twelve @media (prefers-reduced-motion: reduce) blocks named hqPulse
(it isn't a stable CSS class, so those selector-based blocks can't
reach it), so the purely decorative pulse kept running with OS Reduce
Motion on.

Fix: append motion-reduce:[animation:none] to the dot's className -
the same mechanism LogsFooter.jsx already uses for its own
arbitrary-utility pulses (heart-glow, donate-pop-in).

Part B only, per the issue split - Part A, an in-app motion toggle, is
a product decision and stays open.

Fixes #1857 (Part B).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 19:49:32 -04:00
psiberfunkandClaude Opus 5 f88bfecabc fix(firstrun): stop sending free-text instruct prose on first sound
App.jsx's post-onboarding "first sound" request appended a hardcoded
narrator prose string as `instruct`. Every engine's instruct is a
controlled vocabulary (OmniVoice's `_resolve_instruct` rejects
anything outside a fixed token list), so this 400ed on every first
run — silently, since the surrounding catch is deliberately silent
by design (a first impression must never surface an error).

Omit `instruct` entirely instead of swapping in valid vocabulary:
it matches every other call site in the app (`if (instruct)
fd.append('instruct', ...)`), matches the seeded demo profile's
empty stored instruct, and every engine backend already treats a
missing/empty instruct as "no styling" rather than a required field
— so this can't regress no matter which TTS engine is active.

Fixes #1853.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 19:46:15 -04:00
psiberfunkandClaude Opus 5 753891adc9 fix(setup): stop pitching an HF token when one is already active
HfTokenCard.jsx unconditionally rendered the "add a free Hugging Face
token" pitch in first-run's Models & engines step, even when the
backend had already resolved and validated one (app/env/hf-cli). Since
Save persists via huggingface_hub.login(), which overwrites the
canonical $HF_HOME/token file outright, complying with the unnecessary
prompt could silently clobber an already-working token.

The card now checks GET /system/hf-token/state (the same resolver the
Settings -> API Keys panel already consumes) before rendering:
- an active, validated token shows the source + masked value instead
  of the pitch
- replacing it requires an explicit "Replace..." click plus an inline
  overwrite warning, rather than one blind paste-and-Save
- a still-loading check shows a neutral placeholder
- a failed check falls back to the pre-fix pitch rather than hiding
  the card

Fixes #1851.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 16:54:26 -04:00
Palash Debnath 4efde9ce4e feat(ui): polish dubbing workspace layout and controls 2026-09-06 20:26:43 +05:30
li-lizhe ae2fa83b02 fix: handle None from current_accelerator(); exclude MPS in dots_tts
current_accelerator() returns None on CPU-only builds (no accelerator
compiled in), so .type would crash. Use check_available=True and fall back
to 'cpu' when None. For dots_tts, also select fp32 on MPS since
DotsTtsRuntime is untested on MPS.

Addresses greptile P1 + coderabbit Functional Correctness review comments.
2026-09-06 21:06:33 +08:00
li-lizhe a671004cb7 fix: handle None from current_accelerator() on CPU-only builds
current_accelerator() returns None on CPU-only PyTorch builds (no
accelerator compiled in), so accel.type would crash. Use check_available=True
and fall back to 'cpu' when None.

Addresses greptile P1 + coderabbit Stability review comments.
2026-09-06 21:06:19 +08:00
li-lizhe ed6fca46a9 fix(tts-engines): select device via torch.accelerator in confucius4 and dots_tts
Both Confucius4 and DOTS-TTS engine sidecars hardcode device selection to
`torch.cuda.is_available()`, which returns False on Ascend NPU, Intel XPU,
and other non-CUDA accelerators — causing the models to silently run on CPU
(in fp32) instead of the available accelerator.

Replace with `torch.accelerator.current_accelerator().type`, the
device-agnostic API that auto-detects CUDA, NPU, XPU, MPS, and CPU. MPS is
excluded for Confucius4 (upstream untested on Apple Silicon). dtype stays
bf16 for any GPU-class accelerator and fp32 on CPU.

Also verified on Ascend 910B (torch 2.14, torch_npu, 4 NPU):
  before: cuda_available=False → device "cpu", precision "float32"
  after:  accelerator → confucius4 device="npu", dots_tts precision="bfloat16"
2026-09-06 09:24:39 +08:00
li-lizhe 65d37288ce fix(moss_tts_v15): select device via torch.accelerator instead of CUDA hardcode
MOSS-TTS-v1.5 engine hardcoded device selection to
`device = "cuda" if torch.cuda.is_available() else "cpu"`. On an Ascend
NPU (torch_npu) host, `torch.cuda.is_available()` is False, so the whole
model silently runs on CPU in fp32 — never using the accelerator — even
though torch.accelerator reports `npu` and bf16 is supported.

Replace with the device-agnostic `torch.accelerator.current_accelerator()`
so any backend (CUDA / NPU / XPU / MPS) is picked up automatically. MPS is
still excluded (MOSS's upstream trust_remote_code modelling code is untested
on Apple Silicon); dtype is bf16 for any GPU-class accelerator and fp32 on
CPU.

Verified on Ascend 910B (torch 2.14, torch_npu, 4 NPU):
  before: torch.cuda.is_available()==False -> device "cpu", dtype float32
  after:  accelerator -> device "npu", dtype bfloat16
2026-09-06 09:23:22 +08:00
Palash Debnath 293b0812f4 feat(ui): organize dubbing controls and export drawer 2026-09-05 23:17:50 +05:30
Palash Debnath b441a486cc feat(ui): refine voice controls and expandable navigation 2026-09-05 22:37:02 +05:30
Palash Debnath d4bf1fe9a9 feat(ui): polish voice interactions and fix notification badge 2026-09-05 20:43:42 +05:30
Palash Debnath 5574cbbc16 fix(ui): name OmniVoice correctly and cycle active engine labels 2026-09-05 20:06:24 +05:30
Palash Debnath 13eae6ff02 fix(ui): show selected engine on title bar 2026-09-05 19:44:55 +05:30
Palash Debnath fd5e78cdab refactor(ui): simplify engine quick access with family tabs 2026-09-05 19:38:19 +05:30
Palash Debnath 67c316e81b feat(studio): consolidate engine controls and pin mode actions 2026-09-05 18:52:43 +05:30
Palash Debnath 81fb585557 fix(studio): anchor engine menu to header trigger 2026-09-05 17:51:57 +05:30
Palash Debnath 3675d750d6 fix(studio): reuse rich language picker for cloning 2026-09-05 17:46:08 +05:30
Palash Debnath bbbf185cf3 fix(studio): keep sticky language picker inside viewport 2026-09-05 17:11:24 +05:30
Palash Debnath 0c4ed0546f fix(studio): constrain sticky controls on short screens 2026-09-05 16:38:43 +05:30
Palash Debnath 17df9210cd fix(studio): pin synthesis controls below scrolling form 2026-09-05 16:26:13 +05:30
Palash Debnath aedca15f7e docs: record voice workspace tabs 2026-09-05 15:23:59 +05:30
Palash Debnath 7a14c31a8e feat(studio): promote voice modes to workspace tabs 2026-09-05 15:22:44 +05:30
Palash Debnath 53ff367c1f fix(studio): simplify voice cloning setup (#1817)
* fix(studio): simplify voice cloning setup

* docs: link cloning redesign changelog

* fix(studio): keep clone recording controls available

* fix(studio): lock clone capture transitions
2026-09-05 14:12:43 +05:30
flutterkage2kandClaude Opus 5 ed746bab57 fix(tts): speak the tilde in digit ranges instead of mashing the numbers
"20~30초" is read aloud as a single number — OmniVoice says "이십삼" (23).
The separator never reaches the listener, so any written range is heard as
the wrong figure.

`normalize_text` only ran its number pass behind `_num2words_lang`, which
returns None for ko/ja/zh/th/vi (those scripts read digits natively and are
deliberately outside num2words). Nothing else looked at the range mark, so
the tilde went to the engine untouched and the two numbers ran together.

Rewrite `N~M` into the spoken form before the engine sees it, outside the
num2words gate so the CJK languages are covered too. Verified by rendering
each candidate and transcribing it back (ko, OmniVoice, cloned voice):

    "대략 20~30초짜리"      heard "23초"           WRONG
    "대략 20-30초짜리"      heard "23초"           WRONG (reproduces it)
    "대략 20에서 30초짜리"   heard "20에서 30초짜리"  correct
    "20〜30分ぐらい" → "20から30分" heard "20〜30分くらい"  correct

Deliberately narrow:

* Only the tilde family (U+007E, U+301C, U+FF5E). Japanese and Korean IMEs
  emit the latter two. An ASCII hyphen is left alone — between digits it
  also spells dates, phone numbers and product codes, where "to" is wrong
  (`tests` already pin "pages 3-5" as unchanged).
* Only languages with a verified spoken form (ko/ja/zh/en). Anything else
  keeps its tilde, matching how `_PERCENT_WORD` is scoped.
* Spacing belongs to the form, not the caller: a Korean postposition binds
  to its numeral ("20에서 30"), Japanese and Chinese set no spaces, English
  needs them on both sides.
* Neighbour guards block digits and ASCII letters but allow CJK, because
  CJK writes the unit hard against the digits ("20~30초"); a `\w` guard
  rejects exactly the cases the rule exists for.

`ko`/`ja`/`zh` join `_FULL_NAME_TO_CODE` so the new resolver can see them.
They stay out of `_NUM2WORDS_LANGS`, so this does not open a num2words path
for them — the same inert-entry pattern the file already documents for
"vietnamese".

`backend/services/text_normalization.py` joins the functional-CJK allowlist
in tests/test_no_hardcoded_cjk.py, under the text-processing group and by
the procedure that file documents: the range words are engine input, not
user-facing UI strings.

Tests: 7 new change-cases and 8 new leave-unchanged cases (hyphen, date,
phone number, product code, decimals, a non-numeric tilde, an unverified
language, and no language at all). All 7 change-cases fail against the
previous implementation.

Full suites before and after: the same 17 failures, none of them touched by
this change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-05 17:06:15 +09:00
flutterkage2kandClaude Opus 5 847ca6d44c fix(desktop): resolve plugin-dialog wherever the package manager put it
`bun run desktop` dies before the window opens on a fresh clone:

    Error: ENOENT: no such file or directory, open
    '.../frontend/node_modules/@tauri-apps/plugin-dialog/dist-js/index.js'

The alias hardcoded `frontend/node_modules/...`, but this is a bun
workspace: bun hoists the package to the workspace root and leaves
`frontend/node_modules` empty, so the path the alias names does not
exist. Vite's dep optimizer reads it directly and throws, taking
`beforeDevCommand` — and the whole desktop shell — down with it.

Probe both layouts and fall through to Vite's own resolution when
neither is present, so a missing package degrades to normal resolution
instead of crashing the dev server.

Verified on macOS 26.6 (Apple Silicon), bun 1.2.22, fresh clone: the
window now opens and the backend serves.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-05 17:06:12 +09:00
flutterkage2kandClaude Opus 5 784494dc3c fix(gallery): measure spectral flatness per frame so real speech passes
Most gallery previews fail with "the voice engine returned no audible
audio for this archetype". The renders are fine — the guard is not.

Two problems, both in the degenerate-buzz check:

1. `_spectral_flatness` took ONE FFT of the whole clip. Spectral
   flatness is defined over short frames; a full-length transform gets
   finer frequency resolution the longer the clip is, so voiced
   harmonics carve deeper and deeper nulls and the geometric mean
   collapses. The number tracked clip length, not timbre.

2. `_DEGENERATE_FLATNESS = 0.015` was calibrated against
   `_speech_like()` in the unit test — a synthetic harmonics+noise
   stand-in that is far flatter than real speech. Real renders measure
   well below it, so the threshold sat inside the speech range.

Measured on this engine's own output (framed, per this patch):

    pure tone 80 Hz        2.6e-10    two-tone buzz    3.3e-09
    quietest real speech   2.0e-04    (VoxCPM2 ko)

Frame the measurement (1024/512, skipping inter-word frames at the
noise floor) and move the threshold to 1e-5 — ~3000x above the tonal
cases, ~20x below the quietest real render.

Before: 6 of 8 renders rejected; ml_japanese_explainer,
ml_japanese_companion and feat_23_the_explainer all 503 through
GET /archetypes/{id}/preview.
After: 0 false positives across 27 real clips (Japanese, Korean and
English archetypes, cloned voices, human reference recordings), and
those three previews return 200. Every accepted clip was confirmed as
real speech by transcribing it with the app's own ASR.

Not addressed: a render that collapses toward NOISE rather than a tone
still passes (one observed at flatness 0.073, ASR returns a
hallucination). The old threshold missed it too, so this is not a
regression — calibrating an upper bound needs more than one sample.

Tests: frame-based measurement must be clip-length invariant, and the
threshold must sit between the measured tonal ceiling and the measured
real-speech floor. Both fail against the previous implementation.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-05 17:05:59 +09:00
dajiaohuang 6c42b50fe3 test(ci): document cp1252 help regression 2026-09-05 05:21:45 +08:00
dajiaohuang 2594abebf8 fix(ci): keep install-docs help cp1252-safe 2026-09-05 05:17:34 +08:00
Palash DebnathandClaude Opus 5 e4f00bc564 fix(desktop): let Retry preempt the readiness wait
Greptile's P1 on #1809, and it is right. `launch_backend_and_wait` holds
`BackendState::lifecycle` around the entire launch, including the readiness
wait — which this branch just made unbounded for as long as the backend
answers `/startup/progress`. Retry, Clean & Retry, reset and uninstall all
need that same lock, so on a slow start the user's own escape hatch would
block behind the wait instead of interrupting it: an app with no way out,
which is worse than the early kill the branch set out to remove.

Every flow that is about to take lifecycle ownership now bumps a generation
counter first, before reaching for the lock. The waiting loop snapshots that
counter once its caller holds ownership — so a bump that predates it is not
mistaken for a preemption — and stands down within one 500 ms poll when it
changes, releasing the lock for whoever asked.

That also settles what happens at the splash's six-minute stall budget: it
flips to failed and offers Retry and the logs, and Retry now actually works,
while its /health recovery poll still walks straight into the app if the slow
start finishes first. Either way the user gets out.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HR6J9zKQop9TGGVUwjypnF
2026-09-04 18:15:30 +05:30
Palash DebnathandClaude Opus 5 6a2ada2f11 fix(tts): don't answer a GPU OOM by repeating the same allocation
`_get_clone_prompt` catches everything and returns None so synthesis falls
back to `generate()`'s inline reference path. For a device OOM that is not a
fallback at all: the inline path runs the SAME encode on the SAME device —
producing identical output is the entire point of the precompute — so it is
guaranteed to hit the same wall moments later, on a GPU with even less
headroom than the first attempt found. Two reporters' backends died with a
Windows access violation (exit code -1073741819) seconds after this fallback
logged, mid-generation, on a card that had just refused an 86 MiB
allocation.

An OOM here is also the most recoverable kind. The allocator is typically
sitting on reserved-but-unallocated blocks — #1790's own log reports 90 MiB
reserved against that 86 MiB request — so drop them and try once more. If it
still will not fit, raise: the failure layer turns a device OOM into "close
other GPU-heavy apps or unload models, then retry", which is a far better
answer than walking into a native fault.

Every other failure still falls back silently, since for a non-memory fault
the inline path may genuinely succeed.

Fixes #1790.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HR6J9zKQop9TGGVUwjypnF
2026-09-04 18:11:20 +05:30
Palash DebnathandClaude Opus 5 9ac1045917 test: reject a backslash in a tracked path too
CodeRabbit's catch on #1799: git stores paths with `/` separators, so a `\`
that survives into a path component is part of a NAME. It is legal to commit
one from Linux or macOS and impossible to check out on Windows, where git
refuses it under `core.protectNTFS` — the same checkout-time failure, before
any test runs, that the stray `:memory:.ses` caused.

The rule moves into a pure `windows_hostile_reason` so it can be exercised
directly: the repo cannot carry a fixture for each hostile shape without
becoming the very thing the test rejects. Both directions are pinned — every
shape Windows refuses, and ordinary paths that merely resemble one (a file
called `console.md`, `com10.py`, a component containing but not ending in a
dot).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HR6J9zKQop9TGGVUwjypnF
2026-09-04 18:04:38 +05:30
Palash DebnathandClaude Opus 5 31d90def83 fix(errors): don't claim the backend crashed with no evidence that it did
Two Apple Silicon reporters were told "it most likely crashed or was killed
mid-request" while generating. Neither bug report carried a crash marker,
because none had been recorded — the app had no evidence for the one thing
it asserted, and the advice that follows that sentence is Retry and Clean &
Retry, which rebuilds the whole Python environment to fix a backend that had
not died.

Two causes, both fixed here.

The desktop shell learns the backend died from a ~2 s poll: it has to notice
the child exit before it can write the marker. `apiFetch` asked for that
marker exactly once, at the instant the transport gave up, so it raced the
poll and lost either way round — a backend that really died was reported
with the vague sentence instead of its exit code and crash notice, and one
that never died was reported as dead anyway. `streamDropError` already waits
that poll out (#1119); the request path never did. The loop is now a shared
`awaitBackendCrashMarker`, used by both, with a shorter budget here because
the transport cascade has already cost the user a few seconds.

And the copy itself overshot what it could know. By construction it is
reached only once a crash has been looked for and not found, so it no longer
names one: it says the backend stopped answering with no crash recorded, and
that a heavy job holding the engine is the likelier story — which on a
memory-pressured Mac mid-generation it is. Updated in all 21 locales, since
a translation still asserting a crash would be the same bug in another
language.

The #1337 test that required the crash wording is updated with it: #1337
established that the backend had answered seconds earlier, not what silenced
it, and requiring the stronger claim is what pinned this in place.

Fixes #1802.
Fixes #1805.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HR6J9zKQop9TGGVUwjypnF
2026-09-04 18:03:23 +05:30
Palash DebnathandClaude Opus 5 d5c33eda27 fix(desktop): don't kill a backend that is still starting
The launcher waited a flat five minutes from spawn for the backend to
report ready, then killed it and tried again. On a host where the cold
start genuinely takes longer — the reporter's project lived on a mapped
network drive, and `import torch` off one is slow the first time, as is a
first CUDA load or a cold spinning disk — that deadline expired *while the
backend was still importing*. The respawn threw away the warm page cache
and raced the same clock, so the app could never start, and it blamed the
backend: "the backend never reported ready". Launching that same backend by
hand reached ready in well under a minute once the cache was warm.

A backend answering `/startup/progress` with `status: "starting"` is not
one we have to guess about: it bound its socket, it is serving HTTP, and it
is naming the step it is on. Killing it cannot make the retry faster, and
the launcher knows nothing the user doesn't. So keep waiting while it
answers, and keep narrating each step. The budget still governs silence —
nothing answering, or a self-reported `failed` — where a slow backend and a
wedged one really are indistinguishable and the existing stderr-tail
failure is the right answer.

The splash needed the same correction. Its stall watchdog keys on
`bootstrap_status`, which sits on `starting_backend` for the whole of a slow
start, so it would have called the launch stuck at six minutes anyway; the
proof of life arrives on the separate `bootstrap-log` stream. Output now
counts as activity, and a genuinely silent backend still trips the watchdog
so the info-less spinner of #879 stays fixed.

Fixes #1791.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HR6J9zKQop9TGGVUwjypnF
2026-09-04 17:50:23 +05:30
Palash DebnathandClaude Opus 5 36a38bdbb9 fix(ci): don't ship a tracked path Windows cannot check out
A stray sqlite session artifact named `:memory:.ses` was committed by
accident on this branch. Git on Windows rejects a path containing `:` with
`error: invalid path` and exits 128 during **checkout** — so both Windows
jobs went red before a single build or test step ran, pointing at a file
nobody had edited, while Linux and macOS stayed green.

Drop the file, ignore the `*.ses` artifact class, and add a guard that scans
the index on every platform for paths Windows cannot represent: illegal
characters, components ending in a space or dot, and reserved DOS device
names. The failure now surfaces as a named test on every runner instead of
as a checkout crash on one leg of the matrix.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HR6J9zKQop9TGGVUwjypnF
2026-09-04 17:41:02 +05:30
VishvakR 02c3a651ac test(generate): drive the scheduler itself, and restore env before reloading
Third review round on the PR, both findings in the new test file.

CodeRabbit: the disconnect regression called deadlines.for_task directly, so it
would have passed even if Scheduler._budget_for stopped coercing a missing
worker to the CPU budget -- the very thing it exists to pin. It now builds a
real WorkerPool and Scheduler, assigns the task to the 4 GB worker, asserts the
bound budget is the CPU one, disconnects the worker and asserts the
recomputation is not shorter. Forcing under_provisioned=False in _budget_for
fails it with `assert 300 == 600`.

CodeRabbit: the two env-var tests deleted the variables and reloaded
model_manager inside a finally, which runs BEFORE pytest restores them -- so on
a machine that already exports either var, the module constants would describe
an environment pytest was about to put back, and every later test would read
the mismatch. Both use monkeypatch.context() now, so the environment is restored
before the reload.
2026-09-04 15:36:18 +05:30
VishvakR fa148ecb55 fix(generate): tighten the VRAM-floor tests and document budget precedence
Second review round on the PR.

CodeRabbit: the repo-wide dispatch assertion accepted any nested min_vram_gb
keyword, so a budget computed with 0 or another engine's floor would pass while
the guard used the right one. It now compares the two expressions.

CodeRabbit: the awaiting-side deadline test restated gpu_gateway's formula
instead of calling it, so it would not have noticed that function starting to
select a shorter ceiling. It calls _default_deadline now, on cuda and rocm.

CodeRabbit: the docs said an explicit OMNIVOICE_GENERATE_TIMEOUT_S is honoured
"everywhere" while also saying the CPU var governs under-provisioned cards --
the two cannot both be true. Verified against the code (both vars set, 4 GB
cuda, engine floor 6 GB -> 200s, the accelerated value) and documented as a
precedence table rather than prose. The accelerated var deliberately wins on an
under-provisioned host: that is what keeps "lower it to fail fast everywhere"
working. Pinned by a test so the table cannot drift from the behaviour.

CodeRabbit also flagged that Scheduler._budget_for recomputes with no worker
after a disconnect, dropping under_provisioned to False. That cannot shorten
anything: no worker means no execution_device, which _base_execution_seconds
already coerces to "cpu" -- the same budget the floor raises an
under-provisioned card to. Added a test pinning that rather than persisting a
dispatch-time budget on the attempt. The residual case it describes -- an
operator who raised the accelerated budget ABOVE the CPU one sees a shorter
recomputation once the worker is gone -- predates this change and applies to
every GPU worker, not just under-provisioned ones, so it belongs in its own fix.
2026-09-04 13:52:23 +05:30
VishvakR f172d0c3be fix(generate): apply the VRAM-floor budget to remote workers and /convert
Review findings on the PR, fixed here rather than left for a fourth report.

Greptile (P1): the control plane sets a remote attempt's deadline, so the same
inversion reached remote workers. Its suggested fix -- thread the engine floor
into generate_timeout_s() -- would read the wrong machine: that function probes
THIS host, so a Mac control plane dispatching to a 4 GB Windows worker learns
nothing (MPS is excluded by design), and a 4 GB box dispatching to a 24 GB
worker would wrongly get the longer budget. The worker already advertises both
figures it takes -- free_memory_bytes and min_memory_bytes, both set in
worker/capabilities.py -- so ConnectedWorker.under_provisioned() decides from
those, and deadlines.for_task() floors the execution budget at what the same job
would get on a CPU. The task-level ceiling in gpu_gateway._default_deadline is
computed before a worker is bound and already asks for the CPU budget, so it
still covers the raised lease; a test pins that.

CodeRabbit (major): /convert had the identical split -- min_vram_gb to the
guard so a timeout could name the card, and a budget computed without it.

CodeRabbit (minor): the docs promised the CPU-class floor for any GPU, while
the code scopes it to dedicated-VRAM families. Reworded to say CUDA/ROCm and to
say why MPS is excluded.

CodeRabbit (minor): the call-site assertion compared global occurrence counts,
so one dispatch could drop both arguments while another gained an extra and the
total still matched. It now walks the AST and checks each dispatch on its own,
and the pairing is additionally enforced repo-wide across backend/api/routers:
a dispatch that knows the engine's floor well enough to explain a timeout must
know it well enough to set the budget.

Three inline capability-selection loops in ConnectedWorker collapse into one
_capability_for(), so the new predicate cannot select a different capability
than execution_device() does.
2026-09-04 13:33:00 +05:30
VishvakR fcac8e1bae fix(generate): budget an under-provisioned GPU like the CPU it performs like
A GPU with less VRAM than the engine declares it needs pages to system RAM
over PCIe, so it renders slower than the same machine's CPU. The compute-time
budget picked its value from the device family alone, so that card was treated
as fast hardware and given 300s -- half the 600s a plain CPU host gets. It is
the slowest configuration the app supports and it had the shortest watchdog.

Everything else already acted on the verdict. resolve_routing() raises the
caveat, the synth preflight warns before the user waits, and _timeout_guidance()
names the card in the failure. Each TTS generate dispatch even hands the guard
the engine's floor on the line above the timeout that ignored it. #1226 and
#1222 were the same 4 GB cards on the same engine; both were closed by making
the app explain the timeout better, never by correcting the budget behind it.

generate_timeout_s() now floors an under-provisioned accelerator at the CPU
budget. The length scaling is unchanged, and an explicitly configured
OMNIVOICE_GENERATE_TIMEOUT_S is still honoured verbatim, so an operator who
lowered the watchdog to fail fast keeps that. The floor is a max(), never an
assignment, so a raised accelerated budget is never cut down. Engines that
declare no floor, a failed VRAM probe, and MPS (whose vram_gb is a unified-
memory heuristic, not a dedicated pool) are all untouched.

The three-clause "is this host under-provisioned" test was written out inline
in the caveat and in the timeout message, which is how the budget came to
disagree with the warning printed beside it; it is now one predicate,
under_provisioned_vram(), that all three read.

Reported on a GTX 1650 (4 GB) running the omnivoice engine, whose breadcrumbs
show the budget ending the job on the dot: 372s and 301s are exactly
300 + max(0, len - 1200) / 40 for the two takes.

Fixes #1804.
2026-09-04 13:02:14 +05:30
Palash DebnathandClaude Opus 5 4e6c36848c fix(transcriptions): render segments that have no timings
An OpenAI-compatible ASR answering in json/text format returns no
timestamps, and services/asr_backend.py records that honestly as
`end: None` rather than inventing a number. The segment list called
`.toFixed()` on it unconditionally, so the render threw and the whole
Transcriptions view went blank — a transcript that merely lacked timings
became one the user could not read at all.

Show whichever bound is known and nothing when neither is, so the text
stays readable either way. Non-finite values are treated as unknown too,
so a bad timing prints nothing rather than NaN.

Fixes #1798.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HR6J9zKQop9TGGVUwjypnF
2026-09-04 03:26:51 +05:30
Palash Debnath f2302e8c95 fix(desktop): don't adopt a backend running stale code (#1796)
Exports failed with a 422 naming a field the current app never sends — twice, from different users. The cause was the attach handshake: if something already answers on the backend port and reports a matching version, the app adopts it and skips the source sync a normal launch performs. A version string holds steady for a whole release cycle, so a same-version process can still be running weeks-old code, and that code then serves a current UI.

The handshake now compares a fingerprint of the shipped Python sources, read from the same response as the version so a dropped probe can't masquerade as a missing field. A backend predating the mechanism is treated as stale; one that is current but started outside the app is still accepted. Refusals are logged with a greppable marker, since this class previously took two reports and a code audit to identify.

Fixes #1770. Closes the duplicate report tracked in #1792.
2026-09-04 03:22:41 +05:30
Palash Debnath 8b4e4ebf56 fix(windows): start the backend when the install path has non-English characters (#1795)
On Windows with a non-UTF-8 system code page, a venv path containing non-English characters (commonly a CJK username) killed the interpreter during startup, before any VoiceStudio code ran — Python reads .pth files in the active code page, and uv's editable install writes the project path there in UTF-8. The backend could never start, and the setup screen only said it had stalled.

A new or genuinely broken environment now builds at an ASCII-safe short path; an existing environment that starts cleanly is never relocated. When no safe path can be produced, the app says so before downloading rather than after. The failure message names the cause and a remedy that works for the install mode in use, since portable installs ignore the setting managed installs use.

Fixes #1783.
2026-09-04 03:21:42 +05:30
Palash Debnath 7f7a4c5f83 fix(settings): make the generation budget reachable and honest (#1797)
The compute-time error told users to raise a generation timeout that had no control anywhere in the app — the only knob was an environment variable, and on Windows the docs explicitly warn against the usual way of setting one. Both budgets are now editable in Settings under Performance & Device, persisted and applied on the next start.

Two defects found in review and fixed here rather than shipped: an explicit universal budget silently overrode a separately saved CPU budget, so the CPU row would have looked like it worked and done nothing; and a value already set in the environment shadowed the saved preference while the panel still reported success. A shadowed row now says so instead. Long-input warnings also fire on Apple Silicon, which gets the accelerated budget and was the device in one of the duplicate reports.

Fixes #1787. Closes the reports tracked in #1774 and #1778.
2026-09-04 01:55:06 +05:30
Palash Debnath e5916acc01 feat(design): simplify the Voice Design panel (#1793)
The panel printed every chosen value three times and held twelve control rows open before anyone touched it. Details now collapse to a single recipe line that expands on request, gender/age/pitch/style become selects, and English accent and Chinese dialect merge into one grouped field so the combination the engine rejects cannot be selected at all. Starting points show five with an overflow, the bottom-bar slider is labelled Steps, and the panel ends where its content ends.

Also fixes two races found in review: a manual pick or a cleared description now beats an in-flight describe response, and arrow-key chip navigation moves focus without resetting the design.
2026-09-04 00:20:36 +05:30
Palash Debnath 06e69d6d6b fix(desktop): resolve the capability-store dir from the running backend (#1789)
Exports and every other native-picker action 403'd with "Invalid or expired desktop authorization" whenever Tauri and the backend resolved different data directories — a dev backend spawned without the OMNIVOICE_* env, a custom data folder, or portable mode. Tauri now takes the directory the running backend advertises, so the two processes cannot disagree, falling back to its own resolution when the backend is unreachable. One resolver covers all six capability kinds. Also decodes JSON escapes when reading that field, which Windows paths depend on, requires an absolute path so a relative data dir cannot recreate the same split, and keeps the 403 and its log line free of filesystem paths. Fixes #1781.
2026-09-03 22:25:08 +05:30
Palash Debnath e4ce065864 fix(design): enforce dialect/accent exclusivity in the voice-design picker (#1788)
Voice Design rendered EnglishAccent and ChineseDialect as two unlinked controls, so a user could select both and only learn they conflict from a 400 after a round trip. A shared exclusive-groups map now mirrors the engine's rule across every path that builds or restores instruct state: the live picker, free-text entry, saved-profile and imported-session restore, plus a message-matching backstop for a conflict arriving by any other route. Picking one clears the other with a visible reason instead of a silent reset. Fixes #1771.
2026-09-03 21:26:07 +05:30
Jaesik Lee f95e73b710 fix(i18n): ja "Cleaning…" is denoising, not housekeeping (#1775)
The Japanese clone.cleaning status read 掃除中 (tidying up a room) instead of ノイズ除去中, which is what the step actually does: denoising the reference audio. Thanks @j30231!
2026-09-03 20:39:42 +05:30
Jaesik Lee b20cd6cb95 fix(i18n): overhaul the ko locale (#1776)
Corrects 231 machine-translation defects in the Korean locale and translates all 493 previously missing keys, dropping ko to zero in the missing-key baseline. Includes terminology consistency (Cinematic, export, UI scale) and fixes copy that named the wrong control. Maintainer commits merged current main and folded in the five live-preview keys added by #1769. Thanks @j30231!
2026-09-03 20:19:42 +05:30
Matt Van Horn 1515b46adb feat(batch): watch-folder auto-ingest (#1768)
Opt-in watch folder on the batch queue: pick a directory once and new videos are auto-enqueued with the last Add-to-queue settings, with pause/stop controls and copy-in-progress protection. Files stream to the loopback backend as bytes; paths never leave the app. Also gives the batch queue a reachable UI entry point and streams multipart uploads to disk. Maintainer fix: the watched directory handle is opened with full share mode on Windows so users can rename or delete the folder while it is watched, matching macOS/Linux behaviour, with a cross-platform regression test. Thanks @mvanhorn!
2026-09-03 18:47:32 +05:30
Matt Van Horn 999345de41 feat(dub): realtime dub preview (#1769)
Opt-in live preview for dub segments: edits debounce into a streamed /ws/tts synthesis played through the chunk player, with cancellation preserved through buffered playback. Maintainer fixes: /ws/tts added to the backend ticket allowlist (feature was dead off-loopback), handshake failures surface a toast, loopback-only plaintext refusal reverted to keep the documented remote-GPU setup working, PCM16 decode hardened. Thanks @mvanhorn!
2026-09-03 18:27:07 +05:30
Palash Debnath ac287c612f docs(readme): enrich with audio samples, hardware guide, and doc links (#1785)
* docs: polish README hero hierarchy

* docs: enrich README with audio samples, hardware guide, and doc links

* docs: address review findings on Docker port binding, MCP transport, and privacy

* docs: address CodeRabbit review feedback on cURL format and Colab links

* docs: align Docker quick-start with stable tag and named volume mount
2026-09-03 18:00:14 +05:30
Palash Debnath d80286562e docs: polish README hero hierarchy (#1780) 2026-09-03 14:28:42 +05:30
9d30774ee2 feat(audiobook): synced lyrics playback (#1766)
* feat(audiobook): synced-lyrics player

Replace the bare <audio controls> in the audiobook result with a player
that renders the chapter text and highlights the word under
audio.currentTime, karaoke-style. Timing reuses what the render stream
already emits — per-chapter duration_s on the chapter SSE events — with
words even-split inside each chapter (the karaoke burn-in's old-job
fallback, ported from services/karaoke_ass.py); after a reload the whole
book even-splits over the file's own duration. No ASR pass, no new
backend surface, nothing leaves the machine. Download keeps going
through the Tauri-safe downloadMedia util.

New pure helper utils/audiobookLyrics.js mirrors the longform parser's
chapter drop rules so cue indices line up with the stream's chapter
list, and degrades to the proportional split on any drift (script
edited after the render, stopped mid-book). Words are buttons —
click-to-seek, keyboard reachable — restyled as prose in index.css.
audiobook.lyrics translated in all 21 locales.

Co-authored-by: Matt Van Horn <mvanhorn@users.noreply.github.com>

* docs(changelog): synced-lyrics audiobook player entry (#1766)

Co-authored-by: Matt Van Horn <mvanhorn@users.noreply.github.com>

* style(audiobook): apply current formatter

* fix(audiobook): preserve synced render cues

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Palash Debnath <4178343+debpalash@users.noreply.github.com>
2026-09-02 16:32:23 +05:30
65236774aa feat(dub): project-level drag casting board (#1767)
* feat(dub): project-level drag casting board

Adds an expandable Casting Board to the dub editor's CAST strip: speaker
rows (with the auto-clone chip when the extractor found a usable passage)
and draggable voice chips — Default, clone profiles, design presets.
Dropping a chip on a speaker writes the exact fields the CAST <select>
always has (profile_id + merge_parts/merge_parts_original attribution),
via a shared assignSpeakerProfile helper both views now call, so the
dropdowns stay in sync and job persistence is unchanged. Keyboard path:
focus a speaker row, pick from a listbox (arrows/Enter/Escape).

The pre-existing CAST dropdown strip moves verbatim into the new
CastingBoard.jsx (DubLeftColumn shrinks below 800 lines; the new file
holds the 300-line soft cap). Styles extend the .dub-cast-* cluster in
index.css. Six new i18n keys translated in all 21 locales.

Co-authored-by: Matt Van Horn <mvanhorn@users.noreply.github.com>

* docs: changelog + roadmap entries for the casting board (#1767)

Co-authored-by: Matt Van Horn <mvanhorn@users.noreply.github.com>

* fix(casting): validate and preserve speaker assignments

* fix(casting): recover cleared merged assignments

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Palash Debnath <4178343+debpalash@users.noreply.github.com>
2026-09-02 15:37:57 +05:30
Palash Debnath 0ed7d2ec22 chore(release): prepare v0.5.2 (#1761)
Synchronize VoiceStudio release metadata, lockfiles, installers, container references, documentation, and the dated v0.5.2 changelog after all planned fixes landed.
2026-09-02 10:26:14 +05:30
Matt Van Horn a95041f1e6 feat(studio): speech-to-speech voice changer (#1765)
Add a bounded, local-first speech-to-speech Convert workflow with shared ASR/TTS admission, duration matching, stale-request cancellation, profile conditioning, watermarking, persistence, localization, and regression coverage.\n\nCo-authored-by: Matt Van Horn <mvanhorn@users.noreply.github.com>
2026-09-02 09:45:40 +05:30
Matt Van Horn 4053397921 feat(dub): karaoke word-highlight caption burn-in (#1764)
Adds opt-in word-timed ASS karaoke captions while preserving the existing line-caption default.\n\nCo-authored-by: Matt Van Horn <mvanhorn@users.noreply.github.com>
2026-09-02 08:32:43 +05:30
Palash Debnath e2446c3e61 fix(release): keep Preview ahead of Stable (#1763)
Closes #1762.
2026-09-02 07:49:22 +05:30
Palash Debnath ccd984f324 Merge pull request #1760 from agudmund/feat/mcp-output-mode-files
feat(mcp): output mode + base-path file lane so agents never carry audio in context
2026-09-02 06:27:46 +05:30
Palash Debnath 89f0a25082 fix(mcp): bound encoded audio before decode 2026-09-02 06:13:11 +05:30
Palash Debnath b351dc5b1a Merge remote-tracking branch 'origin/main' into review/pr-1760
# Conflicts:
#	CHANGELOG.md
2026-09-02 06:07:57 +05:30
Palash Debnath 026410fbc6 test(worker): make loop responsiveness checks deterministic (#1759)
Reviewed by CodeRabbit and Greptile. Required Tests (backend + frontend) gate passed on the current, mergeable head.
2026-09-02 05:43:08 +05:30
Palash Debnath b6a1ee50ff Merge remote-tracking branch 'origin/main' into fix/deterministic-inbound-loop-tests
# Conflicts:
#	tests/test_worker_inbound_transport.py
2026-09-02 05:29:25 +05:30
Ævar GuðmundssonandClaude Fable 5.1 3c3c37615c feat(mcp): output mode + base-path file lane so agents never carry audio in context
An LLM agent pays for every byte it receives, and generate_speech returned
each WAV as base64 inline - a short clip already brushed per-result limits.
This adds two knobs in the OMNIVOICE_* family, the pattern the ElevenLabs
MCP settled on (OUTPUT_MODE + a BASE_PATH security boundary):

- OMNIVOICE_MCP_OUTPUT_MODE = resources (default, the original contract) |
  files | both. In files mode generate_speech returns audio_url (the render
  the backend already keeps, served at /audio/<id>.wav) and, when a base
  path is set, output_path - the WAV written into that directory.
- OMNIVOICE_MCP_BASE_PATH: the one directory agents may read from and
  receive files in. transcribe(audio_path=) and clone_voice(ref_audio_path=)
  read only inside it (relative paths resolve against it, absolute ones must
  lie within it, symlinks resolved before the check); with no base path,
  path arguments are refused with a reason.
- OMNIVOICE_MCP_TIMEOUT_S (default 120): the tools' backend timeout, since a
  CPU host serializes generations and an agent queued behind another render
  outlasted the fixed budget with an empty-message ToolError.

Also: transcribe and clone_voice share one input helper (data-URI tolerance
now covers transcribe too), the upload filename carries the sniffed
extension, and the reply is built with json.dumps instead of hand-rolled
JSON. Tests cover the mode parsing, the boundary (escape and missing-base
refusals), both input lanes, all four reply shapes, and the timeout knob.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-01 23:46:44 +00:00
Palash Debnath c44f2fc042 test: make key revocation ordering deterministic (#1758)
Replaces a scheduler-sensitive 200 ms assertion with a deterministic ordering check against the blocked-write release barrier. Repairs the red post-merge main run from #1751.
2026-09-02 05:09:21 +05:30
Palash Debnath 62604ec9bb test(worker): make loop responsiveness checks deterministic 2026-09-02 04:56:29 +05:30
Palash Debnath 08569397d3 fix(asr): secure configured endpoints and refresh guidance (#1751)
Refreshes README and linked docs with accurate installation, platform, privacy, API, and model-license guidance; documents local gigastt; and pins OpenAI-compatible ASR traffic to the configured secure origin. Closes #1736.
2026-09-02 04:41:36 +05:30
Palash Debnath c9a468e500 Merge pull request #1756 from debpalash/fix/windows-direct-job-owner-1734
fix(windows): remove the sidecar supervisor hop
2026-09-02 04:07:36 +05:30
Palash Debnath aec4694628 test(windows): cover delayed Job exit 2026-09-02 03:52:17 +05:30
Palash Debnath 5df1dc973c Merge remote-tracking branch 'origin/main' into fix/windows-direct-job-owner-1734
# Conflicts:
#	CHANGELOG.md
2026-09-02 03:48:02 +05:30
Palash Debnath 8cc978588d Merge pull request #1754 from debpalash/fix/backend-startup-budget-1749
fix(frontend): align backend startup stall budget
2026-09-02 03:28:13 +05:30
Palash Debnath 6f80110a42 fix(windows): await timed-out Job teardown 2026-09-02 03:15:16 +05:30
Palash Debnath c5ac548100 Merge remote-tracking branch 'origin/main' into fix/windows-direct-job-owner-1734
# Conflicts:
#	CHANGELOG.md
2026-09-02 03:14:09 +05:30
Palash Debnath 26d7a333e8 Merge remote-tracking branch 'origin/main' into fix/backend-startup-budget-1749
# Conflicts:
#	CHANGELOG.md
2026-09-02 03:12:28 +05:30
Palash Debnath 75eb7c6099 test: make repository ID bound deterministic (#1757)
Replaces a runner-speed-dependent security assertion with a deterministic proof that oversized repository IDs are rejected before library validation. Repairs the red post-merge main run from #1755.
2026-09-02 02:51:20 +05:30
Palash Debnath 1d06c6f079 fix: accept ASR-detected dub source codes (#1755)
Accepts every Whisper language code persisted by ASR, including three-letter Cantonese yue, so subsequent dubbing uploads no longer fail validation. Closes #1737.
2026-09-02 02:26:56 +05:30
Palash Debnath 267ded0e79 fix(windows): simplify nested job cleanup 2026-09-02 01:44:52 +05:30
Palash Debnath 549a56fc2d fix: remove Windows sidecar supervisor hop 2026-09-02 01:38:05 +05:30
Palash Debnath 6e47b15e82 test: pin backend stall timeout boundary 2026-09-02 01:29:22 +05:30
Palash Debnath 5e08dde5e0 fix: align backend startup stall budget 2026-09-02 01:24:27 +05:30
534 changed files with 48605 additions and 7798 deletions
+8 -2
View File
@@ -85,14 +85,20 @@ names: there is no `desktop=prod` (note the **hyphen** in `desktop-prod`).
Requires [Rust](https://rustup.rs/) and platform-specific Tauri dependencies — see the [Tauri prerequisites](https://v2.tauri.app/start/prerequisites/).
After installing Rust with rustup on macOS/Linux, either open a new terminal or
load Cargo into the current one before starting the desktop app:
After installing Rust with rustup (or `uv` with its installer), a terminal that
was already open still has the old `PATH`. The desktop launchers (`bun desktop`,
`bun desktop-prod`, `bun desktop-fresh`) detect this and add `~/.cargo/bin` /
`~/.local/bin` for that run, printing a one-line note; to make it permanent,
open a new terminal, or on macOS/Linux load Cargo into the current one:
```bash
source "$HOME/.cargo/env"
bun desktop
```
If Rust is genuinely not installed, the launchers stop up front with the
install command instead of failing later inside `cargo metadata`.
On Linux, errors such as `Package gdk-3.0 was not found`, `pango.pc` missing,
or `javascriptcoregtk-4.1` missing mean the native packages above were not
installed; changing `PKG_CONFIG_PATH` does not fix libraries that are absent.
+61 -2
View File
@@ -11,6 +11,11 @@ on:
push:
branches: [main]
workflow_dispatch:
inputs:
windows_wix_diagnostic:
description: Run only the tiny nonpublishing Windows MSI authoring diagnostic
type: boolean
default: false
permissions:
contents: read
@@ -21,6 +26,7 @@ env:
jobs:
test:
if: ${{ !inputs.windows_wix_diagnostic }}
name: Tests (backend + frontend)
runs-on: ubuntu-22.04
env:
@@ -189,6 +195,7 @@ jobs:
# and `cargo test --lib` runs the shell's unit tests natively on each OS.
# Full bundling stays in release.yml on tag push.
tauri-cross-platform:
if: ${{ !inputs.windows_wix_diagnostic }}
name: Tauri shell check (${{ matrix.label }})
needs: test
strategy:
@@ -289,6 +296,7 @@ jobs:
# job above misses. Narrow scope (tests/smoke/ only) — full pytest stays
# on Linux until Phase 1's INST-01 lands setuptools for WhisperX.
smoke-matrix:
if: ${{ !inputs.windows_wix_diagnostic }}
name: Smoke (${{ matrix.label }})
needs: test
strategy:
@@ -428,17 +436,68 @@ jobs:
PY
- name: Run smoke tests
# Exercise credential paths on native Windows as well as POSIX hosts.
if: matrix.backend_supported
run: uv run --no-sync pytest tests/smoke/ -q --tb=short
run: uv run --no-sync pytest tests/smoke/ tests/test_hf_token_cache_paths.py -q --tb=short
env:
HF_HUB_OFFLINE: "1" # same no-silent-downloads guard as the main pytest job
HF_HUB_CACHE: ${{ runner.temp }}/pockettts-empty-hf-cache
# The isolated backend session, on Windows. The `test` job runs it on
# Linux only, which is how four tests that CANNOT pass on Windows shipped
# unnoticed: two reach for os.WNOHANG and os.waitid (POSIX-only, an
# AttributeError before the first assertion), one asserts a RuntimeError
# that `backend_drain_fd` returns None instead of raising off POSIX, and
# one raced the OS reaping a crashed child — a race Linux won and Windows
# lost every time. All four were invisible to CI and hit every Windows
# contributor on their first `pytest` run. Forty seconds closes the class.
- name: Isolated backend session (Windows)
if: runner.os == 'Windows' && matrix.backend_supported
run: uv run --no-sync pytest backend/tests/ -q --tb=short
env:
HF_HUB_OFFLINE: "1"
# Artifact commits depend on native Windows rename/replace semantics;
# Linux emulation cannot exercise sharing rules or path parsing.
# test_worker_task_store and test_worker_inbound_transport joined this
# step after a Windows run found a real portability bug the Linux-only
# `test` job could not see: a staged input's artifact id was built with
# os.path.join, so a Windows control plane persisted and shipped
# `inputs\<sha>.wav` — which a Linux worker cannot resolve. These suites
# need no ffmpeg, so they cost seconds here.
- name: Remote-worker artifact paths (Windows)
if: runner.os == 'Windows' && matrix.backend_supported
run: uv run --no-sync pytest tests/test_worker_upload_server.py tests/test_worker_server_integrity.py -q --tb=short
run: >-
uv run --no-sync pytest
tests/test_worker_upload_server.py
tests/test_worker_server_integrity.py
tests/test_worker_task_store.py
tests/test_worker_inbound_transport.py
-q --tb=short
env:
HF_HUB_OFFLINE: "1"
HF_HUB_CACHE: ${{ runner.temp }}/worker-artifact-empty-hf-cache
windows-wix-diagnostic:
name: Windows MSI authoring (no publishing)
needs: test
if: ${{ !cancelled() && (inputs.windows_wix_diagnostic || needs.test.result == 'success') }}
runs-on: windows-2022
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- name: Bundle canonical system and per-user templates with a tiny payload
shell: pwsh
run: ./scripts/diagnose-windows-wix.ps1
- name: Restore hosted Installer policy after failed standard-user installation
shell: powershell
run: ./scripts/test-msi-policy-cleanup.ps1
- name: Preserve verbose linker output and rendered authoring
if: always()
uses: actions/upload-artifact@v4
with:
name: windows-wix-diagnostic
path: wix-diagnostic-artifacts/
if-no-files-found: warn
retention-days: 3
+40 -25
View File
@@ -148,15 +148,20 @@ jobs:
preview-gate:
name: Preview gate
runs-on: ubuntu-22.04
permissions:
contents: read
outputs:
is_preview: ${{ steps.decide.outputs.is_preview }}
proceed: ${{ steps.decide.outputs.proceed }}
stable_tag: ${{ steps.decide.outputs.stable_tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 50
- id: decide
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
event="${{ github.event_name }}"
@@ -171,6 +176,13 @@ jobs:
exit 1
fi
echo "is_preview=true" >> "$GITHUB_OUTPUT"
# Resolve once before the matrix starts so every platform stamps
# against the same immutable Stable-channel snapshot.
STABLE_TAG=$(gh release view --repo "$GITHUB_REPOSITORY" --json tagName --jq .tagName)
[[ "$STABLE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || {
echo "::error::latest stable release has an invalid tag"; exit 1;
}
echo "stable_tag=$STABLE_TAG" >> "$GITHUB_OUTPUT"
else
echo "is_preview=false" >> "$GITHUB_OUTPUT"
fi
@@ -497,35 +509,22 @@ jobs:
echo "APPLE_TEAM_ID=$TID"
} >> "$GITHUB_ENV"
# Stamp each preview build with a unique, monotonically increasing semver
# PRERELEASE so the updater actually offers it (a rolling preview that
# always reported the static 0.3.0 never looked "newer", so no update was
# ever delivered). Ephemeral, CI-only — never committed. Tauri reads the
# bundle + updater version from tauri.conf.json, so rewriting it here
# stamps the artifacts + latest.json. Under the versioning hard rule
# (owner-set 2026-06-11) main is always last-release + 1, so BASE-N is a
# prerelease of the NEXT version and semver-sorts ABOVE the last stable
# (0.3.6-N > 0.3.5) — preview users naturally upgrade past stable, and
# the Windows MSI ProductVersion (which strips the prerelease → 0.3.6)
# is also correctly above the last stable.
# Stamp each preview with a numeric prerelease that is strictly above the
# latest stable release. Main may intentionally retain the released
# version while AUTO_VERSION_BUMP is disabled; in that case the helper
# advances the preview base by one patch so stable users can still opt in
# and receive it. The edit is ephemeral and never committed.
- name: Stamp preview version
if: needs.preview-gate.outputs.is_preview == 'true'
shell: bash
env:
STABLE_TAG: ${{ needs.preview-gate.outputs.stable_tag }}
run: |
set -euo pipefail
# package.json is the single source of truth; tauri.conf.json reads its
# version from it ("version": "../package.json"), so stamping
# package.json restamps the whole bundle.
CONF=frontend/package.json
BASE=$(jq -r .version "$CONF")
# MSI/WiX requires the semver pre-release identifier to be numeric-only
# (and <= 65535). "preview.N" hard-fails the Windows bundler, so the
# preview stamp is BASE-N — still sorts below the stable BASE for the
# updater, still unique per run.
PREVIEW_VERSION="${BASE}-${{ github.run_number }}"
tmp=$(mktemp)
jq --arg v "$PREVIEW_VERSION" '.version = $v' "$CONF" > "$tmp"
mv "$tmp" "$CONF"
PREVIEW_VERSION=$(python scripts/stamp-preview-version.py \
--package-json frontend/package.json \
--stable-tag "$STABLE_TAG" \
--run-number "${{ github.run_number }}")
echo "Stamped preview version: $PREVIEW_VERSION"
# The rolling `preview` release is REUSED every night, and macOS updater
@@ -605,6 +604,21 @@ jobs:
fi
done < /tmp/stale.txt
# A retried job reuses its version and can collide with installers it
# uploaded before a later step failed. Keep other versions/arches intact;
# macOS versionless updater archives are scoped by release tag and arch.
- name: Clear this target's installer assets on retry
if: github.run_attempt > 1
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ (needs.preview-gate.outputs.is_preview == 'true') && 'preview' || github.ref_name }}
RELEASE_TARGET: ${{ matrix.rust_target }}
run: |
VERSION=$(python -c 'import json; print(json.load(open("frontend/package.json"))["version"])')
python scripts/clear-release-rerun-assets.py \
--tag "$RELEASE_TAG" --version "$VERSION" --target "$RELEASE_TARGET"
- name: Build + release (Tauri)
uses: tauri-apps/tauri-action@v0
env:
@@ -660,6 +674,7 @@ jobs:
set -euo pipefail
python ../scripts/render-per-user-wix.py \
--source src-tauri/wix/main.wxs \
--system-wxs src-tauri/target/${{ matrix.rust_target }}/release/wix/x64/main.wxs \
--output src-tauri/target/wix-per-user/main.wxs
bunx tauri build --target ${{ matrix.rust_target }} --bundles msi \
--config src-tauri/tauri.per-user.conf.json
@@ -780,7 +795,7 @@ jobs:
set -euo pipefail
MSI=$(find frontend/src-tauri/target/${{ matrix.rust_target }}/release/bundle/msi -name '*Current*User*.msi' | head -1)
powershell.exe -NoProfile -ExecutionPolicy Bypass \
-File scripts/smoke-per-user-msi.ps1 -MsiPath "$(cygpath -w "$MSI")"
-File scripts/smoke-per-user-msi.ps1 -MsiPath "$(cygpath -w "$MSI")" -PrepareHostedRunner
# linuxdeploy re-links .DirIcon as an ABSOLUTE symlink into the build
# machine AFTER tauri's files-map has placed the real icon bytes — the
+10
View File
@@ -170,3 +170,13 @@ bin/omnivoice-tts-linux-aarch64
# committed (they ship with the app); the per-language source WAVs are just the
# inputs scripts/render_dub_demo_audio.py hands to scripts/build_dub_demo.sh.
backend/assets/samples/demo/dubbing/*.src.wav
# Stray sqlite session artifacts (`<db-path>.ses`). An in-memory DB yields the
# literal name `:memory:.ses`, and a path containing `:` cannot be checked out
# on Windows at all — committing one fails every Windows CI job at the git
# checkout step, before a single test runs. Guarded by
# tests/test_no_windows_hostile_paths.py.
*.ses
# Generated Windows MSI diagnostic logs and installer payloads
/wix-diagnostic-artifacts/
+2
View File
@@ -25,6 +25,8 @@ regexes = [
'''^hf_QWERTYUIOPasdfghjklZXCVBNM0123456789xyzAB$''',
# NLLB generation length argument, not the value of a credential.
'''^max_length=400$''',
# Dubbing pane split-position localStorage key, not a credential.
'''^omnivoice\.dubSplit\.v1$''',
# cryptography's Ed25519 private-key type name, not key material.
'''^Ed25519PrivateKey$''',
]
+5
View File
@@ -33,6 +33,11 @@ Binding for every AI agent (Claude, Codex, Cursor, review bots, …). CLAUDE.md
- `frontend/package.json` dep changes require regenerating root `bun.lock` (Docker runs `--frozen-lockfile`).
- Issues: absorb or decline — never defer to a future version. Check the open-PR queue before implementing community-reported fixes.
## Shared select controls
- Use `frontend/src/components/SearchableSelect.jsx` for all new or redesigned select boxes. Reuse `VoiceSelector` for voice choices. Do not introduce native `<select>` controls.
- Provide a localized `ariaLabel`; use `menuPortal` inside scrolling or clipping containers. Preserve keyboard selection and disabled states.
## Agent skills
Project development skills are pinned in `skills-lock.json` and installed under
+183 -2
View File
@@ -8,26 +8,207 @@ the frozen-backend fallback mirror it for their toolchains.
## [Unreleased]
## [0.5.2] — 2026-09-10
**Highlights**
- Supertonic-3 and PocketTTS show their license Accept button again, so they can be enabled (#2017)
- An engine that can't run on your platform says so, instead of telling you to install it (#2018)
- MOSS-TTS-v1.5, Confucius4-TTS, dots.tts, Supertonic-3 and PocketTTS install in one click, each in its own environment, so switching engines and back never breaks a working one (#2015, #2016)
- A pronunciation entry that is stored but not applied yet says so, instead of looking like it did not match (#1949)
- A bare 500 report now names the backend error class, so two unrelated faults stop filing the same issue (#1773)
- A rejected dubbing source language now names the code it rejected (#1960)
- The first-run install log is kept on disk instead of vanishing with the setup screen (#1847)
- `bun run desktop` reclaims port 3900 from a backend the app itself left running, instead of refusing to start (#1974)
- A dictation shortcut another app already owns now says so, instead of silently doing nothing (#1858)
- Quitting on Windows is no longer reported as a crash on the next launch (#1898)
- A Reduce motion switch in Settings, for calm without changing your whole system (#1857)
- A light theme, and System Auto now follows a light-mode OS instead of staying dark (#1973) — thanks @CoDe-ReDz!
- Generating from a one-character input now says the input was too short, instead of quoting a convolution error (#1826)
- First run asks about text size before the install, not after it (#1849)
- Cloning without a reference clip now says so, instead of naming library parameters you cannot set (#1879)
- Upgrading torch for an RTX 50-series card no longer trades one startup crash for another, and the upgrade is documented (#1931)
- A generation timeout now points at the compute-time budget in Settings rather than an environment variable (#1808)
- An engine you have not installed now says so, instead of reporting a failed check (#1866)
- The Accessibility prompt no longer floats over first-run setup and every other app until you grant it (#1845, #1886)
- The last onboarding step offers to install a speech-to-text model instead of failing three times when none is installed (#1856)
- A download that fails because the folder sits behind a mount point Windows will not cross now says so, and where to move it (#1957)
- A GPU that is merely short on free memory is no longer told to reinstall its drivers (#1812) — thanks @michaelhuamanflores!
- An error thrown by a browser extension is filtered on Safari and the macOS app too, not only on Chromium (#1901) — thanks @Chang-Jin-Lee!
- Choosing the China mirror no longer re-races the network on every dependency step, which cost seconds per step on blocked connections (#1892) — thanks @yuezheng2006!
- The backend log panel reports a log it cannot read instead of quietly showing less (#1847) — thanks @Chang-Jin-Lee!
- The floating dictation bubble adds pause, resume, stop, close, and a multiline preview (#1952)
- Transcriptions checks model readiness and offers an inline download and shortcut hints (#1952)
- Transcriptions' missing-model prompt lists every dictation model by accuracy vs latency, languages and size, so you install the one that fits — or switch to one already on disk (#1952)
- The Engines menu's Transcription tab picks the dictation model under Sherpa-ONNX, and that choice now also drives Sherpa transcription (#1952)
- A failure with no stage attached no longer borrows another stage's advice, so a text-to-speech error stops telling you the video server dropped the download (#1943)
- A generation failure that the app cannot classify now names the backend error class, so two unrelated faults stop arriving as the same untriageable report (#1800)
- Transcriptions dictation wakes the desktop recorder, presents one contextual start action, and centers its microphone icon with the label (#1902)
- Colab transcription and dubbing now include an explicit ASR model setup step (#1922) — thanks @nidhi-singh02!
- Apple Silicon now shows one canonical OmniVoice choice in the engine picker while retaining its automatic crash-isolated sidecar runtime (#1913)
- Validate current-user Windows installers under a standard account on hosted runners (#1883)
- Model downloads survive a flaky connection instead of restarting from zero (#1940)
- `bun run dev` recovers on Windows instead of demanding Task Manager (#1941)
- The desktop app builds and opens from a fresh clone again (#1818) — thanks @flutterkage2k!
- GPUs with less VRAM than the engine needs no longer get half the compute-time budget a CPU gets (#1806) — thanks @VishvakR!
- Gallery voice previews play again — the quality guard was rejecting good renders as silent (#1819) — thanks @flutterkage2k!
- Tilde-separated number ranges are spoken clearly without running their endpoints together (#1821) — thanks @flutterkage2k!
- Voice modes use themed tabs, with Synthesize and Convert pinned below their scrolling forms (#1823)
- Fix current-user Windows installer validation and nested resource cleanup (#1873)
- Keep generated frontend assets available while building the current-user Windows installer (#1881)
- Voice cloning now starts with a clear upload-or-record choice, reveals recording and reference details only when needed, and keeps sampling controls under Production Overrides (#1817)
- The first-run welcome line uses an instruction accepted by OmniVoice and VoiceDesign engines (#1861) — thanks @psiberfunk!
- audio.cpp joins the engine lineup as an opt-in CPU backend for Breeze-TTS-2 (English + Chinese, clone + voice design, explicit Model Catalogue install, no Python venv) (#1891)
- audio.cpp uses installed native CUDA, HIP, Metal, and Vulkan providers and preserves device routing across remote workers (#1926)
- Show estimated and measured model, dependency, cache, and temporary disk costs in the engine catalogue (#1718)
- CosyVoice setup guidance now separates downloaded model files from the runtime that makes the engine available.
- Preview builds now stay newer than Stable even when automatic post-release version bumps are disabled (#1762)
- CosyVoice setup guidance now separates downloaded model files from the runtime that makes the engine available (#1761)
- MCP tools can now keep audio out of agent context by returning files and accepting base-path-confined file inputs (#1760) — thanks @agudmund!
- Hear a dub line as you type it — an opt-in live preview streams TTS for the edited segment (#1769) — thanks @mvanhorn!
- Studio gains a Convert method: re-say any clip in one of your saved voices, speech to speech, fully local (#1765) — thanks @mvanhorn!
- Hardsub video export gains an opt-in karaoke word-highlight caption style (#1764) — thanks @mvanhorn!
- The batch queue can now watch a folder: new videos dropped into it are dubbed automatically (#1768) — thanks @mvanhorn!
- The audiobook player now shows the chapter text and highlights the word being narrated (#1766) — thanks @mvanhorn!
- The dub editor gains a casting board: drag voice chips onto speakers, dropdowns stay in sync (#1767) — thanks @mvanhorn!
### Changed
- Tauri 2.11.5 with refreshed plugins (dialog, updater, log, opener, positioner, single-instance), React 19.3, TanStack Query 5.102, lucide 1.43, posthog-js 1.428, and the rest of the npm workspace on current minors; jsdom 30, jest-dom 7, concurrently 10, taze 21 (#1952)
- eslint ignores `src-tauri/`, so a local Tauri build no longer floods `lint:hooks` with parse errors from generated assets (#1952)
- Casting uses responsive SVG voice cards and searchable speaker menus that stay above surrounding panels (#1823)
- Dubbing aligns output settings, brings review status forward, and simplifies transcript and glossary editing; Launchpad files and voices reflow into responsive grids (#1823)
- Transcript segments use three readable rows for text, timing/status and voice controls, with heights that adapt to wrapping (#1823)
- Dragging the waveform pans horizontally while a click still seeks, keeping the timed transcript aligned (#1823)
- Bulk segment editing uses searchable voice and language menus, readable language names and a responsive selection toolbar (#1823)
- Dubbing overlays playback controls on video, combines waveform and transcript in a compact timeline, and removes header/action background fills (#1823)
- Dubbing uses compact casting, translation and output controls with responsive rows to leave more room for editing (#1823)
- Export uses grouped format settings, themed track menus and switches, with a pinned filename summary and download action (#1823)
- Dubbing output settings use icon-labelled switches, themed track and speaker menus, and clearer timing/transcript controls (#1823)
- Casting voice menus use searchable themed options with SVG preset icons instead of native dropdowns (#1823)
- Dubbing groups casting and translation controls with readable labels, SVG icons, searchable menus, and compact timeline spacing (#1823)
- Production Overrides use readable icon-labelled controls and accessible Denoise/Postprocess switches (#1823)
- Expanded navigation uses a theme-accent tint with subtle static wave gradients (#1823)
- Convert groups source audio, target voice, and timing options into clearer controls; design choices include theme-matched SVG icons (#1823)
- The expandable sidebar reveals workspace labels with restrained active states; language menus adapt to multiple columns on wider screens (#1823)
- Voice design and recording use themed, keyboard-accessible selectors with clearer spacing and labels (#1823)
- Voice tabs and upload/record controls have subtle SVG motion; Text adds clipboard paste and the upload area fills available height (#1823)
- The title-bar label cycles through active speech, transcription, and LLM engines; bundled model labels correctly say OmniVoice (#1823)
- The top-bar Engines panel groups Speech, Transcription, and LLM choices into tabs, with compact memory controls and no duplicate pickers (#1823)
- Voice Design simplified: the 12-row fine-grained block collapses to one summary line with a five-field editor, English accent and Chinese dialect merge into a single field, and the starting-point chips now show 5 with an overflow toggle (#1793)
### Added
- The audiobook result is now a synced-lyrics player: chapter text follows playback with the current word highlighted and click-to-seek, timed from the render's own chapter durations with a karaoke-style even split — no ASR pass, fully local (#1766) — thanks @mvanhorn!
- The dub CAST strip expands into a project-level casting board: drag voice chips (clone profiles, design presets, Default) onto speaker rows — or pick from a keyboard listbox — writing the same per-speaker cast fields as the existing dropdowns (#1767) — thanks @mvanhorn!
- Studio's new Convert method turns a dropped or recorded clip into an existing voice profile's voice, with optional source-duration matching (#1765) — thanks @mvanhorn!
- Opt-in watch folder on the batch queue: pick a directory once and new videos are auto-enqueued with your last Add-to-queue settings, with pause/stop controls and copy-in-progress protection — files upload as bytes, paths never leave the app (#1768) — thanks @mvanhorn!
- Hardsub export can now burn karaoke word-highlight captions: an opt-in Line | Karaoke control renders a word-timed ASS sweep from timings persisted at transcription, with an even-split fallback for older jobs and translated tracks, plus a `GET /dub/ass/{job_id}` sidecar (#1764) — thanks @mvanhorn!
- Windows releases now include an independently updatable per-user MSI that installs and uninstalls without elevation (#1713)
- Dub segments can now stream live TTS while you edit a translated line — opt-in toggle, existing `/ws/tts` socket, shared generation admission, exports still render at full quality (#1769) — thanks @mvanhorn!
- Engine status and diagnostic bundles now record loaded execution provider, device, precision, fallback stage, accelerator identity, runtime versions, and parent-process memory visibility (#1717)
### Docs
- The CosyVoice guide now states that packaged builds have no one-click runtime installer and records the exact readiness checks exposed by [Discussion 1631](https://github.com/debpalash/VoiceStudio/discussions/1631).
- PowerShell Docker setup now generates the administrator key without requiring Python on the host (#1993) — thanks @yangfan-yf-yf!
- The torch upgrade an RTX 50-series card needs is written down, with the second pin file the resolver checks and the command that proves the kernels are there (#1931)
- Docker quick starts now explain the AMD64-only images and direct Apple Silicon users to the native macOS app (#1921) — thanks @yangfan-yf-yf!
- audio.cpp (Breeze-TTS-2) is now a documented opt-in engine: prebuilt binary install, explicit GGUF download, voice modes, and the weights' research/non-commercial terms (#1891)
- `docs/STRUCTURE.md` describes the tree as it is today, and a test now keeps its counts honest (#1981) — thanks @Dawcraft!
- Local gigastt is now documented as a supported OpenAI-compatible ASR endpoint, with loopback privacy distinguished from remote servers (#1736) — thanks @ekhodzitsky!
- The CosyVoice guide now states that packaged builds have no one-click runtime installer and records the exact readiness checks exposed by [Discussion 1631](https://github.com/debpalash/VoiceStudio/discussions/1631) (#1761)
- A production private-API guide now covers pinned containers, root credentials, network isolation, streaming proxies, health checks, upgrades, and benchmark evidence (#1720)
- RX 6700 XT/gfx1031 over WSL2 ROCDXG is now explicitly unverified until a published end-to-end GPU workload proves the mapped path (#1716)
### Fixed
- One-click engine installs no longer inherit VoiceStudio's own PyTorch pin, which made MOSS-TTS-v1.5 and Confucius4 impossible to install (#2024)
- Uninstalling a translation engine no longer removes a package VoiceStudio or another engine still needs (#2019)
- Closing the dictation pill on Windows removes it from the screen: an empty dark rectangle used to stay there, always on top, until the app was quit (#2009)
- The dictation pill on Windows no longer sits inside a bordered card wider than the pill itself (#2009)
- Dictation uses the model you picked instead of one remembered from before the backend started, so it stops reporting no speech-to-text model while one is installed — and when none is, the main window offers the download (#2012)
- The remote-worker loop-responsiveness tests no longer turn a build red over milliseconds of scheduling noise on shared CI hardware (#1990)
- Remote GPU workers work when the machine running VoiceStudio is on Windows: a staged input is now identified the same way on every operating system, instead of with a path only Windows can read (#2005)
- The pronunciation list badges an IPA or CMU entry as not applied yet, so you can see it without running a test (#1949) — thanks @utkarsha741!
- A remote-worker test no longer fails at random on Windows CI: it waited for a background thread by spinning the event loop that thread's work needed (#1990)
- The isolated backend test session passes on a stock Windows checkout, and CI now runs it there so it stays that way (#1990)
- Windows contributors can run the test suite without Developer Mode: tests that create a symlink now skip instead of failing with `WinError 1314` (#1990)
- The crash details dialog now says what the exit code means and what to try, instead of showing a raw number and a log (#1927)
- A crash report now carries the backend's actual last words: the log tail is captured after the dying process's final output lands, not the instant it exits (#1850)
- The first-run setup screen no longer mislabels a step when the bootstrap restarts itself: Rust now says which attempt each stage and log line belongs to, instead of the screen guessing from a once-a-second poll (#1900)
- A port-3900 conflict now names who is actually holding it, and gives the command that ends an orphaned backend, instead of telling you to quit an app that has no window (#1933) — thanks @Chang-Jin-Lee!
- Windows desktop launches no longer freeze at "Loading ML runtime (PyTorch)": the parent-liveness watchdog polls the stdin pipe instead of leaving a read pending, which deadlocked numpy's OpenBLAS initializer (#1952, #1955)
- `bun desktop-prod` and `bun desktop-fresh` find Rust and uv from a terminal opened before they were installed, as `bun desktop` already did; a missing Rust toolchain fails up front with the install steps (#1952)
- Voice synthesis progress no longer races to a fabricated 95%; it stays indeterminate until the active generation path reports real progress (#1907) — thanks @psiberfunk!
- The Backend log tab keeps showing history across a log rollover, instead of going nearly empty until new lines arrive (#1920)
- Clearing the logs now empties the rotated log files too, so it frees the space it appears to (#1920)
- An error thrown by a browser extension no longer offers to file itself as a VoiceStudio bug (#1901)
- Clearing the desktop logs no longer wipes the backend's stderr, which is the only record a native crash leaves behind and is meant to survive a respawn (#1510)
- Long audiobook chapters now use the same device- and text-length-aware synthesis timeout as other TTS routes (#1910) — thanks @psiberfunk!
- Interrupted audiobook renders can resume cached chapters after tab navigation, and their chapter cache is available from the recovery card (#1911) — thanks @psiberfunk!
- System-check details and storage paths beginning with a number or a slash no longer render with their leading text moved to the end of the line (#1848) — thanks @psiberfunk!
- An unavailable engine's row now links to that engine's guide, so the generic "check installation and configuration" message has somewhere to send you (#1866) — thanks @psiberfunk!
- The backend log now records which engine failed a health check and whether its probe raised, instead of a line that identified neither (#1866) — thanks @psiberfunk!
- The first-run Activity log counts every line instead of freezing at 200 while the install is still running, and Copy now hands back the whole run rather than the last 200 lines (#1847) — thanks @psiberfunk!
- A first-run failure that happened early in a long install keeps its specific advice, instead of falling back to the generic retry hint once the log scrolled past 200 lines (#1847) — thanks @psiberfunk!
- Opening the log panel no longer clips the Launchpad's heading and slides the feature cards up over it — the page scrolls instead of squashing itself (#1859) — thanks @psiberfunk!
- Segmented model downloads split files into 16 MB ranges instead of one range per connection, so a dropped connection refetches one range rather than restarting the file (#1940)
- The download accelerator is kept across retries after a transient network failure and resumes from its manifest, instead of falling back to a from-zero `snapshot_download` (#1940)
- `dev-backend.mjs` stops the backend by process tree on Windows, so an orphaned uvicorn no longer holds port 3900 and turns a source reload into three phantom crashes (#1941)
- `clear-dev-ports.mjs` can free a stuck development port on Windows again, bound to the inspected process instance so a recycled pid is never terminated (#1941)
- Checkout-ownership matching no longer resolves POSIX paths with the host's separator, which made the guard's own test fail on Windows (#1941)
- Install documentation help now prints correctly on Windows consoles using legacy encodings (#1815) — thanks @dajiaohuang!
- Saved transcriptions with missing or invalid timestamps now remain readable (#1799) — thanks @yunaremaia and @tvbht!
- Transcribing with an engine that reports no segment end no longer fails with a server error; the null timing is passed through the way the segment list already expects (#1904) — thanks @aeroglu!
- Copying a saved transcription now uses the shared clipboard helper and reports failed copies accurately (#1803) — thanks @tvbht!
- Voice reference preparation reclaims allocator memory before one bounded retry, then reports persistent GPU out-of-memory failures (#1811)
- `bun run desktop` now opens on a fresh clone: the Vite alias for `@tauri-apps/plugin-dialog` no longer assumes a nested `frontend/node_modules`, which bun's workspace hoisting leaves empty (#1818) — thanks @flutterkage2k!
- Slow backend startups remain running with progress updates, and Retry interrupts startup without stale timeout failures (#1809)
- Backend connection errors report crashes only when recorded evidence exists, and diagnostic waits honor cancellation (#1810)
- A CUDA or ROCm GPU with less VRAM than the engine needs now gets the CPU compute-time budget instead of the shorter accelerated one, since it pages to system RAM and renders slower than the CPU would — applied to local generation, voice conversion, and remote worker deadlines alike (#1806) — thanks @VishvakR!
- Gallery previews no longer fail with "the voice engine returned no audible audio" on perfectly good renders: the degenerate-buzz guard measured spectral flatness over the whole clip (so the value tracked clip length) against a threshold calibrated on a synthetic signal, and rejected real speech in every language tested (#1819) — thanks @flutterkage2k!
- Speak tilde separators in integer, signed, and decimal ranges in English, Korean, Japanese, and Chinese (#1821) — thanks @flutterkage2k!
- Keep recording and conversion work safe while switching methods, synchronize dubbing language controls, and localize timeline controls and timing warnings (#1841)
- Audiobook is now a Write → Cast → Produce tab workspace matching the voice workspace, with the warnings/progress/result rail pinned below (#1841)
- Gallery uses a workspace header with zone tabs, hairline section dividers, theme-token cards, and borderless import rows (#1841)
- Gallery cards reset native button faces, cluster icon actions in the header so Use voice never wraps, and use a roomier grid floor (#1841)
- Gallery filters gain name search, removable iconified pills with clear-all, and dimension icons on every facet (#1841)
- Dubbing playback starts before waveform decoding, automatic cast names are readable, and transcript timestamps have more room (#1823)
- The title-bar engine button stays compact and stable while cycling labels, with engine names aligned right (#1823)
- Long dubbing segment errors wrap in a bounded scrollable notice instead of widening the editor (#1823)
- Voice dropdowns match their field width, use theme accents, and show recent voices only once (#1823)
- Language menus no longer show a pale frame around their search header (#1823)
- The notification count stays inside the title bar instead of clipping above the bell (#1823)
- The workspace engine menu opens beside its button instead of at the opposite edge of the page (#1823)
- Cloning reuses the dubbing language picker with flags, search, and single selection, opening above the pinned synthesis controls (#1823)
- The first-run welcome line uses an instruction accepted by OmniVoice and VoiceDesign engines (#1861) — thanks @psiberfunk!
- The header status dot now honors OS Reduce Motion instead of pulsing regardless (#1862) — thanks @psiberfunk!
- Onboarding reads Hugging Face tokens locally, preserves Windows CLI logins, and requires successful discovery before replacing saved credentials (#1852) — thanks @psiberfunk!
- The logs panel no longer reports “All clear” before log retrieval succeeds or while logs contain warnings or errors (#1870) — thanks @motodriver!
- MOSS accelerator routing and status match runtime selection, with CPU fallback when device probing fails (#1830) — thanks @li-lizhe!
- Confucius accelerator routing tolerates failed device probes, and dots.tts keeps safe default precision on non-CUDA hosts (#1831) — thanks @li-lizhe!
- On macOS, the header status dot and kicker no longer render underneath the overlaid traffic lights (#1863) — thanks @psiberfunk!
- The capture widget can hide after recording and recover from being left visible while idle (#1865) — thanks @psiberfunk!
- macOS retains the shared desktop window sizing, resize limits, and file-drop behavior when native chrome is applied (#1865) — thanks @psiberfunk!
- On macOS, the header no longer shows Windows-style minimize/maximize/close buttons alongside the native traffic lights (#1865) — thanks @psiberfunk!
- Release retries replace their own partially uploaded installers without colliding with existing assets (#1871)
- Timed-out voice engines finish process cleanup before retrying, and old timeout callbacks cannot kill replacement engines (#1872)
- Fast macOS process exits no longer turn a completed shutdown into a permission error (#1809)
- The bootstrap splash no longer shows fabricated first-run install steps on a warm start or repair sync — a step now renders done only once it was actually observed (#1894)
- A deliberate, clean quit killed by the desktop shell's short shutdown grace no longer gets reported as a crash on next launch — the run sentinel now clears before the slower shutdown steps instead of after (#1895)
- Model Catalogue engine rows stack into one column on narrow shells instead of clipping actions off-screen (#1891)
- Simplified Chinese locale completed: all 486 missing keys translated and the parity ratchet tightened to zero (#1877) — thanks @yearth!
- The generation compute-time budget is now a Settings control (Performance & Device) instead of an env-var-only setting the timeout error recommended with no UI path — the error copy points there too, and long CPU/MPS renders get an upfront heads-up before they start (#1787)
- Windows: the backend can now start when the install path contains non-English characters (e.g. a CJK username) on a non-UTF-8 system code page — a new or broken Python environment now builds at an ASCII-safe path automatically (a healthy existing one is never relocated), and a specific error message names the cause and a working fix if the interpreter still crashes in `site` (#1783)
- Exports and other native-picker actions no longer 403 with "Invalid or expired desktop authorization" when the desktop app and backend resolve different data directories, e.g. dev mode or a custom data folder (#1781)
- Voice Design no longer lets you pick a Chinese dialect and an English accent together — the picker keeps them mutually exclusive instead of round-tripping a 400 (#1771)
- The desktop app no longer attaches to an already-running backend on version string alone: it now verifies the backend's actual code fingerprint too, so an orphaned or manually started backend reporting the current version but running older code (e.g. a stale `destination_path` export 422) gets replaced instead of adopted (#1770)
- Korean locale overhauled: 231 mistranslations corrected and all 493 missing keys translated (#1776) — thanks @j30231!
- Japanese "Cleaning…" clone status now reads as denoising instead of housekeeping (#1775) — thanks @j30231!
- The batch dubbing queue now has a UI entry point — a quiet link on the Dub landing (it was previously unreachable: the app switched on a mode nothing ever set) (#1768) — thanks @mvanhorn!
- OpenAI-compatible ASR now requires HTTPS outside loopback and refuses redirects so audio stays on the configured origin (#1736)
- Windows isolated engines now retain direct Job ownership without an extra Python supervisor process that can deadlock the child loader (#1734)
- The setup splash now waits through the backend's full startup budget instead of reporting slow Windows CUDA initialization as stuck after two minutes (#1749)
- Dubbing jobs can now reuse every source-language code produced by automatic ASR detection without a 400 error on the next upload (#1737)
- Incomplete Sherpa-ONNX model snapshots now self-repair before recognizer startup instead of failing on a missing ONNX file (#1733)
- OmniVoice subprocess startup now allows slow packaged Windows Python runtimes to signal readiness before termination (#1711)
- SRT files selected during source analysis now wait for speaker cloning, then replace transcript text without losing voices (#1709)
+10 -4
View File
@@ -10,10 +10,10 @@ Copyright 2024-present Palash Debnath and VoiceStudio contributors.
VoiceStudio is **free and open-source software, licensed under the GNU
Affero General Public License, Version 3 (AGPL-3.0)**. You are free to use,
copy, modify, and redistribute it — and that **includes commercial and internal
business use**: run the app, use its outputs commercially, sell the audio you
produce with it, provide professional/client services with it, and deploy it
within your organization.
copy, modify, and redistribute it. That **includes commercial and internal
business use** of the application itself. Model weights, tokenizers, and other
third-party assets retain their own terms; this application license does not
grant or summarize rights under those separate terms.
Because this is the **Affero** GPL, one additional obligation applies: if you
modify VoiceStudio and make that modified version available to others over
@@ -41,6 +41,12 @@ is **separately licensed under Apache License 2.0** by its upstream authors and
is not relicensed here. Apache License 2.0 is compatible with, and may be
combined under, the GNU AGPL-3.0. See `pyproject.toml`.
Downloaded model weights are not relicensed by VoiceStudio. The default
`k2-fsa/OmniVoice` model card identifies its code as Apache-2.0 and pretrained
weights as CC-BY-NC. Its `audio_tokenizer/LICENSE` contains separate Boson
Higgs Audio 2 and Meta Llama community terms. A commercial license for
VoiceStudio-owned code does not replace any of those terms.
Third-party dependencies retain their own licenses. See `Cargo.lock`,
`bun.lock`, and `uv.lock` for the resolved set.
+173 -68
View File
@@ -1,26 +1,30 @@
<div align="center">
<a href="https://trendshift.io/repositories/28176?utm_source=repository-badge&amp;utm_medium=badge&amp;utm_campaign=badge-repository-28176" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/repositories/28176" alt="debpalash%2FVoiceStudio | Trendshift" width="250" height="55" /></a>
<img src="docs/logo.png" alt="VoiceStudio logo" width="120" height="120" />
<p><img src="docs/logo.png" alt="VoiceStudio logo" width="120" height="120" /></p>
<h1>VoiceStudio</h1>
<p>
<a href="https://trendshift.io/repositories/28176?utm_source=repository-badge&amp;utm_medium=badge&amp;utm_campaign=badge-repository-28176" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/repositories/28176" alt="VoiceStudio ranking on Trendshift" width="220" height="48" /></a>
</p>
<p><sub>Previously OmniVoice-Studio</sub></p>
<h3>Local voice cloning, dubbing, dictation, and long-form audio.</h3>
<p>16 TTS engines · 11 ASR engines · 646-language catalogue · macOS, Windows, and Linux</p>
<p><strong>Local-first.</strong> No account, API key, subscription, or usage meter for the core workflow.</p>
<h3>Clone voices, dub video, dictate, and produce long-form audio on your own hardware.</h3>
<p>16 TTS engines · 11 ASR engines · 646-language catalogue · macOS, Windows, Linux, and Docker</p>
<p>No account, API key, subscription, or usage meter for the local workflow.</p>
<p>
<a href="#install">Install</a> ·
<a href="#features">Features</a> ·
<a href="#comparison">Compare</a> ·
<a href="#requirements">Requirements</a> ·
<a href="#hardware-recommendations">Hardware</a> ·
<a href="#engines">Engines</a> ·
<a href="#architecture">Architecture</a> ·
<a href="#api">API</a> ·
<a href="#documentation">Docs</a> ·
<a href="#faq">FAQ</a> ·
<a href="README_CN.md"><strong>简体中文</strong></a>
</p>
<p>
<a href="https://github.com/debpalash/VoiceStudio/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/debpalash/VoiceStudio/ci.yml?branch=main&style=flat-square&label=CI" alt="CI status" /></a>
<a href="https://github.com/debpalash/VoiceStudio/stargazers"><img src="https://img.shields.io/github/stars/debpalash/VoiceStudio?style=flat-square&color=f59e0b" alt="GitHub stars" /></a>
<a href="https://github.com/debpalash/VoiceStudio/releases"><img src="https://img.shields.io/github/downloads/debpalash/VoiceStudio/total?style=flat-square&color=8b5cf6&label=downloads" alt="Total downloads" /></a>
<a href="https://github.com/debpalash/VoiceStudio/releases/latest"><img src="https://img.shields.io/github/v/release/debpalash/VoiceStudio?style=flat-square&color=10b981" alt="Latest release" /></a>
@@ -38,7 +42,7 @@
</div>
> [!WARNING]
> **Active beta.** Use the [latest release](https://github.com/debpalash/VoiceStudio/releases/latest) for stable work or `main` for current fixes. Report problems through [GitHub Issues](https://github.com/debpalash/VoiceStudio/issues).
> **Active beta.** Use the [latest release](https://github.com/debpalash/VoiceStudio/releases/latest) for stable work. `main` contains the newest fixes and may change between releases. Report problems through [GitHub Issues](https://github.com/debpalash/VoiceStudio/issues).
## At a glance
@@ -51,33 +55,70 @@
| **Compute** | CUDA · Apple Silicon MPS/MLX · ROCm on Linux · CPU · optional remote workers |
| **Interfaces** | Desktop app · local REST/SSE/WebSocket API · OpenAI-compatible audio API · MCP Server |
| **Storage** | Voices, projects, settings, and outputs stay on the machine by default |
| **License** | AGPL-3.0; optional engines keep their own model licenses |
| **License** | AGPL-3.0 application; downloaded models keep their upstream terms |
The Voice workspace starts with three tabs: **From audio** for cloning, **By design** for creating a voice, and **Convert** for speech-to-speech conversion. Each tab displays its own workflow, with Synthesize Audio or Convert pinned below the scrolling form. The top-bar **Engines** panel combines engine selection, loaded models, and unload/flush controls; <kbd>Ctrl</kbd>/<kbd>Cmd</kbd>+<kbd>E</kbd> opens it. The searchable language picker shares Dubbings flags and language list layout, selects one output language, and retains Auto and the full cloning catalogue. Language options flow into multiple columns when space allows. Expand **Workspaces** in the sidebar to reveal navigation labels; Escape collapses it.
Dubbing starts with file upload or URL import and nearby language choices. Its **Projects** panel lists previous dubs so they can be reopened by clicking anywhere on a card; action buttons operate independently. Advanced import options include captions and optional YouTube sign-in. Dubbing places playback controls over the video with background blur and combines the waveform and timed transcript in one compact editing surface. Drag the zoomed waveform left or right to pan; click to seek. Translation language and ISO-code controls stay synchronized; Auto clears any previous language code and dialect. Transcript items group editable text, timing and status, and voice controls into three readable rows that wrap with the panel width. Output Options stays compact with the active settings shown in its summary; expand it to change output, timing, or voice matching. Transcript, glossary, and paste controls share a toolbar above the segment editor. Project details, workflow steps, and Generate/Verify/Export actions use an unfilled header.
The Audiobook Script editor fills the available workspace beneath its markup toolbar; Voices and Book settings stay in their own tabs.
Output settings use aligned rows; review status appears before the collapsible transcript and glossary. Glossary terms have labelled entry fields and an explicit edit action. Launchpad arranges recent files and saved voices side by side when space allows, with responsive card grids and visible Open actions.
The casting board shows icon-based voice cards and searchable selectors for each speaker. Drag a card onto a speaker or choose a voice from that speakers menu.
<a id="install"></a>
## Install
Download a package from the [latest release](https://github.com/debpalash/VoiceStudio/releases/latest), then follow the platform guide.
| Platform | Package | Guide |
|---|---|---|
| macOS 13.3+ | DMG, Apple Silicon | [Install on macOS](docs/install/macos.md) |
| Windows 10/11 | MSI, x64 | [Install on Windows](docs/install/windows.md) |
| macOS 13.3+ | Apple Silicon DMG | [Install on macOS](docs/install/macos.md) |
| Windows 10/11 | x64 MSI; choose the current-user build when listed to install without admin access | [Install on Windows](docs/install/windows.md#install-pre-built-msi) |
| Linux | AppImage, x86_64 with glibc 2.39+ | [Install on Linux](docs/install/linux.md) |
| Docker | CUDA, ROCm, or CPU; worker-only GPU profiles | [Run with Docker](docs/install/docker.md) |
| Docker | Linux/AMD64 images; CUDA, ROCm, CPU, and worker-only GPU profiles | [Run with Docker](docs/install/docker.md) |
Download packages from the [latest release](https://github.com/debpalash/VoiceStudio/releases/latest). First launch creates a managed Python environment and downloads the default model. Later launches reuse both.
First launch creates a managed Python environment and downloads the default model. Later launches reuse both.
> [!NOTE]
> On macOS, first launch needs a one-time right-click **Open** approval. Intel Macs cannot run the local Python backend; use a [remote backend](docs/install/macos.md) instead.
> On macOS, first launch needs a one-time right-click, then **Open** approval. Intel Macs cannot run the local Python backend; use a [remote backend](docs/install/macos.md) instead.
### Quick Docker run
The published images are **`linux/amd64` only**. On Apple Silicon, use the
[native macOS app](docs/install/macos.md) for GPU acceleration. ARM64 hosts
should read the [architecture requirements](docs/install/docker.md#architecture)
before pulling an image.
```bash
docker run -d -p 127.0.0.1:3900:3900 -v omnivoice-data:/app/omnivoice_data --name voicestudio palashdeb/omnivoice-studio:stable
```
### First voice
1. Launch VoiceStudio and open **Voice Cloning**.
2. Add a clean voice sample. Three seconds works; 515 seconds usually gives a better prompt.
2. Add a clean voice sample. Three seconds works; 5 to 15 seconds usually gives a better prompt.
3. Enter text, choose a language, then select **Generate**.
> [!TIP]
> **Try without installing:** Run VoiceStudio in the cloud via the [Google Colab notebook](https://colab.research.google.com/github/debpalash/VoiceStudio/blob/main/notebooks/OmniVoice_Studio_Colab.ipynb). Explore audio quality comparisons in [benchmarks](docs/benchmarks.md) and prompt design tips in [expressive speech](docs/expressive-speech.md).
### Audio samples
Listen to sample outputs produced locally with VoiceStudio:
| Workflow | Prompt / Reference Audio | Generated Audio |
|---|---|---|
| **Voice Cloning** | [demo_voice.wav](backend/assets/samples/demo_voice.wav) | [demo_clone_output.wav](backend/assets/samples/demo_clone_output.wav) |
| **Voice Design** (US News Anchor) | *"Clear, authoritative American broadcast tone"* | [demo_voice_design_us_news_anchor.wav](backend/assets/samples/voice_design/demo_voice_design_us_news_anchor.wav) |
| **Voice Design** (UK Audiobook) | *"Warm, expressive British storytelling voice"* | [demo_voice_design_audiobook_uk_narrator.wav](backend/assets/samples/voice_design/demo_voice_design_audiobook_uk_narrator.wav) |
| **Video Dubbing** (Multilingual) | [source.src.wav](backend/assets/samples/demo/dubbing/source.src.wav) | [Spanish](backend/assets/samples/demo/dubbing/dubbed_es.src.wav) · [French](backend/assets/samples/demo/dubbing/dubbed_fr.src.wav) · [Japanese](backend/assets/samples/demo/dubbing/dubbed_ja.src.wav) · [Chinese](backend/assets/samples/demo/dubbing/dubbed_zh.src.wav) |
### Run from source
Install the [development prerequisites](.github/CONTRIBUTING.md#development-setup), then:
Install the [development prerequisites](.github/CONTRIBUTING.md#development-setup) (Node 20+/Bun and Python 3.11+), then:
```bash
git clone https://github.com/debpalash/VoiceStudio.git
@@ -86,7 +127,7 @@ bun install
bun run desktop
```
Use `bun run dev` for the browser UI. See [Contributing](.github/CONTRIBUTING.md) for services, tests, and platform packages.
The desktop launcher configures Python dependencies on first run via `uv` automatically. Use `bun run dev` for the browser UI. See [Contributing](.github/CONTRIBUTING.md) for services, tests, and platform packages.
### If setup fails
@@ -101,22 +142,22 @@ Use `bun run dev` for the browser UI. See [Contributing](.github/CONTRIBUTING.md
| Area | Included |
|---|---|
| **Voice Cloning** | Zero-shot synthesis from a short reference clip |
| **Voice Design** | Create a voice from age, accent, pitch, style, and delivery instructions |
| **Video Dubbing** | Transcribe, translate, preserve speakers, synthesize, and export video |
| **Voice Cloning** | Zero-shot synthesis from a short reference clip ([guide](docs/engines/README.md)) |
| **Voice Design** | Create a voice from age, accent, pitch, style, and delivery instructions ([expressive speech](docs/expressive-speech.md)) |
| **Video Dubbing** | Transcribe, translate, preserve speakers, synthesize, and export video; compact translation settings include track selection, and completed dubs flag timing issues for review ([export guide](docs/dubbing/export.md)) |
| **Stories and audiobooks** | Multi-voice scripts · EPUB/PDF import · chapter rendering · `.m4b` export |
| **[Dictation Widget](docs/features/dictation.md)** | System-wide shortcut, live transcription, optional local-LLM cleanup |
| **Vocal Isolation** | Demucs speech/background separation |
| **Speaker Diarization** | Pyannote and WhisperX speaker assignment |
| **Batch Queue** | Queue large sets of audio and video jobs with per-job progress |
| **Model Catalogue** | Install, remove, select, and route TTS, ASR, and LLM models |
| **Remote Model Downloads** | Install models on enrolled remote workers with live progress |
| **GPU Auto-Detect** | CUDA, MPS, ROCm, and CPU routing with per-engine checks |
| **Speaker Diarization** | Pyannote and WhisperX speaker assignment ([guide](docs/features/diarization.md)) |
| **Batch Queue** | Queue large sets of audio and video jobs with per-job progress, or watch a local folder for new videos |
| **Model Catalogue** | Install, remove, select, and route TTS, ASR, and LLM models ([catalogue](docs/engines/README.md)) |
| **Remote Model Downloads** | Install models on enrolled remote workers with live progress ([guide](docs/downloading-models.md)) |
| **GPU Auto-Detect** | CUDA, MPS, ROCm, and CPU routing with per-engine checks ([performance](docs/performance.md)) |
| **AI Watermark** | AudioSeal embedding and detection |
| **MCP Server** | Synthesis and transcription tools for MCP clients |
| **Diagnostics** | Self-checks, error journal, logs, and scrubbed support bundles |
| **MCP Server** | Synthesis and transcription tools for MCP clients ([guide](docs/mcp.md)) |
| **Diagnostics** | Self-checks, error journal, logs, and scrubbed support bundles ([troubleshooting](docs/install/troubleshooting.md)) |
| **Local-first** | Core creation stays local; network-backed features are explicit opt-ins |
| **Extensible** | Registry-based TTS, ASR, and plugin interfaces |
| **Extensible** | Registry-based TTS, ASR, and plugin interfaces ([acceptance](docs/engine-acceptance.md)) |
<table>
<tr>
@@ -159,10 +200,20 @@ Requirements vary by engine. These values cover the default local workflow.
| **Disk** | 10 GB free | 20 GB+ SSD |
| **GPU** | Optional; CPU mode is supported | NVIDIA CUDA or Apple Silicon |
| **VRAM** | 4 GB when using a GPU | 8 GB+; large optional engines need more |
| **Python from source** | 3.11+ | 3.113.12 |
| **Python from source** | 3.11+ | 3.11 or 3.12 |
ROCm is Linux-only and opt-in. Windows AMD/Ryzen AI uses CPU. Systems with limited VRAM offload work to CPU when required. See [performance](docs/performance.md), [benchmarks](docs/benchmarks.md), and [engine disk usage](docs/engines/disk-usage.md).
<a id="hardware-recommendations"></a>
### Recommended stack by hardware
| Hardware | Recommended TTS | Recommended ASR | Why |
|---|---|---|---|
| **Apple Silicon (M1M4)** | [MLX-Audio](docs/engines/mlx-audio.md) · [OmniVoice](docs/engines/omnivoice.md) (MPS) | [MLX Whisper](docs/engines/mlx-whisper.md) · [Parakeet MLX](docs/engines/parakeet-mlx.md) | Native unified memory, lowest latency on macOS |
| **NVIDIA GPU (8 GB+ VRAM)** | [OmniVoice](docs/engines/omnivoice.md) · [CosyVoice 3](docs/engines/cosyvoice.md) | [WhisperX](docs/engines/whisperx.md) | High-fidelity zero-shot cloning, word timestamps, diarization |
| **Low VRAM / CPU-only** | [PocketTTS](docs/engines/pockettts.md) · [Sherpa-ONNX](docs/engines/sherpa-onnx.md) · [KittenTTS](docs/engines/kittentts.md) | [Moonshine](docs/engines/moonshine.md) · [Faster-Whisper](docs/engines/faster-whisper.md) (`int8`) | Low memory footprint, optimized CPU inference |
<a id="engines"></a>
## Engines
@@ -175,22 +226,22 @@ Engine support is capability-specific. Check cloning, language, platform, memory
| Engine | Languages | Clone | Instruct | Linux | macOS ARM | Windows | License |
|---|:---:|:---:|:---:|:---:|:---:|:---:|---|
| **VoiceStudio** (default, powered by k2-fsa/OmniVoice) | 600+ | Yes | Yes | CUDA/CPU | MPS | CUDA/CPU | [AGPL-3.0](LICENSE) app · [Apache-2.0](LICENSE-NOTICE.md) model |
| **CosyVoice 3** | 9 + 18 dialects | Yes | Yes | CUDA/CPU | CPU | CUDA/CPU | Apache-2.0 |
| **GPT-SoVITS** | 5 | Yes | | CUDA/CPU | | CUDA/CPU | MIT |
| **VoxCPM2** | 30 | Yes | Yes | CUDA/CPU | MPS | CUDA/CPU | Apache-2.0 |
| **MOSS-TTS-Nano** | 20 | Yes | | CUDA/CPU | CPU | CUDA/CPU | Apache-2.0 |
| **KittenTTS** | English | | | CPU | CPU | CPU | MIT |
| **MLX-Audio** | Model-dependent | Varies | Varies | | MLX | | Varies |
| **Sherpa-ONNX** | 20+ | | | CUDA/CPU | CPU | CUDA/CPU | Apache-2.0 |
| **IndexTTS 2.5** ⚡ | ZH · EN · JA · ES · AR | Yes | | CUDA/CPU | CPU | CUDA/CPU | Bilibili model license¹ |
| **OmniVoice GGUF** ⚡ | 600+ | Yes | Yes | CUDA/CPU | MPS/CPU | CUDA/CPU | [AGPL-3.0](LICENSE) app · [Apache-2.0](LICENSE-NOTICE.md) model |
| **OmniVoice (subprocess)** ⚡ | 600+ | Yes | Yes | CUDA/CPU | MPS | CUDA/CPU | [AGPL-3.0](LICENSE) app · [Apache-2.0](LICENSE-NOTICE.md) model |
| **PocketTTS** ⚡ | EN · FR · DE · PT · IT · ES | Yes | | CPU | CPU | CPU | CC-BY-4.0, gated² |
| **Supertonic 3** ⚡ | 31 | | | CPU | CPU | CPU | OpenRAIL-M |
| **MOSS-TTS-v1.5** ⚡ | 31 | Yes | | CUDA/CPU | CPU | CUDA/CPU | Apache-2.0 |
| **dots.tts** ⚡ | 24 | Yes | | CUDA/CPU | CPU | | Apache-2.0 |
| **Confucius4-TTS** ⚡ | 14 | Yes | | CUDA/CPU | CPU | CUDA/CPU | Apache-2.0 |
| [**VoiceStudio** (default, powered by k2-fsa/OmniVoice)](docs/engines/omnivoice.md) | 600+ | Yes | Yes | CUDA/CPU | MPS | CUDA/CPU | [AGPL-3.0](LICENSE) app · [Apache-2.0 code, CC-BY-NC weights](https://huggingface.co/k2-fsa/OmniVoice#license |
| [**CosyVoice 3**](docs/engines/cosyvoice.md) | 9 + 18 dialects | Yes | Yes | CUDA/CPU | CPU | CUDA/CPU | Apache-2.0 |
| [**GPT-SoVITS**](docs/engines/gpt-sovits.md) | 5 | Yes | No | CUDA/CPU | No | CUDA/CPU | MIT |
| [**VoxCPM2**](docs/engines/voxcpm2.md) | 30 | Yes | Yes | CUDA/CPU | MPS | CUDA/CPU | Apache-2.0 |
| [**MOSS-TTS-Nano**](docs/engines/moss-tts-nano.md) | 20 | Yes | No | CUDA/CPU | CPU | CUDA/CPU | Apache-2.0 |
| [**KittenTTS**](docs/engines/kittentts.md) | English | No | No | CPU | CPU | CPU | MIT |
| [**MLX-Audio**](docs/engines/mlx-audio.md) | Model-dependent | Varies | Varies | No | MLX | No | Varies |
| [**Sherpa-ONNX**](docs/engines/sherpa-onnx.md) | 20+ | No | No | CUDA/CPU | CPU | CUDA/CPU | Apache-2.0 |
| [**IndexTTS 2.5** ⚡](docs/engines/indextts.md) | ZH · EN · JA · ES · AR | Yes | No | CUDA/CPU | CPU | CUDA/CPU | Bilibili model license¹ |
| [**OmniVoice GGUF** ⚡](docs/engines/omnivoice-gguf.md) | 600+ | Yes | Yes | CUDA/CPU | MPS/CPU | CUDA/CPU | [AGPL-3.0](LICENSE) app · [review the derivative model terms](https://huggingface.co/Serveurperso/OmniVoice-GGUF#license |
| [**OmniVoice (subprocess; opt-in off MPS)** ⚡](docs/engines/omnivoice-subprocess.md) | 600+ | Yes | Yes | CUDA/CPU | MPS via default OmniVoice | CUDA/CPU | [AGPL-3.0](LICENSE) app · [Apache-2.0 code, CC-BY-NC weights](https://huggingface.co/k2-fsa/OmniVoice#license |
| [**PocketTTS** ⚡](docs/engines/pockettts.md) | EN · FR · DE · PT · IT · ES | Yes | No | CPU | CPU | CPU | CC-BY-4.0, gated² |
| [**Supertonic 3** ⚡](docs/engines/supertonic3.md) | 31 | No | No | CPU | CPU | CPU | OpenRAIL-M |
| [**MOSS-TTS-v1.5** ⚡](docs/engines/moss-tts-v15.md) | 31 | Yes | No | CUDA/CPU | CPU | CUDA/CPU | Apache-2.0 |
| [**dots.tts** ⚡](docs/engines/dots-tts.md) | 24 | Yes | No | CUDA/CPU | CPU | No | Apache-2.0 |
| [**Confucius4-TTS** ⚡](docs/engines/confucius4-tts.md) | 14 | Yes | No | CUDA/CPU | CPU | CUDA/CPU | Apache-2.0 |
⚡ Installed or registered on demand.
@@ -198,6 +249,8 @@ Engine support is capability-specific. Check cloning, language, platform, memory
² PocketTTS shows its gated-access and CC-BY-4.0 terms before first use.
³ The OmniVoice snapshot also includes an audio tokenizer under separate [Boson Higgs Audio 2 and Meta Llama community terms](https://huggingface.co/k2-fsa/OmniVoice/blob/main/audio_tokenizer/LICENSE). VoiceStudio's application license does not replace model or tokenizer terms.
Clone-less engines cannot preserve a reference speaker in dubbing or pinned-voice batch jobs. VoiceStudio rejects those jobs instead of silently changing engines. Heavy engines have separate memory and platform limits; check their engine guide first.
<a id="asr-engines"></a>
@@ -206,17 +259,17 @@ Clone-less engines cannot preserve a reference speaker in dubbing or pinned-voic
| Engine | ID | Languages | Best fit |
|---|---|:---:|---|
| **WhisperX** (default) | `whisperx` | ~100 | Dubbing, subtitles, word-level timing |
| **Faster-Whisper** | `faster-whisper` | ~100 | General cross-platform transcription |
| **Faster-Whisper (isolated)** | `faster-whisper-isolated` | ~100 | Crash-isolated batch transcription |
| **MLX Whisper** | `mlx-whisper` | ~100 | Apple Silicon |
| **PyTorch Whisper** | `pytorch-whisper` | ~100 | CUDA, MPS, and CPU fallback |
| **Parakeet TDT** | `nemo-parakeet` | English + 25 EU | Fast CPU/CUDA transcription |
| **Parakeet TDT v3 (MLX)** | `parakeet-mlx` | 25 EU | Apple Silicon dictation and word timestamps |
| **Moonshine** | `moonshine` | English | Low-power, low-latency ONNX |
| **FunASR** | `funasr` | 50+ | VAD and inline diarization |
| **sherpa-onnx** (live dictation) | `sherpa-onnx-asr` | Model-dependent | Streaming CPU dictation |
| **OpenAI-compatible** ⚠️ remote | `openai-compat-asr` | Server-dependent | Qwen3-ASR or another compatible endpoint; audio leaves the machine |
| [**WhisperX** (default)](docs/engines/whisperx.md) | `whisperx` | ~100 | Dubbing, subtitles, word-level timing |
| [**Faster-Whisper**](docs/engines/faster-whisper.md) | `faster-whisper` | ~100 | General cross-platform transcription |
| [**Faster-Whisper (isolated)**](docs/engines/faster-whisper-isolated.md) | `faster-whisper-isolated` | ~100 | Crash-isolated batch transcription |
| [**MLX Whisper**](docs/engines/mlx-whisper.md) | `mlx-whisper` | ~100 | Apple Silicon |
| [**PyTorch Whisper**](docs/engines/pytorch-whisper.md) | `pytorch-whisper` | ~100 | CUDA, MPS, and CPU fallback |
| [**Parakeet TDT**](docs/engines/nemo-parakeet.md) | `nemo-parakeet` | English + 25 EU | Fast CPU/CUDA transcription |
| [**Parakeet TDT v3 (MLX)**](docs/engines/parakeet-mlx.md) | `parakeet-mlx` | 25 EU | Apple Silicon dictation and word timestamps |
| [**Moonshine**](docs/engines/moonshine.md) | `moonshine` | English | Low-power, low-latency ONNX |
| [**FunASR**](docs/engines/funasr.md) | `funasr` | 50+ | VAD and inline diarization |
| [**sherpa-onnx** (live dictation)](docs/engines/sherpa-onnx-asr.md) | `sherpa-onnx-asr` | Model-dependent | Streaming CPU dictation |
| [**OpenAI-compatible** ⚠️ configured server](docs/engines/openai-compatible-asr.md) | `openai-compat-asr` | Server-dependent | Local gigastt/Qwen3-ASR or a remote endpoint; audio goes only to that server |
WhisperX and Faster-Whisper retry with `int8` when efficient `float16` is unavailable. Pin `ASR_COMPUTE_TYPE=int8` or `float32` only if automatic selection still fails.
@@ -251,8 +304,8 @@ FastAPI backend
- The desktop talks to a loopback-only backend on `localhost:3900`.
- Loopback API calls need no server key. Remote access requires a share PIN or API key.
- Remote workers and OpenAI-compatible ASR are opt-in. The UI identifies when audio leaves the machine.
- Analytics is off until consent. If enabled, it sends allowlisted, content-free usage metadata—not text, audio, file names, or projects.
- Remote workers and OpenAI-compatible ASR are opt-in. Loopback ASR may use HTTP and keeps audio on the machine; non-loopback endpoints require HTTPS, and redirects are not followed.
- Analytics is off until consent. If enabled, it sends allowlisted, content-free usage metadata. It never sends text, audio, file names, or projects.
<a id="api"></a>
@@ -287,12 +340,19 @@ with client.audio.speech.with_streaming_response.create(
response.stream_to_file("speech.wav")
```
The bundled Rust control sidecar also lets Herdr, coding agents, VS Code,
desktop apps, and TUIs trigger the existing system-wide dictation flow or reuse
its safe native insertion. See the [speech platform guide](docs/speech-platform.md).
The full API reference is in **Settings → OpenAPI Reference**. For LAN,
Tailscale, or proxy access, read [API authentication](docs/api-auth.md) before
exposing the backend.
```bash
# Quick test via cURL
curl http://localhost:3900/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model": "tts-1", "input": "Made on my own hardware.", "voice": "default", "response_format": "wav"}' \
--output speech.wav
```
The bundled Rust control sidecar lets Herdr, coding agents, VS Code, desktop apps,
and TUIs trigger the system-wide dictation flow or reuse its native text
insertion. See the [speech platform guide](docs/speech-platform.md). The full API
reference is in **Settings → OpenAPI Reference**. For LAN, Tailscale, or proxy
access, read [API authentication](docs/api-auth.md) before exposing the backend.
### Agent skills
@@ -305,6 +365,36 @@ npx skills add debpalash/VoiceStudio
- `omnivoice`: synthesize speech and transcribe audio through local VoiceStudio.
- `oss-maintainer`: the repository's open-source maintenance workflow.
### Model Context Protocol (MCP)
VoiceStudio mounts an MCP server at `http://localhost:3900/mcp` for Claude Desktop, Cursor, and AI agents:
```json
{
"mcpServers": {
"voicestudio": {
"url": "http://localhost:3900/mcp"
}
}
}
```
For clients requiring stdio transport, use the bundled local shim (`docs/mcp.json`):
```json
{
"mcpServers": {
"voicestudio": {
"command": "python",
"args": ["-m", "backend.mcp_shim"],
"cwd": "/path/to/VoiceStudio"
}
}
}
```
See the [MCP guide](docs/mcp.md) for tools (`generate_speech`, `clone_voice`, `transcribe`), file streaming modes, and client bindings.
### Google Colab
[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/debpalash/VoiceStudio/blob/main/notebooks/OmniVoice_Studio_Colab.ipynb)
@@ -326,6 +416,8 @@ The [notebook](notebooks/OmniVoice_Studio_Colab.ipynb) runs the app and web UI o
| Track changes | [Changelog](CHANGELOG.md) · [roadmap](docs/ROADMAP.md) · [latest release](https://github.com/debpalash/VoiceStudio/releases/latest) |
| Remove everything | [Uninstall guide](docs/install/uninstall.md) |
<a id="faq"></a>
## FAQ
<details>
@@ -337,19 +429,19 @@ Apple Silicon is supported with MPS and MLX options. Intel Macs cannot run the l
<details>
<summary><strong>How much VRAM do I need?</strong></summary>
A GPU is optional. Use 4 GB VRAM as the minimum for accelerated work and 8 GB+ for the default multi-stage workflow. Large optional engines can require 1216 GB or more. Check the [benchmarks](docs/benchmarks.md) and engine guide.
A GPU is optional. Use 4 GB VRAM as the minimum for accelerated work and 8 GB+ for the default multi-stage workflow. Large optional engines can require 12 to 16 GB or more. Check the [benchmarks](docs/benchmarks.md) and engine guide.
</details>
<details>
<summary><strong>Why does a longer reference clip not always improve the clone?</strong></summary>
Cloning is zero-shot: the clip is a prompt, not training data. Use 515 seconds of one speaker, close to the microphone, without music, noise, or reverb. Match the tone and pace you want in the output. For training, see [data preparation](docs/data_preparation.md) and [training](docs/training.md).
Cloning is zero-shot: the clip is a prompt, not training data. Use 5 to 15 seconds of one speaker, close to the microphone, without music, noise, or reverb. Match the tone and pace you want in the output. For training, see [data preparation](docs/data_preparation.md) and [training](docs/training.md).
</details>
<details>
<summary><strong>Can I use generated audio commercially?</strong></summary>
Yes under VoiceStudio's AGPL-3.0 terms. Optional engines and model weights may use different licenses; review the selected engine's license before commercial use.
VoiceStudio's application license does not restrict generated audio, but it does not grant rights under a model's separate terms. The default OmniVoice repository labels its pretrained weights CC-BY-NC and includes a tokenizer under separate community terms. Review the selected model terms before commercial use.
</details>
<details>
@@ -371,17 +463,30 @@ Use `scripts/uninstall.sh` on macOS/Linux or `scripts\uninstall.ps1` on Windows.
- [Good first issues](https://github.com/debpalash/VoiceStudio/labels/good%20first%20issue) for a scoped starting point.
- [Contributing guide](.github/CONTRIBUTING.md) for setup, tests, and pull requests.
<p align="center">
<a href="https://star-history.com/#debpalash/VoiceStudio&Date">
<img src="https://api.star-history.com/svg?repos=debpalash/VoiceStudio&type=Date" alt="Star History Chart" width="100%" />
</a>
</p>
## Support development
VoiceStudio is free and has no paid tier. Donations fund development and infrastructure.
[Ko-fi](https://ko-fi.com/debpalash) · [PayPal](https://paypal.me/palashCoder) · [Sponsorship details](SPONSORS.md)
## Responsible use and safety
VoiceStudio enables zero-shot voice cloning and speech generation on personal hardware. Please use it responsibly:
- **Consent:** Only clone or synthesize voices with explicit permission from the speaker.
- **Audio provenance:** VoiceStudio integrates [AudioSeal](https://github.com/facebookresearch/audioseal) imperceptible watermarking by default to detect and identify synthetic speech without altering sound quality.
- **Local privacy:** For the default local workflow, audio recordings, transcripts, voices, and projects remain strictly on your local disk; data leaves your device only when you explicitly configure remote workers or external ASR endpoints.
## License
VoiceStudio is licensed under [AGPL-3.0](LICENSE). You may run it, modify it, use it internally, and sell generated audio. If you modify VoiceStudio and provide that modified version as a network service, AGPL requires you to offer the corresponding source under the same license. A commercial license is available for proprietary embedding; contact **VoiceStudio@palash.dev**. See [LICENSE-NOTICE.md](LICENSE-NOTICE.md) for the plain-language scope.
VoiceStudio is licensed under [AGPL-3.0](LICENSE). You may run it, modify it, and use it internally. The application license itself does not restrict selling generated audio, but downloaded model and tokenizer terms may. If you modify VoiceStudio and provide that modified version as a network service, AGPL requires you to offer the corresponding source under the same license. A commercial license for VoiceStudio-owned code is available for proprietary embedding; it does not relicense third-party models. Contact **VoiceStudio@palash.dev**. See [LICENSE-NOTICE.md](LICENSE-NOTICE.md) for the plain-language scope.
Optional engines and downloaded models retain their own licenses. The bundled `omnivoice/` model remains Apache-2.0 upstream.
Optional engines and downloaded models retain their own licenses. The bundled `omnivoice/` Python code is Apache-2.0 upstream; the default downloaded weights and audio tokenizer use separate terms.
## Acknowledgments
+67 -3
View File
@@ -20,6 +20,7 @@
</p>
<p>
<a href="https://github.com/debpalash/VoiceStudio/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/debpalash/VoiceStudio/ci.yml?branch=main&style=flat-square&label=CI" alt="CI 状态" /></a>
<a href="https://github.com/debpalash/VoiceStudio/stargazers"><img src="https://img.shields.io/github/stars/debpalash/VoiceStudio?style=flat-square&color=f59e0b" alt="Star 数" /></a>
<a href="https://github.com/debpalash/VoiceStudio/releases/latest"><img src="https://img.shields.io/github/v/release/debpalash/VoiceStudio?style=flat-square&color=10b981" alt="版本" /></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/license-AGPL--3.0-blue?style=flat-square" alt="许可证" /></a>
@@ -65,11 +66,27 @@
- 🐧 **Linux** — [docs/install/linux.md](docs/install/linux.md)
- 🐳 **Docker** — [docs/install/docker.md](docs/install/docker.md) · [Docker Hub: `palashdeb/omnivoice-studio`](https://hub.docker.com/r/palashdeb/omnivoice-studio)
```bash
# Docker 快速运行 (CPU / 本地环回模式)
docker run -d -p 127.0.0.1:3900:3900 -v omnivoice-data:/app/omnivoice_data --name voicestudio palashdeb/omnivoice-studio:stable
```
**三步克隆出你的第一个声音:**
1. **安装并启动。** 首次启动会自动搭建 Python 运行环境并下载模型权重——启动画面会逐步显示进度(仅首次,需要几分钟;之后即开即用)。
2. 从启动台打开**语音克隆**,拖入任意声音的 **3 秒音频**
3. **输入一句话,点击生成。** 音频完全属于你——在你的设备上生成保存,支持 646 种语言。
3. **输入一句话,点击生成。** 音频在你的设备上生成保存,支持 646 种语言(商业使用前请审阅所选模型与分词器的许可条款)
### 🎧 音频示例
在线试听 VoiceStudio 本地生成的实际音频样例:
| 工作流 | 提示词 / 参考音频 | 生成音频 |
|---|---|---|
| **声音克隆** | [demo_voice.wav](backend/assets/samples/demo_voice.wav) | [demo_clone_output.wav](backend/assets/samples/demo_clone_output.wav) |
| **声音设计** (美语新闻主播) | *"清晰、权威的美国广播级音色"* | [demo_voice_design_us_news_anchor.wav](backend/assets/samples/voice_design/demo_voice_design_us_news_anchor.wav) |
| **声音设计** (英式有声书) | *"温暖生动的英式故事讲述音色"* | [demo_voice_design_audiobook_uk_narrator.wav](backend/assets/samples/voice_design/demo_voice_design_audiobook_uk_narrator.wav) |
| **视频配音** (多语种) | [source.src.wav](backend/assets/samples/demo/dubbing/source.src.wav) | [西班牙语](backend/assets/samples/demo/dubbing/dubbed_es.src.wav) · [法语](backend/assets/samples/demo/dubbing/dubbed_fr.src.wav) · [日语](backend/assets/samples/demo/dubbing/dubbed_ja.src.wav) · [中文](backend/assets/samples/demo/dubbing/dubbed_zh.src.wav) |
觉得慢?[docs/performance.md](docs/performance.md) 讲清了生成时间到底花在哪里、有哪些调优开关,以及“它变慢了”的三个经典原因。各引擎/设备的实测数据见 [docs/benchmarks.md](docs/benchmarks.md)。
@@ -217,6 +234,16 @@ Hugging Face Token 的配置见
> [!IMPORTANT]
> **macOS Intelx86_64)不支持本地后端:** 应用 UI 可以安装,但 Python 后端无法运行,因为 PyTorch 已不再发布 Intel Mac 轮子([#889](https://github.com/debpalash/VoiceStudio/issues/889))。Intel Mac 用户仍可让 UI 指向另一台机器上的远程后端——参见 [docs/install/macos.md](docs/install/macos.md)。
<a id="hardware-recommendations"></a>
### 💡 按硬件推荐引擎配置
| 硬件配置 | 推荐 TTS 引擎 | 推荐 ASR 语音识别 | 优势 |
|---|---|---|---|
| **Apple Silicon (M1M4)** | [MLX-Audio](docs/engines/mlx-audio.md) · [OmniVoice](docs/engines/omnivoice.md) (MPS) | [MLX Whisper](docs/engines/mlx-whisper.md) · [Parakeet MLX](docs/engines/parakeet-mlx.md) | 原生统一内存,macOS 上延迟最低、性能最强 |
| **NVIDIA 显卡 (8 GB+ 显存)** | [OmniVoice](docs/engines/omnivoice.md) · [CosyVoice 3](docs/engines/cosyvoice.md) | [WhisperX](docs/engines/whisperx.md) | 极致零样本克隆品质、字级时间戳对齐与说话人分离 |
| **低显存 / 仅 CPU 设备** | [PocketTTS](docs/engines/pockettts.md) · [Sherpa-ONNX](docs/engines/sherpa-onnx.md) · [KittenTTS](docs/engines/kittentts.md) | [Moonshine](docs/engines/moonshine.md) · [Faster-Whisper](docs/engines/faster-whisper.md) (`int8`) | 超低内存占用,针对 CPU 指令集深度优化 |
<a id="tts-engines"></a>
### 🗣️ TTS 引擎
@@ -338,9 +365,9 @@ print(result.text)
### 📓 在 Google Colab 上运行
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/debpalash/VoiceStudio/blob/main/notebooks/VoiceStudio_Studio_Colab.ipynb)
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/debpalash/VoiceStudio/blob/main/notebooks/OmniVoice_Studio_Colab.ipynb)
没有本地 GPU?官方笔记本([notebooks/VoiceStudio_Studio_Colab.ipynb](notebooks/VoiceStudio_Studio_Colab.ipynb))可在免费的 Colab T4 上启动完整应用(包含 Web 界面):在笔记本内直接构建前端,用 uv 安装后端(复用 Colab 预装的 CUDA PyTorch),并通过 Colab 内置端口代理打开界面。无需第三方隧道,也无需任何 API 密钥。随后还有一套覆盖全部主要功能的 API 导览,全部可在笔记本内直接播放:多语言 TTS、声音克隆与声音设计、已保存的声音档案、语音转写、AI 水印检测、OpenAI 兼容 API、多角色故事、带章节的 m4b 有声书,以及一个附带人声分离音轨的迷你视频配音。
没有本地 GPU?官方笔记本([notebooks/OmniVoice_Studio_Colab.ipynb](notebooks/OmniVoice_Studio_Colab.ipynb))可在免费的 Colab T4 上启动完整应用(包含 Web 界面):在笔记本内直接构建前端,用 uv 安装后端(复用 Colab 预装的 CUDA PyTorch),并通过 Colab 内置端口代理打开界面。无需第三方隧道,也无需任何 API 密钥。随后还有一套覆盖全部主要功能的 API 导览,全部可在笔记本内直接播放:多语言 TTS、声音克隆与声音设计、已保存的声音档案、语音转写、AI 水印检测、OpenAI 兼容 API、多角色故事、带章节的 m4b 有声书,以及一个附带人声分离音轨的迷你视频配音。
### 🤝 智能体技能(Agent Skills
@@ -352,6 +379,36 @@ npx skills add debpalash/omnivoice-studio
内含两个 [skills](https://skills.sh)**`omnivoice`**——让任何智能体通过你的本地安装进行语音合成与转录(包括你克隆的声音),免费且离线;以及 **`oss-maintainer`**——本项目所遵循的维护者方法论,适合任何用智能体运营自己开源项目的人。
### 🔌 模型上下文协议(MCP 服务器)
VoiceStudio 在 `http://localhost:3900/mcp` 挂载了 MCP 服务,可供 Claude Desktop、Cursor 与自主智能体调用:
```json
{
"mcpServers": {
"voicestudio": {
"url": "http://localhost:3900/mcp"
}
}
}
```
对于需要 stdio 管道传输的客户端,请使用内置的本地桥接脚本(`docs/mcp.json`):
```json
{
"mcpServers": {
"voicestudio": {
"command": "python",
"args": ["-m", "backend.mcp_shim"],
"cwd": "/path/to/VoiceStudio"
}
}
}
```
支持 `generate_speech``clone_voice``transcribe` 等工具与流式文件输出模式,详见 [docs/mcp.md](docs/mcp.md)。
---
## 🗺️ 路线图
@@ -542,6 +599,13 @@ VoiceStudio **免费**且采用 **AGPL-3.0** 许可——没有付费版,没
VoiceStudio 完全本地运行——卸载就是删除应用及其写入的文件夹(模型缓存、Python 环境、你的声音/项目、配置)。运行 <code>scripts/uninstall.sh</code>macOS/Linux)或 <code>scripts\uninstall.ps1</code>Windows)——它会先以干跑方式列出每个文件夹及其大小,加 <code>--yes</code> 才会真正删除。完整的各平台路径列表和应用移除步骤见 <a href="docs/install/uninstall.md"><b>docs/install/uninstall.md</b></a>。
</details>
## 🛡️ 负责任使用与安全
VoiceStudio 在个人硬件上提供零样本语音克隆与语音创作能力。我们提倡负责任的技术使用:
- **明确授权:** 严禁在未经说话人本人知情并明确授权的情况下克隆其声音。
- **AI 溯源:** VoiceStudio 默认集成 [AudioSeal](https://github.com/facebookresearch/audioseal) 不可见神经音频水印,在完全不影响听感音质的前提下精准标记合成语音。
- **本地隐私:** 默认本地工作流下,所有音频、声音档案、项目与转录文本始终保存在你的本地设备上;仅当你主动配置远程工作节点或第三方 ASR 端点时,相应数据才会传输到对应服务。
---
<a id="license"></a>
+114 -2
View File
@@ -32,17 +32,129 @@ def _public_routing_reason(status: object, diagnostic: object) -> str:
return _ROUTING_BY_STATUS.get(status, _ROUTING_UNAVAILABLE)
# Categories for WHY an engine is unavailable. The probe's own sentence cannot
# cross the boundary — it carries exception text, local paths and sometimes
# credentials — but "Engine unavailable. Check installation and configuration."
# told the user nothing at all, and "Last error: A previous engine check
# failed." reads like a crash rather than "you have not installed this yet"
# (#1866). Classifying the private diagnostic into an owned sentence keeps the
# boundary intact and still names the kind of problem and the place to fix it.
_UNAVAILABLE_NOT_INSTALLED = (
"This engine's package isn't installed yet. Install it from "
"Model Catalogue → Engines."
)
# An engine gated behind an in-app license review (Supertonic-3, PocketTTS).
# The Model Catalogue shows its Accept button only when the reason matches
# /license not accepted/i (EngineCompatibilityMatrix.reasonMentionsLicense), so
# this sentence must keep those words: collapsing it into the generic line hid
# the only way to enable those engines.
_UNAVAILABLE_LICENSE = (
"License not accepted yet. Review and accept it in "
"Model Catalogue → Engines to enable this engine."
)
# An engine that cannot run on this machine at all: Apple-Silicon-only MLX,
# PyTorch with no Intel Mac build. "Isn't installed yet" or "check
# installation" sent people after an install that could never work.
_UNAVAILABLE_PLATFORM = (
"This engine doesn't run on this computer's platform. Its guide lists "
"the platforms it supports."
)
# Apple Silicon whose PyTorch cannot use the GPU (MPS): the platform is
# right, the installation is not. MLX-Audio / MLX-Whisper need MPS (#390).
_UNAVAILABLE_NO_MPS = (
"This engine needs Apple's GPU (MPS), and this installation's PyTorch "
"can't use it. Updating macOS or reinstalling VoiceStudio usually "
"restores it."
)
_UNAVAILABLE_NEEDS_CONFIG = (
"This engine needs to be configured before it can run. Open "
"Model Catalogue → Engines to finish setting it up."
)
_UNAVAILABLE_FILE_MISSING = (
"A file this engine needs is missing or unreadable. Reinstall it from "
"Model Catalogue → Engines."
)
# The same two cases for an engine the app cannot install for you. "Install it
# from Model Catalogue → Engines" sent people to a page with no Install button
# for that engine — most of the catalogue — which reads as the app being
# broken. The row's own guide link (``docs_url``) is the real next step.
_UNAVAILABLE_NOT_INSTALLED_MANUAL = (
"This engine isn't installed yet, and it has no one-click install. "
"Its guide lists the install steps."
)
_UNAVAILABLE_FILE_MISSING_MANUAL = (
"A file this engine needs is missing or unreadable. Its guide lists the "
"install steps."
)
_MANUAL_INSTALL_VARIANT = {
_UNAVAILABLE_NOT_INSTALLED: _UNAVAILABLE_NOT_INSTALLED_MANUAL,
_UNAVAILABLE_FILE_MISSING: _UNAVAILABLE_FILE_MISSING_MANUAL,
}
# Matched against the lowered probe text. Ordered most specific first: a
# missing file often also says "not installed", and the file case has the more
# useful remedy of the two.
_UNAVAILABLE_SIGNATURES = (
# First: its probe text also says "Open Model Catalogue", and the
# license is the one gap only the user can close.
(_UNAVAILABLE_LICENSE, ("license not accepted",)),
# Before the install and file checks: a platform reason often also says
# "unavailable" or names a missing wheel, and no install can fix it. Not
# "apple silicon only": mlx-audio says that on an M-series Mac too, when
# the package is merely missing and installing does help.
(_UNAVAILABLE_PLATFORM, (
"requires apple silicon", "not supported on this platform",
"unavailable on intel macs", "no macos x86_64 wheel",
"no windows install", "not supported on windows",
)),
(_UNAVAILABLE_NO_MPS, ("torch mps unavailable",)),
(_UNAVAILABLE_FILE_MISSING, (
"file is missing", "file is empty", "file is unreadable",
"script missing", "binary", "not found at",
)),
(_UNAVAILABLE_NEEDS_CONFIG, (
"environment variable", "configure a server endpoint", "api key",
"unconfigured", "set the", "base url",
)),
(_UNAVAILABLE_NOT_INSTALLED, (
"not installed", "package missing", "not available", "no module named",
"import ", "unavailable:", "failed to load",
)),
)
def _public_unavailable_reason(diagnostic: object) -> str:
"""Map a private availability probe to an accurate stable category."""
private = diagnostic.lower() if isinstance(diagnostic, str) else ""
for public, markers in _UNAVAILABLE_SIGNATURES:
if any(marker in private for marker in markers):
return public
return _UNAVAILABLE
def public_backends(entries: list[dict]) -> list[dict]:
"""Copy registry entries while replacing service diagnostics.
Availability probes may contain exception text, local paths, tracebacks, or
credentials. Installation hints are registry-authored and remain intact.
credentials. Registry-authored fields are not probe output and remain
intact: ``install_hint``, ``setup_snippet`` and ``docs_url`` are all
VoiceStudio-owned constants keyed on the engine id, so an unavailable row
still has something actionable to show and somewhere to send the user
(#1866) even though ``reason``/``last_error`` are replaced here.
"""
safe: list[dict] = []
for entry in entries:
item = dict(entry)
if item.get("reason") is not None:
item["reason"] = _UNAVAILABLE
reason = _public_unavailable_reason(item["reason"])
# Only a row that explicitly says it has NO one-click install gets
# the manual wording. Rows without the field (ASR, LLM,
# translation — some of which have installers of their own) keep
# the line that points at Model Catalogue.
if item.get("one_click_install") is False:
reason = _MANUAL_INSTALL_VARIANT.get(reason, reason)
item["reason"] = reason
if item.get("last_error") is not None:
item["last_error"] = _PREVIOUS_FAILURE
if item.get("routing_reason") is not None:
+37 -14
View File
@@ -57,11 +57,12 @@ _PREVIEW_SEED = 42
# 32 reliably converges to speech across the gallery's instruct/script space
# at a one-time (cached) render cost.
_PREVIEW_NUM_STEP = 32
# Spectral-flatness floor below which a render is a degenerate tonal artifact
# rather than speech. Real, mastered speech sits ~0.040.07; a tonal buzz
# collapses to <0.005. 0.015 separates the two with wide margin and sits well
# below even breathy/whisper voices (which are broadband → high flatness).
_DEGENERATE_FLATNESS = 0.015
# Reject near-pure tonal artifacts using mean framed spectral flatness.
# Calibrated against the tracked speech demos exercised by
# test_archetype_preview_quality.py: the quietest (Mandarin dubbing, 44.1 kHz)
# measures ~7.7e-6, while the worst tested tonal buzz measures ~3.3e-9.
# 1e-7 leaves >10x margin on both sides without rejecting low-flatness speech.
_DEGENERATE_FLATNESS = 1e-7
def _preview_key(a: dict) -> str:
@@ -248,24 +249,46 @@ def _is_blank_audio(audio_tensor) -> bool:
return False
_FLATNESS_FRAME = 1024
_FLATNESS_HOP = 512
#: Frames quieter than this fraction of the loudest frame's energy are the gaps
#: between words, not speech; their spectrum is the noise floor and averaging it
#: in drags the measurement toward the value of whatever silence sounds like.
_FLATNESS_FRAME_FLOOR = 1e-4
def _spectral_flatness(audio_tensor) -> Optional[float]:
"""Geometric-mean / arithmetic-mean of the power spectrum.
"""Mean per-frame geometric-mean / arithmetic-mean of the power spectrum.
~1.0 for broadband noise, 0 for a pure tone. The degenerate diffusion
renders this guards against are near-pure tonal buzzes (flatness <0.005),
distinct from both silence (caught by ``_is_blank_audio``) and real speech
(~0.04+). Returns ``None`` if it can't be computed so callers don't act on
a bad measurement.
renders this guards against are near-pure tonal buzzes, distinct from both
silence (caught by ``_is_blank_audio``) and real speech. Returns ``None``
if it can't be computed so callers don't act on a bad measurement.
Measured over short frames and averaged the standard definition. A single
FFT of the whole clip (what this used to do) is not the same quantity: its
frequency resolution grows with clip length, so speech harmonics carve
ever-deeper nulls into the spectrum and the geometric mean collapses. That
made the result depend on how long the clip was rather than on what it
sounded like, and put real speech below the rejection threshold.
"""
try:
import torch
t = audio_tensor if isinstance(audio_tensor, torch.Tensor) else torch.as_tensor(audio_tensor)
t = t.detach().to("cpu", dtype=torch.float32).flatten()
if t.numel() < 1024 or not torch.isfinite(t).all():
t = t.detach().to("cpu", dtype=torch.float32)
if t.ndim > 1:
t = t.mean(dim=0)
t = t.flatten()
if t.numel() < _FLATNESS_FRAME or not torch.isfinite(t).all():
return None
spec = torch.fft.rfft(t * torch.hann_window(t.numel())).abs().pow(2) + 1e-12
return float(torch.exp(torch.mean(torch.log(spec))) / torch.mean(spec))
frames = t.unfold(0, _FLATNESS_FRAME, _FLATNESS_HOP)
spec = torch.fft.rfft(frames * torch.hann_window(_FLATNESS_FRAME)).abs().pow(2) + 1e-12
energy = spec.sum(dim=1)
spec = spec[energy > energy.max() * _FLATNESS_FRAME_FLOOR]
if spec.shape[0] == 0:
return None
return float((torch.exp(spec.log().mean(dim=1)) / spec.mean(dim=1)).mean())
except Exception: # never let the checker itself block a render
return None
+17 -1
View File
@@ -718,6 +718,10 @@ def _remote_chapter_call(chapter, *, engine_id, default_voice, voice_map,
"expressive": opts.to_manifest(), "watermark": bool(watermark_enabled()),
}
signature = hashlib.sha256(json.dumps(params, sort_keys=True, default=str).encode()).hexdigest()
# The worker synthesizes from ``spans``, but the gateway and scheduler read
# top-level ``text`` to scale the remote execution deadline. Add this after
# the signature so existing content-addressed remote cache keys still hit.
params["text"] = "\n".join(row["text"] for row in rows)
wav_path = os.path.join(cache_dir, f"remote-{signature}.wav")
def decode(result):
@@ -739,7 +743,7 @@ async def _run_chapter(chapter, *, operation="audiobook", decision, job, default
voice_map, lexicon, cache_dir):
"""Run one chapter through the gateway; local preparation stays lazy."""
from services import gpu_gateway
from services.tts_backend import active_backend_id
from services.tts_backend import active_backend_id, get_backend_class
engine_id = active_backend_id()
remote, remote_cache = _remote_chapter_call(
@@ -753,15 +757,27 @@ async def _run_chapter(chapter, *, operation="audiobook", decision, job, default
return remote_cache, float(info.duration), True, None
async def prepare_local():
from services.model_manager import generate_timeout_s
synth, sr, resolve, local_engine = await _prepare_synth(
default_voice, language=language, opts=opts, voice_map=voice_map
)
try:
timeout_engine = get_backend_class(local_engine)
except ValueError:
# Tests and third-party integrations may inject a synth under a
# non-catalogue id. Keep the canonical host/text policy available;
# registered production engines still add their routing metadata.
timeout_engine = None
return gpu_gateway.LocalCall(
fn=lambda: _render_chapter_cached(
chapter, synth, sr, local_engine, resolve, cache_dir, lexicon,
language, opts, voice_map,
),
what="Audiobook chapter",
timeout=generate_timeout_s(
remote.params["text"], engine=timeout_engine
),
)
return await gpu_gateway.run(
+19 -3
View File
@@ -111,6 +111,24 @@ BATCH_WIDTH_ENV = "OMNIVOICE_DUB_BATCH_WIDTH"
#: that costs more than the saving.
_MAX_BATCH_WIDTH = 16
# Bound each allocation while persisting multipart uploads. Video inputs can
# be many gigabytes; `await UploadFile.read()` with no size used to mirror the
# entire file in process memory before writing it back out.
_UPLOAD_CHUNK_BYTES = 1024 * 1024
async def _save_upload(upload: UploadFile, destination: str) -> None:
try:
with open(destination, "wb") as output:
while chunk := await upload.read(_UPLOAD_CHUNK_BYTES):
output.write(chunk)
except BaseException:
try:
unlink_if_present(destination)
except FileCleanupError:
logger.warning("Could not remove incomplete batch upload", exc_info=True)
raise
def _native_batch_width(backend) -> int:
"""How many segments to render in one native batch on THIS host.
@@ -690,9 +708,7 @@ async def enqueue_batch_job(
ext = os.path.splitext(video.filename or "video.mp4")[1] or ".mp4"
video_path = os.path.join(batch_dir, f"{job_id}{ext}")
with open(video_path, "wb") as f:
content = await video.read()
f.write(content)
await _save_upload(video, video_path)
job = {
"id": job_id,
+20 -4
View File
@@ -28,6 +28,17 @@ router = APIRouter()
logger = logging.getLogger("omnivoice.capture")
def _timing(value):
"""A segment timing, or ``None`` when the engine could not determine one.
``dict.get(key, 0)`` hands back a stored ``None`` rather than the default,
because the key is present so rounding it raised and took a transcript
that was otherwise fine down with it (#1904). Pass the null through instead:
the segment list renders whichever half of the range is known.
"""
return round(value, 2) if isinstance(value, (int, float)) else None
def _truthy(value: Optional[str]) -> bool:
"""Parse a multipart form flag. Treats '1'/'true'/'yes'/'on'/'auto'
(any case) as on; everything else including None as off."""
@@ -162,10 +173,15 @@ async def transcribe_audio(
from services.text_polish import polish_text
full_text = polish_text(full_text)
# Calculate audio duration from segments if available
# Calculate audio duration from segments if available. A segment whose
# timing the engine could not determine carries end=None (sherpa's
# _sherpa_result when the sample rate yields no duration, and every
# plain-text OpenAI-compatible response), so measure only the ones that
# have a number and keep 0.0 when none do.
duration = 0.0
if segments:
duration = max(s.get("end", 0) for s in segments)
ends = [e for e in (s.get("end") for s in segments) if isinstance(e, (int, float))]
duration = max(ends) if ends else 0.0
detected_lang = result.get("language", language or "unknown")
@@ -194,8 +210,8 @@ async def transcribe_audio(
"text": full_text,
"segments": [
{
"start": round(s.get("start", 0), 2),
"end": round(s.get("end", 0), 2),
"start": _timing(s.get("start", 0)),
"end": _timing(s.get("end", 0)),
"text": s.get("text", "").strip(),
}
for s in segments
+29 -4
View File
@@ -55,6 +55,17 @@ from services.text_polish import polish_text
router = APIRouter()
logger = logging.getLogger("omnivoice.capture_ws")
def _timing(value):
"""A segment timing, or ``None`` when the engine could not determine one.
``dict.get(key, 0)`` returns a stored ``None`` rather than the default, so
rounding it raised (#1904). The null is the honest answer here — this module
emits it deliberately for un-endpointed utterances and the segment list
renders whichever half of the range is known.
"""
return round(value, 2) if isinstance(value, (int, float)) else None
SPEECH_PROTOCOL = "voicestudio.speech.v1"
PLATFORM_STREAM_PATH = "/v1/audio/transcriptions/stream"
@@ -349,6 +360,7 @@ async def ws_transcribe(websocket: WebSocket):
audio_chunks: list[bytes] = []
total_bytes = 0
last_audio_time = time.monotonic()
paused = False
running = True
partial_text = ""
# Track whether the client initiated the disconnect. When True the
@@ -366,7 +378,7 @@ async def ws_transcribe(websocket: WebSocket):
message as the authoritative result and skip the duplicate HTTP
POST that used to run on every dictation.
"""
nonlocal total_bytes, last_audio_time, running, client_disconnected
nonlocal total_bytes, last_audio_time, running, client_disconnected, paused
try:
while running:
msg = await websocket.receive()
@@ -397,6 +409,10 @@ async def ws_transcribe(websocket: WebSocket):
total_bytes += len(data)
last_audio_time = time.monotonic()
continue
if msg.get("text") in ("PAUSE", "RESUME"):
paused = msg["text"] == "PAUSE"
last_audio_time = time.monotonic()
continue
if _is_end_control(msg.get("text")):
# Client signals end-of-audio but stays connected for `final`.
running = False
@@ -429,6 +445,9 @@ async def ws_transcribe(websocket: WebSocket):
if not running:
break
if paused:
continue
# Check silence timeout
if time.monotonic() - last_audio_time > SILENCE_TIMEOUT_S and total_bytes > MIN_BUFFER_BYTES:
running = False
@@ -1187,13 +1206,19 @@ async def _transcribe_buffer_full(
from services.refinement import collapse_repetitive_artifacts
full_text = collapse_repetitive_artifacts(full_text)
duration = max((s.get("end", 0) for s in segments), default=0.0)
# end=None means the engine could not determine the timing — this
# module writes exactly that in its own streaming payloads, and
# sherpa's _sherpa_result does too when the sample rate yields no
# duration. Measure only real numbers, and pass the nulls through
# rather than rounding them (#1904).
ends = [e for e in (s.get("end") for s in segments) if isinstance(e, (int, float))]
duration = max(ends) if ends else 0.0
return {
"text": full_text,
"segments": [
{"start": round(s.get("start", 0), 2),
"end": round(s.get("end", 0), 2),
{"start": _timing(s.get("start", 0)),
"end": _timing(s.get("end", 0)),
"text": s.get("text", "").strip()}
for s in segments
],
+12
View File
@@ -86,6 +86,18 @@ def list_dictation_models():
}
@router.get("/dictation/readiness", dependencies=[Depends(require_local)])
def dictation_readiness(model_id: str | None = None) -> dict:
"""Check capture's model selection without loading or downloading weights."""
from services.asr_backend import asr_model_missing_error
missing = asr_model_missing_error(
purpose="dictation",
sherpa_model_id=model_id or _read_prefs()["model_id"],
)
return {"ready": missing is None, "missing": missing}
@router.get("/dictation/prefs", dependencies=[Depends(require_local)])
def get_dictation_prefs():
return _read_prefs()
+43 -11
View File
@@ -518,9 +518,12 @@ _ingest_gen = dub_pipeline.ingest_pipeline
#: container so a mislabelled video can't slip past the video-skipping branch.
_AUDIO_EXTS = {".wav", ".mp3", ".m4a", ".aac", ".flac", ".ogg", ".opus", ".wma"}
# Source-language choices exposed by the first-party dub UI. Keeping this an
# allow-list rejects language names and private-use BCP-47 tags before they are
# persisted as ASR overrides. Values are normalized to lowercase below.
# Source-language choices exposed by the first-party dub UI, plus every
# language code Whisper can write back after auto-detection. A restored job
# may reuse that detected value as the next upload's override, so rejecting our
# own persisted codes strands otherwise valid dubbing sessions (#1737).
# Keeping this an allow-list still rejects language names and private-use
# BCP-47 tags. Values are normalized to lowercase below.
_DUB_SOURCE_LANG_CODES = frozenset({
"af", "sq", "am", "ar", "hy", "az", "eu", "be", "bn", "bs", "bg",
"my", "ca", "cmn-hans", "cmn-hant", "hr", "cs", "da", "nl", "en",
@@ -531,19 +534,48 @@ _DUB_SOURCE_LANG_CODES = frozenset({
"ru", "sm", "gd", "sr", "sn", "sd", "si", "sk", "sl", "so", "es",
"su", "sw", "sv", "tg", "ta", "te", "th", "tr", "uk", "ur", "uz",
"vi", "cy", "xh", "yi", "yo", "zu",
"as", "ba", "bo", "br", "fo", "lb", "ln", "mg", "nn", "oc", "sa",
"tk", "tl", "tt", "yue", "zh",
})
def _source_lang_override(value: str | None) -> str | None:
"""Normalize a user-selected source language; auto/und means detect."""
"""Normalize a user-selected source language; auto/und means detect.
A rejection NAMES the code it rejected. "Invalid source language code" on
its own cannot be acted on or reported usefully: it does not say which of
the ninety-odd codes was wrong, so neither the user nor a maintainer
reading the auto-filed issue can tell whether the picker offered something
the backend does not accept, or a stale preference from an older build is
still being sent (#1960).
The value is a language code the user chose from a menu not private
data and the neighbouring engine validator already echoes its input the
same way.
"""
code = (value or "").strip().lower()
if code in {"", "auto", "und"}:
return None
if code not in _DUB_SOURCE_LANG_CODES:
raise HTTPException(status_code=400, detail="Invalid source language code")
raise HTTPException(
status_code=400,
detail=(
f"Invalid source language code: {code!r}. Pick a language from "
"the Dubbing source-language menu, or leave it on auto-detect."
),
)
return code
def _detected_source_lang(value: str | None) -> str:
"""Normalize an ASR language without truncating valid three-letter codes."""
code = (value or "en").split("_", 1)[0].strip().lower()
if code in _DUB_SOURCE_LANG_CODES:
return code
short = code[:2]
return short if short in _DUB_SOURCE_LANG_CODES else "en"
@router.post("/dub/upload")
async def dub_upload(
video: UploadFile = File(...),
@@ -1809,9 +1841,9 @@ async def dub_transcribe_stream(
except Exception as e:
logger.warning("speaker_clone extraction skipped: %s", e)
job["source_lang"] = job.get("source_lang_override") or (
(detected_lang or "en").split("_")[0][:2] or "en"
).lower()
job["source_lang"] = job.get("source_lang_override") or _detected_source_lang(
detected_lang
)
job["full_transcript"] = " ".join(s.get("text", "") for s in final_segs)
_save_job(job_id, job)
@@ -2008,9 +2040,9 @@ async def dub_transcribe(job_id: str, num_speakers: Optional[int] = None):
except Exception as e:
logger.warning("Failed to unload ASR backend: %s", e)
job["source_lang"] = job.get("source_lang_override") or (
(detected_lang or "en").split("_")[0][:2] or "en"
).lower()
job["source_lang"] = job.get("source_lang_override") or _detected_source_lang(
detected_lang
)
scene_cuts = job.get("scene_cuts") or []
segments = segment_transcript(result, duration=job.get("duration", 0.0), scene_cuts=scene_cuts)
+97 -3
View File
@@ -23,6 +23,7 @@ from services.ffmpeg_utils import (
find_ffmpeg,
run_ffmpeg,
)
from services.karaoke_ass import build_ass, scale_words
from services.video_retime import (
DRIFT_TOLERANCE_S,
RetimeError,
@@ -403,6 +404,27 @@ def _write_burn_srt(job: dict, exports_dir: str, stamp: str, dual: bool,
return sub_path
def _write_burn_ass(job: dict, exports_dir: str, stamp: str,
fitted_segments: "list[dict] | None" = None,
lang: "str | None" = None) -> str | None:
"""Karaoke variant of ``_write_burn_srt``: word-timed ASS via ``build_ass``.
Same text/timing resolution (``_segments_for_lang`` + fitted-cue overlay,
which also scales per-word times onto the fitted timeline); the basename
is plain ASCII under exports_dir so it is ffmpeg-filter-safe. Returns
None if there are no segments to render.
"""
segments = _segments_for_lang(job, lang)
if not segments:
return None
if fitted_segments:
segments = _apply_fitted_times(segments, fitted_segments)
sub_path = os.path.join(exports_dir, f"burn_subs_{stamp}.ass")
with open(sub_path, "w", encoding="utf-8") as f:
f.write(build_ass(segments))
return sub_path
def _ffmpeg_filter_escape(path: str) -> str:
"""Escape a path for use inside an ffmpeg filter value (subtitles=...).
@@ -515,6 +537,20 @@ def _apply_fitted_times(segments: list[dict], fitted: list[dict]) -> list[dict]:
patched = dict(seg)
patched["start"] = float(cue["start"])
patched["end"] = float(cue["end"])
# Karaoke burn-in: persisted word times live on the original timeline;
# scale them linearly onto the fitted cue span so the highlight sweep
# follows the retimed audio. Degenerate spans drop the words — export
# then falls back to an even split over the fitted span. Inert for
# SRT/VTT, which never read ``words``.
if isinstance(seg.get("words"), list) and seg.get("words"):
scaled = scale_words(
seg["words"], seg.get("start", 0.0), seg.get("end", 0.0),
patched["start"], patched["end"],
)
if scaled is not None:
patched["words"] = scaled
else:
patched.pop("words", None)
out.append(patched)
return out
@@ -577,6 +613,7 @@ async def dub_download(
save_authorization: str = Header("", alias="X-VoiceStudio-Path-Authorization"),
burn_subs: bool = Query(False, description="Burn subtitles into the video stream (forces re-encode). Uses dual-subtitle layout when dual=1."),
dual: bool = Query(False, description="When burn_subs=1, render translated on top of italicised original."),
karaoke: bool = Query(False, description="When burn_subs=1, burn a word-timed karaoke highlight (ASS) instead of line subtitles. Ignored when dual=1 (dual karaoke is unsupported — the line burn renders instead)."),
out_format: str = Query("m4a", description="Audio-only jobs (#119): output container — wav, m4a, mp3, or flac. Ignored for video jobs."),
):
# Strict allowlist on the path param BEFORE it reaches any filesystem
@@ -729,7 +766,18 @@ async def dub_download(
fitted_segments = _fitted_segments_for(job, default_track) if default_track and default_track != "original" else None
# Burn the DEFAULT track's text (P1.2) — it's the audio the viewer hears.
_burn_lang = default_track if default_track and default_track != "original" else None
sub_path = _write_burn_srt(job, exports_dir, stamp, dual, fitted_segments=fitted_segments, lang=_burn_lang) if burn_subs else None
# Karaoke (word-highlight) burn writes an ASS instead of the line SRT.
# Dual layout keeps the line burn — dual karaoke is out of scope, matching
# the disabled control in the Export drawer. The default (karaoke off)
# takes exactly the legacy SRT path.
sub_path = None
sub_is_ass = False
if burn_subs:
if karaoke and not dual:
sub_path = _write_burn_ass(job, exports_dir, stamp, fitted_segments=fitted_segments, lang=_burn_lang)
sub_is_ass = sub_path is not None
if sub_path is None:
sub_path = _write_burn_srt(job, exports_dir, stamp, dual, fitted_segments=fitted_segments, lang=_burn_lang)
# ── Smart Fit video retime (two-tier) ─────────────────────────────────
# Tier 1 (≤48 chunks): single filter_complex graph inlined into the mux
@@ -829,14 +877,16 @@ async def dub_download(
esc = _ffmpeg_filter_escape(sub_path)
# Burn AFTER any retime so cues (already on the fitted timeline for
# Smart Fit) land on the retimed video. Without retime this reduces
# to the legacy `[0:v]subtitles=…[vsub]` graph.
# to the legacy `[0:v]subtitles=…[vsub]` graph. Karaoke burns the
# word-timed ASS through the ass filter at the same graph position.
if video_map.startswith("["):
sub_src = video_map
elif retimed_idx is not None:
sub_src = f"[{retimed_idx}:v]"
else:
sub_src = "[0:v]"
filter_parts.append(f"{sub_src}subtitles='{esc}'[vsub]")
_sub_filter = "ass" if sub_is_ass else "subtitles"
filter_parts.append(f"{sub_src}{_sub_filter}='{esc}'[vsub]")
video_map = "[vsub]"
if stretch_entry:
orig_dur = float(stretch_entry.get("orig_duration") or job.get("duration") or 0.0)
@@ -1744,6 +1794,50 @@ async def dub_export_vtt(
)
@router.get("/dub/ass/{job_id}")
@router.get("/dub/ass/{job_id}/{filename}")
async def dub_export_ass(
job_id: str,
lang: str = Query(None, description="Track language code. Same text/timing resolution as /dub/srt, rendered as a karaoke (word-highlight) ASS sidecar."),
):
"""Karaoke ASS sidecar — the same script the karaoke burn-in renders.
Raw text body like /dub/srt and /dub/vtt (the Tauri side writes the file
itself; no ?save_path= variant see the comment above /dub/srt).
"""
_job_dir_or_400(job_id)
lang = _safe_lang_or_400(lang)
job = _get_job(job_id)
if not job:
raise HTTPException(status_code=404, detail="Job not found")
segments = _segments_for_lang(job, lang)
if not segments:
raise HTTPException(status_code=400, detail="No transcript segments available")
# Same strategy-aware cue timing as /dub/srt. The fitted overlay also
# scales word times; the stretch_video cue path has no per-word record,
# so words are dropped and build_ass even-splits over the new spans.
fitted = _fitted_segments_for(job, lang)
if fitted:
segments = _apply_fitted_times(segments, fitted)
else:
cues = _fitted_cue_times(job, lang)
if cues:
segments = [
{**{k: v for k, v in seg.items() if k != "words"}, "start": s, "end": e}
for seg, (s, e) in zip(segments, cues)
]
base_name = os.path.splitext(job.get('filename', 'video'))[0]
dl_name = f"subtitles_{base_name}_karaoke.ass"
return Response(
content=build_ass(segments),
media_type="text/plain",
headers={"Content-Disposition": content_disposition(dl_name)},
)
@router.get("/dub/export-segments/{job_id}")
async def dub_export_segments_zip(job_id: str, lang: str = Query(None)):
import zipfile
+73 -3
View File
@@ -42,10 +42,26 @@ _FAMILIES = {
}
def _catalogue_active_id(family: str, module) -> str:
"""Return the active id represented by the public engine catalogue."""
active = module.active_backend_id()
if family != "tts" or active != "omnivoice-subprocess":
return active
from core.device_caps import detect_host_caps
try:
return "omnivoice" if detect_host_caps().family == "mps" else active
except Exception:
return active
def _family_payload(family: str, module):
"""Public inventory plus whether an environment pin owns this family."""
return {
"active": module.active_backend_id(),
# MPS hides the explicit compatibility row, so legacy configs report
# the visible canonical equivalent as active to picker consumers.
"active": _catalogue_active_id(family, module),
"env_override": bool(os.environ.get(f"OMNIVOICE_{family.upper()}_BACKEND")),
"backends": public_backends(module.list_backends()),
}
@@ -188,6 +204,11 @@ async def uninstall_translation_engine(engine_id: str):
pkg = entry.get("pip_package")
if not pkg:
return {"status": "no_op", "engine": engine_id}
# The builtin flag is a promise someone has to remember to make; this
# check does not depend on it (#2019).
blocked = translation_engines.uninstall_blocker(engine_id)
if blocked:
raise HTTPException(status_code=blocked[0], detail=blocked[1])
rc, out = await translation_engines.run_pip(["uninstall", "-y", pkg])
if rc != 0:
raise HTTPException(status_code=500, detail=f"pip uninstall {pkg} failed ({rc}): {out[-1000:]}")
@@ -230,6 +251,11 @@ def install_sidecar_engine(engine_id: str):
from services import sidecar_install
try:
return sidecar_install.start_install(engine_id)
except sidecar_install.HostUnsupported as exc:
# The engine has an installer, but not one that can work on this
# machine. 409, not 404: the route is right, the host is the problem,
# and the message (a VoiceStudio-owned sentence) says what to do.
raise HTTPException(status_code=409, detail=str(exc))
except KeyError:
raise HTTPException(
status_code=404,
@@ -354,6 +380,9 @@ def engine_health(engine_id: str):
)
t0 = perf_counter()
# Stable exception class when the probe itself raised, None when it merely
# returned not-available. Never the exception text — see the log line below.
raised_class: str | None = None
if hasattr(cls, "health_check"):
# SubprocessBackend path — spawn sidecar (if not running) and ping.
# ``health_check`` already swallows its own exceptions per Plan
@@ -364,6 +393,7 @@ def engine_health(engine_id: str):
ok, msg = instance.health_check()
except Exception as exc:
ok, msg = False, f"{type(exc).__name__}: {exc}"
raised_class = type(exc).__name__
else:
# In-process backend — `is_available()` is the classmethod-level
# liveness check. Cheap and side-effect-free for every shipping
@@ -372,6 +402,7 @@ def engine_health(engine_id: str):
ok, msg = cls.is_available()
except Exception as exc:
ok, msg = False, f"{type(exc).__name__}: {exc}"
raised_class = type(exc).__name__
# Engine-owned output can contain much more than shaped HF tokens: local
# paths, arbitrary credentials, source lines, or a nested traceback.
@@ -379,7 +410,38 @@ def engine_health(engine_id: str):
latency_ms = (perf_counter() - t0) * 1000.0
if not ok:
logger.warning("Engine health check failed; details withheld")
# The response tells the user to "check the backend log for details",
# and docs/engines/*.md asks a user diagnosing an unavailable engine to
# copy that engine's log lines. The old line named neither the engine
# nor anything about the probe, so neither instruction could be
# followed (#1866).
#
# `probe=` reports what the PROBE DID, not what went wrong. It cannot
# classify the cause: SubprocessBackend.health_check() swallows its own
# exceptions per Plan 02-01's contract, so a dead sidecar and a package
# that was never installed both arrive here as `returned-unavailable`.
# Separating those needs structured failure metadata from the probes
# themselves, which is a wider change than this one.
#
# Still no diagnostic text and still not the caller-supplied id: the
# engine id comes off the resolved registry class and a raised probe
# contributes only its exception class, the same shape
# core.public_errors.public_failure() logs as `class=`.
# tests/test_response_safety.py pins that boundary and passes
# unchanged.
#
# The id is a class attribute off the registry rather than caller
# input, but this line is a log-injection surface either way, so it is
# flattened to a single token before it goes in.
engine_label = str(getattr(cls, "id", None) or cls.__name__)
engine_label = "".join(
c if (c.isalnum() or c in "-_.") else "-" for c in engine_label
)[:64]
logger.warning(
"Engine health check failed; engine=%s probe=%s, details withheld",
engine_label or "unknown",
f"raised:{raised_class}" if raised_class else "returned-unavailable",
)
return {
"id": engine_id,
"ok": bool(ok),
@@ -589,7 +651,15 @@ def select_engine(req: SelectEngineRequest):
if not family:
raise HTTPException(400, f"Unknown family: {req.family}. Expected one of tts/asr/llm.")
module, pref_key = family
available = {b["id"]: b for b in module.list_backends()}
# MPS intentionally hides the redundant explicit OmniVoice sidecar from
# the picker, but existing scripts and saved preferences may still submit
# that supported compatibility id directly.
rows = (
module.list_backends(include_hidden=True)
if req.family == "tts"
else module.list_backends()
)
available = {b["id"]: b for b in rows}
if req.backend_id not in available:
raise HTTPException(400, f"Unknown {req.family} backend: {req.backend_id!r}")
entry = available[req.backend_id]
+181 -76
View File
@@ -125,6 +125,96 @@ def _profile_instruct(row):
return heal_design_instruct(row["instruct"], vd)
def _resolve_profile_conditioning(row, *, ref_text=None, instruct=None,
seed=None, language=None):
"""Resolve a ``voice_profiles`` row into generation conditioning.
Extracted verbatim from /generate's inline profile-resolution block so
other synthesis routes (POST /convert) share the exact same semantics
lock wins, ``kind`` is authoritative (0005), legacy pre-0004 rows fall
back to the is_locked/instruct inference, and #533's language fill.
Request-supplied values (``ref_text``/``instruct``/``seed``/``language``)
always win over the stored row; only gaps are filled. Returns a dict with
``ref_audio_path`` / ``ref_text`` / ``instruct`` / ``seed`` / ``language``
/ ``kind`` plus ``persist_ref_text`` True when the caller should cache
an auto-transcribed reference transcript back onto the row (#1032).
"""
out = {
"ref_audio_path": None, "ref_text": ref_text, "instruct": instruct,
"seed": seed, "language": language, "kind": None,
"persist_ref_text": False,
}
# `kind` is authoritative (0005): 'design' profiles condition on their
# deterministic rendered sample + instruct; 'clone' on the user's
# reference. Lock always wins (it pins a specific take). Rows from
# pre-0004 DBs mid-upgrade may lack the column → fall back to the legacy
# is_locked/instruct inference.
try:
profile_kind = row["kind"] or "clone"
except (KeyError, IndexError):
profile_kind = "design" if (
row["instruct"] and not row["is_locked"] and not row["ref_audio_path"]
) else "clone"
out["kind"] = profile_kind
if row["is_locked"] and row["locked_audio_path"]:
out["ref_audio_path"] = os.path.join(VOICES_DIR, row["locked_audio_path"])
if not out["ref_text"]:
out["ref_text"] = row["ref_text"]
if not out["instruct"]:
out["instruct"] = _profile_instruct(row)
if out["seed"] is None and row["seed"] is not None:
out["seed"] = row["seed"]
elif profile_kind == "design":
# Rendered sample (if present) carries the voice identity; instruct
# alone is the fallback for legacy archetype rows.
out["ref_audio_path"] = (
os.path.join(VOICES_DIR, row["ref_audio_path"]) if row["ref_audio_path"] else None
)
if out["ref_audio_path"] and not out["ref_text"] and row["ref_text"]:
out["ref_text"] = row["ref_text"]
if not out["instruct"]:
out["instruct"] = _profile_instruct(row)
if out["seed"] is None and row["seed"] is not None:
out["seed"] = row["seed"]
elif row["instruct"] and not row["is_locked"] and not row["ref_audio_path"]:
# Legacy design-shaped row (pre-0004 archetype materialization failure
# path): instruct-only conditioning.
if not out["instruct"]:
out["instruct"] = _profile_instruct(row)
if out["seed"] is None and row["seed"] is not None:
out["seed"] = row["seed"]
else:
out["ref_audio_path"] = (
os.path.join(VOICES_DIR, row["ref_audio_path"]) if row["ref_audio_path"] else None
)
if not out["ref_text"] and row["ref_text"]:
out["ref_text"] = row["ref_text"]
elif out["ref_audio_path"] and not out["ref_text"]:
# Empty stored transcript → the caller's auto-transcribe will run;
# cache its result onto the profile so it runs ONCE, not on every
# generate (#1032 perf regression).
out["persist_ref_text"] = True
if not out["instruct"] and row["instruct"]:
out["instruct"] = row["instruct"]
if out["seed"] is None and row["seed"] is not None:
out["seed"] = row["seed"]
if out["language"] == "Auto":
out["language"] = None
# #533: a profile's stored language must drive generation when the request
# didn't pin one. An EXPLICIT non-Auto request language still wins; we
# only fill the gap. `row` is a sqlite3.Row, so guard the column lookup
# for pre-language DBs mid-upgrade.
if out["language"] is None:
try:
prof_lang = row["language"]
except (KeyError, IndexError):
prof_lang = None
if prof_lang and prof_lang != "Auto":
out["language"] = prof_lang
return out
def _note_generate_progress() -> None:
"""Tell the pool guard this render just finished a unit of work (#1391).
@@ -714,16 +804,34 @@ def _oom_friendly_reraise(e):
) from e
def _generate_timeout_s(text: str, *, execution_device=None) -> float:
def _generate_timeout_s(
text: str,
*,
execution_device=None,
min_vram_gb=0.0,
hardware_family=None,
vram_gb=None,
) -> float:
"""Wall-clock budget for one generate, scaled to the request.
Thin alias for the canonical helper, which moved to
``services.model_manager.generate_timeout_s`` (#1190) so /v1/audio/speech,
batch, dub and archetype previews share it instead of each re-deriving (or,
as they did, silently keeping the flat 300s).
``min_vram_gb`` is the engine's declared VRAM floor. A GPU below it pages to
system RAM and renders slower than this machine's CPU, so it must not be
budgeted as fast hardware (#1804) — the same figure the dispatch already
hands the guard so a timeout message can name the card (#1226/#1222).
"""
from services.model_manager import generate_timeout_s
return generate_timeout_s(text, execution_device=execution_device)
return generate_timeout_s(
text,
execution_device=execution_device,
min_vram_gb=min_vram_gb,
hardware_family=hardware_family,
vram_gb=vram_gb,
)
def _run_inference(
@@ -1344,6 +1452,8 @@ async def generate_speech(
# local fallback call's timeout device-neutral so the closure is valid
# without pretending the control plane describes the remote worker.
_routing = {"effective_device": None}
_routing_hardware_family = None
_routing_vram_gb = None
if not _remote:
# Single-active-engine memory discipline: hand back any OTHER resident
@@ -1400,11 +1510,16 @@ async def generate_speech(
# 4090 from a Mac control plane would be refused by a gate describing
# a machine that is about to do nothing.
from core.device_caps import detect_host_caps
from services.engine_routing import resolve_routing, routing_notice
_routing = resolve_routing(
getattr(backend_cls, "gpu_compat", ("cpu",)), detect_host_caps(),
_engine_min_vram_gb,
from services.engine_routing import (
routing_notice,
runtime_compute_profile_async,
)
_routing = await runtime_compute_profile_async(
backend_cls, detect_host_caps()
)
_engine_min_vram_gb = _routing["min_vram_gb"]
_routing_hardware_family = _routing.get("runtime_hardware_family")
_routing_vram_gb = _routing.get("runtime_vram_gb")
if _routing["routing_status"] == "unavailable":
# The engine needs an accelerator this host lacks and has no CPU path.
raise HTTPException(status_code=400, detail=_routing["routing_reason"])
@@ -1461,70 +1576,21 @@ async def generate_speech(
row = conn.execute("SELECT * FROM voice_profiles WHERE id=?", (profile_id,)).fetchone()
if row:
resolved_profile_id = profile_id
# `kind` is authoritative (0005): 'design' profiles condition on
# their deterministic rendered sample + instruct; 'clone' on the
# user's reference. Lock always wins (it pins a specific take).
# Rows from pre-0004 DBs mid-upgrade may lack the column → fall
# back to the legacy is_locked/instruct inference.
try:
profile_kind = row["kind"] or "clone"
except (KeyError, IndexError):
profile_kind = "design" if (row["instruct"] and not row["is_locked"] and not row["ref_audio_path"]) else "clone"
history_mode = profile_kind
if row["is_locked"] and row["locked_audio_path"]:
ref_audio_path = os.path.join(VOICES_DIR, row["locked_audio_path"])
if not ref_text:
ref_text = row["ref_text"]
if not instruct:
instruct = _profile_instruct(row)
if used_seed is None and row["seed"] is not None:
used_seed = row["seed"]
elif profile_kind == "design":
# Rendered sample (if present) carries the voice identity;
# instruct alone is the fallback for legacy archetype rows.
ref_audio_path = os.path.join(VOICES_DIR, row["ref_audio_path"]) if row["ref_audio_path"] else None
if ref_audio_path and not ref_text and row["ref_text"]:
ref_text = row["ref_text"]
if not instruct:
instruct = _profile_instruct(row)
if used_seed is None and row["seed"] is not None:
used_seed = row["seed"]
elif row["instruct"] and not row["is_locked"] and not row["ref_audio_path"]:
# Legacy design-shaped row (pre-0004 archetype materialization
# failure path): instruct-only conditioning.
if not instruct:
instruct = _profile_instruct(row)
if used_seed is None and row["seed"] is not None:
used_seed = row["seed"]
else:
ref_audio_path = os.path.join(VOICES_DIR, row["ref_audio_path"]) if row["ref_audio_path"] else None
if not ref_text and row["ref_text"]:
ref_text = row["ref_text"]
elif ref_audio_path and not ref_text:
# Empty stored transcript → the auto-transcribe below will
# run; cache its result onto the profile so it runs ONCE,
# not on every generate (#1032 perf regression).
persist_ref_text_profile_id = profile_id
if not instruct and row["instruct"]:
instruct = row["instruct"]
if used_seed is None and row["seed"] is not None:
used_seed = row["seed"]
if language == "Auto":
language = None
# #533: a profile's stored language must drive generation when the
# request didn't pin one. Without this the German (etc.) archetype
# generates with language=None and the model drifts to English —
# even though the archetype PREVIEW renders correctly (archetypes.py
# passes the language). An EXPLICIT non-Auto request language still
# wins; we only fill the gap. `row` is a sqlite3.Row, so guard the
# column lookup for pre-language DBs mid-upgrade.
if language is None:
try:
prof_lang = row["language"]
except (KeyError, IndexError):
prof_lang = None
if prof_lang and prof_lang != "Auto":
language = prof_lang
# Shared with POST /convert — see _resolve_profile_conditioning
# for the resolution rules (kind-authoritative, lock wins, #533
# language fill, #1032 transcript-cache signal).
_cond = _resolve_profile_conditioning(
row, ref_text=ref_text, instruct=instruct, seed=used_seed,
language=language,
)
history_mode = _cond["kind"]
ref_audio_path = _cond["ref_audio_path"]
ref_text = _cond["ref_text"]
instruct = _cond["instruct"]
used_seed = _cond["seed"]
language = _cond["language"]
if _cond["persist_ref_text"]:
persist_ref_text_profile_id = profile_id
elif ref_audio is not None:
try:
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as f:
@@ -1677,7 +1743,13 @@ async def generate_speech(
local=gpu_gateway.LocalCall(
_remote_only_local_call(_target_label),
what="TTS generate",
timeout=_generate_timeout_s(text, execution_device=_routing["effective_device"]),
timeout=_generate_timeout_s(
text,
execution_device=_routing["effective_device"],
min_vram_gb=_engine_min_vram_gb,
hardware_family=_routing_hardware_family,
vram_gb=_routing_vram_gb,
),
min_vram_gb=_engine_min_vram_gb,
),
remote=_remote_call,
@@ -1971,7 +2043,13 @@ async def generate_speech(
),
what="TTS generate",
min_vram_gb=_engine_min_vram_gb,
timeout=_generate_timeout_s(text, execution_device=_routing["effective_device"]),
timeout=_generate_timeout_s(
text,
execution_device=_routing["effective_device"],
min_vram_gb=_engine_min_vram_gb,
hardware_family=_routing_hardware_family,
vram_gb=_routing_vram_gb,
),
on_abandon=release,
)
)
@@ -1991,7 +2069,13 @@ async def generate_speech(
),
what="TTS generate",
min_vram_gb=_engine_min_vram_gb,
timeout=_generate_timeout_s(text, execution_device=_routing["effective_device"]),
timeout=_generate_timeout_s(
text,
execution_device=_routing["effective_device"],
min_vram_gb=_engine_min_vram_gb,
hardware_family=_routing_hardware_family,
vram_gb=_routing_vram_gb,
),
on_abandon=release,
)
)
@@ -2031,7 +2115,13 @@ async def generate_speech(
# Budget scaled to THIS chunk (#1190) — the flat
# 300s here is what made long streamed renders fail
# even after the v0.3.22 scaled budget shipped.
timeout=_generate_timeout_s(chunk_text, execution_device=_routing["effective_device"]),
timeout=_generate_timeout_s(
chunk_text,
execution_device=_routing["effective_device"],
min_vram_gb=_engine_min_vram_gb,
hardware_family=_routing_hardware_family,
vram_gb=_routing_vram_gb,
),
on_abandon=release,
)
)
@@ -2191,7 +2281,13 @@ async def generate_speech(
_REMOTE_OP,
local=gpu_gateway.LocalCall(
_local_render, what="TTS generate",
timeout=_generate_timeout_s(text, execution_device=_routing["effective_device"]),
timeout=_generate_timeout_s(
text,
execution_device=_routing["effective_device"],
min_vram_gb=_engine_min_vram_gb,
hardware_family=_routing_hardware_family,
vram_gb=_routing_vram_gb,
),
min_vram_gb=_engine_min_vram_gb,
on_abandon=release,
),
@@ -2316,7 +2412,16 @@ async def generate_speech(
raise HTTPException(status_code=503, detail=str(e)) from e
except ValueError as e:
logger.error("Validation failed: %s", e)
raise HTTPException(status_code=400, detail=str(e)) from e
# Most ValueErrors here are VoiceStudio's own validation messages and
# are exactly what the user should read. A few are raw library text
# naming parameters and files the user cannot act on — those get the
# owned remedy for their class instead (#1879). Unclassified ones keep
# passing through, so this cannot swallow a good message.
from core.failure import classify, public_hint_for_topic
_topic = classify(str(e))
_owned = public_hint_for_topic(_topic) if _topic else ""
raise HTTPException(status_code=400, detail=_owned or str(e)) from e
except Exception as e:
tb = traceback.format_exc()
logger.error("Inference failed: %s\n%s", e, tb)
+3 -4
View File
@@ -325,10 +325,9 @@ async def create_speech(req: SpeechRequest):
# Routing gate (#21 — no silent CPU fallback), identical to REST /generate.
from core.device_caps import detect_host_caps
from services.engine_routing import resolve_routing, routing_notice
_routing = resolve_routing(
getattr(backend, "gpu_compat", ("cpu",)), detect_host_caps(),
getattr(backend, "min_vram_gb", 0.0),
from services.engine_routing import routing_notice, runtime_compute_profile_async
_routing = await runtime_compute_profile_async(
backend, detect_host_caps()
)
if _routing["routing_status"] == "unavailable":
raise HTTPException(status_code=400, detail=_routing["routing_reason"])
+12 -1
View File
@@ -32,7 +32,11 @@ from pydantic import BaseModel
from api.dependencies import require_admin
from core.db import db_conn
from services.pronunciation import apply_pronunciation, entries_for_language
from services.pronunciation import (
apply_pronunciation,
entries_for_language,
inert_entries_for_language,
)
logger = logging.getLogger("omnivoice.pronunciation")
router = APIRouter(dependencies=[Depends(require_admin)])
@@ -250,11 +254,18 @@ def test_substitution(req: PronTestRequest):
).fetchall()
substituted = apply_pronunciation(req.text, rows, req.language)
applied = entries_for_language(rows, req.language)
# IPA/CMU rows are validated and stored but not applied yet, so a term that
# DOES match can still change nothing. Reporting them separately keeps the
# dry run honest — otherwise it says "no entries match", which is wrong and
# sends the user to re-type an entry that was already correct (#1949).
inert = inert_entries_for_language(rows, req.language)
return {
"input": req.text,
"substituted": substituted,
"changed": substituted != req.text,
"applied_terms": sorted(applied.keys(), key=len, reverse=True),
# Present but not honoured: [{term, type}, …]. Empty on the happy path.
"inert_entries": inert,
}
+10 -11
View File
@@ -35,11 +35,11 @@ class _HFTokenBody(BaseModel):
token: str = Field(..., min_length=1, description="HuggingFace access token")
def _state_response() -> dict:
def _state_response(*, validate: bool = False) -> dict:
"""Return the same shape the React panel renders. Never includes raw token."""
from services import token_resolver
s = token_resolver.state()
s = token_resolver.state(validate=validate)
return {
"active": s["active"],
"sources": [asdict(row) for row in s["sources"]],
@@ -65,8 +65,7 @@ def save_hf_token(body: _HFTokenBody):
@router.delete("/hf-token")
def clear_hf_token(also_clear_hf_cli: bool = Query(False)):
"""Clear the App-source token. Optionally also call huggingface_hub.logout
to clear the canonical HF file. Returns the updated cascade state."""
"""Clear the App token and optionally recognized local Hub token files."""
from services import token_resolver
try:
token_resolver.clear_app_token(also_clear_hf_cli=also_clear_hf_cli)
@@ -82,13 +81,12 @@ def get_hf_token_state(fresh: bool = Query(False)):
``fresh=1`` drops the resolver's whoami validation cache first so the
response re-runs whoami for every source this is what the panel's
"Test now" button sends. Plain GETs (panel mounts) keep the 300s cache
so repeat Settings visits don't hammer the HF API.
"Test now" button sends. Plain GETs only inspect local token presence.
"""
from services import token_resolver
if fresh:
token_resolver.invalidate_cache()
return _state_response()
return _state_response(validate=fresh)
# ── Performance settings (INST-12) ────────────────────────────────────────
@@ -150,7 +148,7 @@ def _compute_device_state() -> dict:
caps = device_caps.detect_host_caps()
env_pin = (os.environ.get("OMNIVOICE_DEVICE") or "").strip().lower()
auto_family = next(
(f for f in ("cuda", "rocm", "xpu", "mps") if f in caps.available_families),
(f for f in device_caps.ACCELERATOR_PRIORITY if f in caps.available_families),
"cpu",
)
value = device_caps.requested_device_override()
@@ -1035,9 +1033,10 @@ def set_asr_openai_compat(body: _ASROpenAICompatBody):
from services import asr_backend, settings_store
if body.base_url is not None:
url = body.base_url.strip().rstrip("/")
if url and not url.startswith(("http://", "https://")):
raise HTTPException(status_code=400, detail="Base URL must start with http(s)://")
try:
url = asr_backend.normalize_openai_compat_asr_base_url(body.base_url)
except ValueError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc
settings_store.set_text(asr_backend._ASR_OPENAI_COMPAT_BASE_URL_KEY, url)
if body.model is not None:
settings_store.set_text(
+79 -8
View File
@@ -381,11 +381,60 @@ def _is_retryable_download_error(exc: BaseException) -> bool:
return is_hf_connectivity_error(str(exc))
def _segmented_retry_plan(
exc: BaseException, attempt: int, max_attempts: int
) -> tuple[bool, bool]:
"""What to do after the segmented accelerator failed on ``attempt``.
Returns ``(disable_accelerator, reraise)``.
A dropped connection is not the accelerator's fault, so the error is
re-raised for the outer retry: the next attempt re-enters
:func:`_segmented_snapshot`, which resumes from the ``.part`` manifest.
Falling straight through to ``snapshot_download`` instead would finish the
install from a separate ``.incomplete`` file and strand that manifest the
restart-from-zero this exists to prevent.
The final attempt is always reserved for the plain path, so the accelerator
can never be the reason an install fails outright. The two flags are
decoupled for that handover: the attempt that exhausts the accelerator still
re-raises, so the plain path starts on the LAST attempt rather than the
second-to-last. Disabling and falling through in the same attempt would
abandon the resumable manifest one attempt early and restart through a
separate file which is the failure this whole helper exists to avoid.
"""
if not _is_retryable_download_error(exc):
return True, False # the accelerator cannot work here at all
if attempt >= max_attempts:
# Nothing left to hand over to: take the plain path now rather than
# re-raising out of the loop with no fallback ever tried.
return True, False
return attempt >= max_attempts - 1, True
def _segmented_retry_note(disable: bool, reraise: bool) -> str:
"""How to describe the outcome of :func:`_segmented_retry_plan` in the log.
Three distinct states, and reading only ``disable`` conflates two of them:
the attempt that exhausts the accelerator is disabled AND re-raises, so the
fallback starts on the NEXT attempt, not this one.
"""
if not disable:
return "kept for the next attempt (resumes from its manifest)"
if reraise:
return "exhausted — retrying once more, then snapshot_download takes over"
return "disabled for this install — falling back to snapshot_download now"
@router.post("/models/install")
async def install_model(req: InstallModelRequest):
"""Download one HF repo snapshot; progress goes through the shared
``/setup/download-stream`` SSE feed."""
if req.repo_id not in [m["repo_id"] for m in KNOWN_MODELS]:
model_spec = next(
(model for model in KNOWN_MODELS if model["repo_id"] == req.repo_id),
None,
)
if model_spec is None:
raise HTTPException(
status_code=400,
detail=(
@@ -393,6 +442,7 @@ async def install_model(req: InstallModelRequest):
+ ", ".join(m["repo_id"] for m in KNOWN_MODELS)
),
)
allow_patterns = list(model_spec.get("allow_patterns") or []) or None
target = (req.target or "").strip()
if target != "local":
from services import gpu_gateway # noqa: PLC0415
@@ -450,6 +500,8 @@ async def install_model(req: InstallModelRequest):
"revision": revision_for(req.repo_id),
"max_workers": _download_max_workers(),
}
if allow_patterns:
dl_kwargs["allow_patterns"] = allow_patterns
_tqdm_cls = hf_progress.tracked_tqdm_class()
if _tqdm_cls is not None:
dl_kwargs["tqdm_class"] = _tqdm_cls
@@ -493,6 +545,8 @@ async def install_model(req: InstallModelRequest):
"revision": dl_kwargs["revision"],
"dry_run": True,
}
if allow_patterns:
_preflight_kwargs["allow_patterns"] = allow_patterns
if _endpoint:
_preflight_kwargs["endpoint"] = _endpoint
try:
@@ -548,6 +602,11 @@ async def install_model(req: InstallModelRequest):
_max_attempts = 5
_attempt = 0
# The accelerator is retried across attempts so its manifest-based
# resume actually gets used; it is disabled for the rest of the
# install only when it fails for a reason that is NOT transient
# network trouble (i.e. the accelerator itself is unusable here).
_segmented_off = False
while True:
if req.repo_id in _cancelled:
raise _InstallCancelled()
@@ -555,11 +614,17 @@ async def install_model(req: InstallModelRequest):
try:
# Segmented accelerator (FDL-09, default ON): parallel
# byte-range fetch with real live progress, for the
# legacy-LFS path. Any failure falls through to
# snapshot_download — the accelerator can never compromise a
# correct install.
# legacy-LFS path. A failure that is not transient network
# trouble falls through to snapshot_download, and so does the
# install's last attempt — the accelerator can never
# compromise a correct install (see _segmented_retry_plan).
_snapshot_path = None
if _attempt == 1 and _segmented_enabled() and not _xet_active():
if (
not _segmented_off
and not allow_patterns
and _segmented_enabled()
and not _xet_active()
):
try:
_snapshot_path = _segmented_snapshot(
req.repo_id,
@@ -569,10 +634,16 @@ async def install_model(req: InstallModelRequest):
except _InstallCancelled:
raise
except Exception as _seg_err:
logger.info(
"segmented download for %s failed (%s); falling back to snapshot_download",
req.repo_id, _seg_err,
_segmented_off, _seg_reraise = _segmented_retry_plan(
_seg_err, _attempt, _max_attempts
)
logger.info(
"segmented download for %s failed (%s); accelerator %s",
req.repo_id, _seg_err,
_segmented_retry_note(_segmented_off, _seg_reraise),
)
if _seg_reraise:
raise
_snapshot_path = None
if _snapshot_path is None:
_snapshot_path = snapshot_download(**dl_kwargs) # nosec B615 -- immutable revision_for pin
+8 -3
View File
@@ -19,6 +19,7 @@ import sys
from fastapi import APIRouter
from api.schemas import SetupStatusResponse, PreflightResponse
from core.device_caps import KERNEL_RISK_MARKER
# MIN_FREE_GB + disk_free_bytes are single-sourced in ``.models`` (the lowest
# module in the setup import graph) so the wizard gate, the /models header, and
# the per-install disk guard can't drift apart.
@@ -174,8 +175,8 @@ def _detect_gpu() -> dict:
return info
def _probe_network(host: str = "huggingface.co", port: int = 443, timeout: float = 2.0) -> bool:
"""Tiny TCP connect test."""
def _probe_network(host: str = "huggingface.co", port: int = 443, timeout: float = 8.0) -> bool:
"""Tiny TCP connect test. 8s default — high-latency / China paths often exceed 23s."""
import socket
try:
with socket.create_connection((host, port), timeout=timeout):
@@ -498,10 +499,14 @@ def preflight():
_why = gpu_routing.get("routing_reason")
if _rs == "accelerated" and not _why:
r_status, r_detail, r_fix = "pass", f"{_eng}{_dev} (accelerated)", None
elif _rs == "accelerated": # driver/arch caveat
elif _rs == "accelerated" and KERNEL_RISK_MARKER in (_why or ""):
r_status, r_detail, r_fix = "warn", f"{_eng}{_dev}: {_why}", (
"GPU selected but may fail at kernel launch — update drivers / "
"reinstall torch for this GPU architecture.")
elif _rs == "accelerated": # low-VRAM caveat — not a driver/arch issue
r_status, r_detail, r_fix = "warn", f"{_eng}{_dev}: {_why}", (
"Unload other models before generating, keep the text short, "
"or pick a lighter engine.")
elif _rs == "cpu_fallback":
r_status, r_detail, r_fix = "warn", (
f"{_eng} runs on CPU here: {_why or 'no GPU path for this host'}"), (
+252 -46
View File
@@ -203,8 +203,22 @@ def system_info():
"""
try:
_ffmpeg = find_ffmpeg()
from services import model_manager as _mm
from core import prefs as _prefs_mod
return {
"app_version": APP_VERSION,
"generate_timeout_s": _mm.GPU_JOB_TIMEOUT_S,
"cpu_generate_timeout_s": _mm.CPU_JOB_TIMEOUT_S,
# #1787 review fix: a saved prefs.json value for either key can be
# silently shadowed by an external env var (os.environ.setdefault
# in core.prefs.restore_env is a no-op when one is already
# present) — the Settings panel must say so rather than promise a
# restart will apply a value that never will.
"generate_timeout_shadowed": _prefs_mod.is_env_shadowed(
"OMNIVOICE_GENERATE_TIMEOUT_S"),
"cpu_generate_timeout_shadowed": _prefs_mod.is_env_shadowed(
"OMNIVOICE_CPU_GENERATE_TIMEOUT_S"),
"code_fingerprint": os.environ.get("OMNIVOICE_BUILD_FINGERPRINT", ""),
"data_dir": DATA_DIR,
"outputs_dir": OUTPUTS_DIR,
"crash_log_path": CRASH_LOG_PATH,
@@ -240,6 +254,11 @@ def system_info():
logger.exception("system_info failed — returning safe defaults")
return {
"app_version": APP_VERSION,
"generate_timeout_s": 300.0,
"cpu_generate_timeout_s": 600.0,
"generate_timeout_shadowed": False,
"cpu_generate_timeout_shadowed": False,
"code_fingerprint": os.environ.get("OMNIVOICE_BUILD_FINGERPRINT", ""),
"data_dir": DATA_DIR,
"outputs_dir": OUTPUTS_DIR,
"crash_log_path": str(CRASH_LOG_PATH),
@@ -278,6 +297,142 @@ def _tail_file(path: str, tail: int):
return all_lines[-tail:], len(all_lines)
# Must track main.py's _WindowsSafeRotatingFileHandler(backupCount=3). The
# handler rolls omnivoice.log at 2 MB into .1/.2/.3, so up to 6 MB of history
# lives in files this module used to ignore entirely.
_LOG_BACKUP_COUNT = 3
def _rotated_log_paths(base: str) -> list[str]:
"""Existing `<base>.1 … .N`, newest first."""
return [p for p in (f"{base}.{i}" for i in range(1, _LOG_BACKUP_COUNT + 1)) if os.path.exists(p)]
def _tail_rolling(base: str, tail: int):
"""Tail `base`, reaching into its rotated siblings when it runs short.
A rollover leaves omnivoice.log nearly empty, and the Backend tab then
showed a handful of lines or none while the failure the user was asked
to copy sat in omnivoice.log.1. Reading the current file first keeps the
common case at one file read; the backups are only touched when they are
the only place the requested lines can come from.
Returns (lines oldest-first, total lines across the files read, paths read
oldest-first). The total counts only the files it had to open it stops as
soon as `tail` is satisfied, so it is "how much is behind these lines",
not the size of the whole rotation set.
"""
chunks: list[list[str]] = []
paths: list[str] = []
total = 0
remaining = tail
candidates = [p for p in [base, *_rotated_log_paths(base)] if os.path.exists(p)]
for path in candidates:
if remaining <= 0:
break
try:
lines, count = _tail_file(path, remaining)
except FileNotFoundError:
# A rollover can rename a candidate between the existence check
# above and this open, and the handler holds no lock we can take
# from a route. Skip the vanished file rather than 500 the whole
# panel over one member of the set — the previous single-file
# version failed the request outright in the same situation.
#
# A roll landing mid-walk can also shift which chunk a file holds,
# so a tail taken at that instant may repeat or miss a block. The
# panel re-polls every 5s and the next read is clean; buying strict
# consistency here would mean reaching into logging's internals.
continue
except PermissionError as exc:
# Windows only, and only the sharing violation: the handler still
# holds the file it is rolling. Any other permission failure is a
# real misconfiguration and must not be hidden.
if os.name == "nt" and getattr(exc, "winerror", None) == 32:
continue
raise
if count == 0:
continue
chunks.append(lines)
paths.append(path)
total += count
remaining -= len(lines)
# Files were visited newest-first; the reader wants oldest-first.
out: list[str] = []
for chunk in reversed(chunks):
out.extend(chunk)
return out, total, list(reversed(paths))
def _tauri_plugin_log_candidates():
"""The `tauri-plugin-log` files — the shell's own log, and the only thing
the Tauri tab actually displays.
Split out from :func:`_tauri_log_candidates` so Clear can touch these and
leave the backend stdout/stderr redirect alone. See
:func:`clear_tauri_logs`.
"""
home = os.path.expanduser("~")
bid = "com.debpalash.omnivoice-studio"
if sys.platform == "darwin":
return [
os.path.join(home, "Library/Logs", bid, "tauri.log"),
os.path.join(home, "Library/Logs", bid, "VoiceStudio.log"),
]
if sys.platform.startswith("linux"):
data_dir = os.environ.get("XDG_DATA_HOME") or os.path.join(home, ".local/share")
return [
os.path.join(data_dir, bid, "logs", "tauri.log"),
os.path.join(home, ".config", bid, "logs", "tauri.log"),
]
if sys.platform.startswith("win"):
appdata = os.environ.get("APPDATA", home)
localappdata = os.environ.get("LOCALAPPDATA") or os.path.join(home, "AppData", "Local")
return [
os.path.join(localappdata, bid, "logs", "tauri.log"),
os.path.join(appdata, bid, "logs", "tauri.log"),
]
return []
def _backend_redirect_log_candidates():
"""`backend.log` / `backend_err.log` — the spawned backend's stdout and
stderr, written by `src-tauri/src/backend.rs::backend_log_path()`.
Deliberately NOT cleared by the Tauri tab's Clear button.
`open_err_log_for_run()` opens `backend_err.log` **append-only** so "a
respawn must not destroy the previous run's evidence" (#1510), rotates it
to `.1` rather than truncating, and its spawn diagnostics are described
there as "retained in backend_err.log across runs and lands verbatim in bug
reports". A native death (a Windows access violation, a SIGSEGV) writes
nothing to the Python log by construction, so this file is the only record
of it.
`OMNIVOICE_LOG_DIR` is honoured first, in the same precedence
`backend_log_path()` uses. The backend is a child of the shell, so an
ambient override reaches both and a resolver that ignored it would look
in the per-OS default while the writer wrote somewhere else, which is the
divergence class this file already has one of (see #1782).
"""
override = (os.environ.get("OMNIVOICE_LOG_DIR") or "").strip()
if override:
return [
os.path.join(override, "backend.log"),
os.path.join(override, "backend_err.log"),
]
home = os.path.expanduser("~")
if sys.platform == "darwin":
base = os.path.join(home, "Library/Logs/OmniVoice")
elif sys.platform.startswith("linux"):
state_dir = os.environ.get("XDG_STATE_HOME") or os.path.join(home, ".local/state")
base = os.path.join(state_dir, "OmniVoice")
elif sys.platform.startswith("win"):
localappdata = os.environ.get("LOCALAPPDATA") or os.path.join(home, "AppData", "Local")
base = os.path.join(localappdata, "OmniVoice", "Logs")
else:
return []
return [os.path.join(base, "backend.log"), os.path.join(base, "backend_err.log")]
def _tauri_log_candidates():
"""Likely paths for Tauri-side logs, most useful first.
@@ -289,40 +444,15 @@ def _tauri_log_candidates():
`com.debpalash.omnivoice-studio` (frontend/src-tauri/tauri.conf.json).
- backend.rs::backend_log_path() redirects the spawned backend's
stdout/stderr to `backend.log` / `backend_err.log` under
`~/Library/Logs/OmniVoice` (macOS), `$XDG_STATE_HOME/VoiceStudio` falling
`~/Library/Logs/OmniVoice` (macOS), `$XDG_STATE_HOME/OmniVoice` falling
back to `~/.local/state/OmniVoice` (Linux), and
`%LOCALAPPDATA%\\OmniVoice\\Logs` (Windows). This is where uvicorn
startup banners and hard-crash tracebacks land keep all three OS
shapes listed or sidecar crashes become invisible off-macOS.
"""
home = os.path.expanduser("~")
bid = "com.debpalash.omnivoice-studio"
if sys.platform == "darwin":
return [
os.path.join(home, "Library/Logs", bid, "tauri.log"),
os.path.join(home, "Library/Logs", bid, "VoiceStudio.log"),
os.path.join(home, "Library/Logs/OmniVoice/backend.log"),
os.path.join(home, "Library/Logs/OmniVoice/backend_err.log"),
]
if sys.platform.startswith("linux"):
data_dir = os.environ.get("XDG_DATA_HOME") or os.path.join(home, ".local/share")
state_dir = os.environ.get("XDG_STATE_HOME") or os.path.join(home, ".local/state")
return [
os.path.join(data_dir, bid, "logs", "tauri.log"),
os.path.join(home, ".config", bid, "logs", "tauri.log"),
os.path.join(state_dir, "OmniVoice", "backend.log"),
os.path.join(state_dir, "OmniVoice", "backend_err.log"),
]
if sys.platform.startswith("win"):
appdata = os.environ.get("APPDATA", home)
localappdata = os.environ.get("LOCALAPPDATA") or os.path.join(home, "AppData", "Local")
return [
os.path.join(localappdata, bid, "logs", "tauri.log"),
os.path.join(appdata, bid, "logs", "tauri.log"),
os.path.join(localappdata, "OmniVoice", "Logs", "backend.log"),
os.path.join(localappdata, "OmniVoice", "Logs", "backend_err.log"),
]
return []
# Composed from the two halves so the read path keeps seeing every file
# while Clear can be narrowed to the shell's own log.
return _tauri_plugin_log_candidates() + _backend_redirect_log_candidates()
@router.get("/system/logs")
@@ -337,12 +467,24 @@ async def system_logs(tail: int = 200):
except Exception:
tail = 200
path = LOG_PATH if os.path.exists(LOG_PATH) else CRASH_LOG_PATH
if not os.path.exists(path):
if os.path.exists(LOG_PATH) or _rotated_log_paths(LOG_PATH):
base = LOG_PATH
else:
base = CRASH_LOG_PATH
if not os.path.exists(base) and not _rotated_log_paths(base):
return {"lines": [], "path": LOG_PATH, "exists": False}
path = base
try:
lines, total = await asyncio.to_thread(_tail_file, path, tail)
return {"lines": lines, "path": path, "exists": True, "total_lines": total}
lines, total, paths = await asyncio.to_thread(_tail_rolling, base, tail)
return {
"lines": lines,
"path": path,
"exists": True,
"total_lines": total,
# Which files the tail actually came from, oldest first. A bug
# report can then say whether it crossed a rollover.
"paths": paths,
}
except Exception as e:
raise HTTPException(
status_code=500,
@@ -448,9 +590,23 @@ def _read_from_pos(path: str, pos: int) -> list[str]:
@router.post("/system/logs/clear")
async def clear_system_logs():
"""Truncate the rolling runtime log and the crash log (what the Backend tab reads)."""
"""Truncate the rolling runtime log and the crash log (what the Backend tab reads).
Includes the rotated siblings. Truncating only omnivoice.log left up to
6 MB in .1/.2/.3, so Clear freed almost nothing and now that the tail
reaches into those files would have looked like it did nothing at all.
"""
cleared_any = False
for p in (LOG_PATH, CRASH_LOG_PATH):
# The full fixed name set rather than a snapshot of what exists: enumerating
# first leaves a window where a rollover creates a backup after the scan and
# its history survives a Clear that reported success. Names the handler can
# ever write are known up front, so there is nothing to enumerate.
targets = [
LOG_PATH,
*(f"{LOG_PATH}.{i}" for i in range(1, _LOG_BACKUP_COUNT + 1)),
CRASH_LOG_PATH,
]
for p in targets:
if os.path.exists(p):
try:
await asyncio.to_thread(_truncate_file, p)
@@ -483,10 +639,20 @@ def _truncate_file(path: str):
@router.post("/system/logs/tauri/clear")
async def clear_tauri_logs():
"""Truncate whichever Tauri-side log files we know about. OS-level rotation may recreate them."""
"""Truncate the shell's own log files. OS-level rotation may recreate them.
The backend stdout/stderr redirect is deliberately excluded. This button
lives on a tab that shows `tauri.log`, and truncating `backend_err.log`
from it destroyed evidence the user was never shown the one record of a
native death, which writes nothing to the Python log. `backend.rs`'s
`open_err_log_for_run()` opens that file append-only precisely so "a
respawn must not destroy the previous run's evidence" (#1510) and rotates
it to `.1` instead of truncating, so it manages its own size and does not
need clearing from here.
"""
cleared = []
failed = 0
for p in _tauri_log_candidates():
for p in _tauri_plugin_log_candidates():
if os.path.exists(p):
try:
await asyncio.to_thread(_truncate_file, p)
@@ -848,6 +1014,14 @@ PERSISTENT_KEYS = {
# the Rust sidecar reads OMNIVOICE_PORT at startup and the backend derives
# the LAN-share/UI ports from the others.
"OMNIVOICE_PORT", "OMNIVOICE_SHARE_PORT", "OMNIVOICE_UI_PORT",
# Per-job compute-time budgets (#1787). Both are captured at import time
# by services/model_manager.py (GPU_JOB_TIMEOUT_S / CPU_JOB_TIMEOUT_S), so
# a value saved here takes effect on the NEXT backend restart — same
# contract as OMNIVOICE_PORT above. Restored into os.environ during the
# "env_prefs" startup step (main.py), which runs before model_manager is
# first imported ("ml_imports"), so the restored value is what the module
# captures. The Settings UI must say so (RestartBadge).
"OMNIVOICE_GENERATE_TIMEOUT_S", "OMNIVOICE_CPU_GENERATE_TIMEOUT_S",
}
# Sidecar-engine install dirs (OMNIVOICE_INDEXTTS_DIR, …). The one-click
@@ -865,6 +1039,16 @@ except Exception: # pragma: no cover — defensive: env panel > installer wirin
# being set so a bad value never reaches uvicorn / the share listener.
_PORT_KEYS = {"OMNIVOICE_PORT", "OMNIVOICE_SHARE_PORT", "OMNIVOICE_UI_PORT"}
# Keys whose value is a wall-clock compute-time budget in seconds (#1787).
# Validated the same way as _PORT_KEYS: reject anything that isn't a
# positive number before it reaches services/model_manager.py. Upper bound is
# generous — long enough that a legitimate multi-hour, audiobook-length CPU
# render is never blocked — but still bounded, so a fat-fingered extra digit
# (300 -> 3000000) can't turn a wedged job into one that silently occupies a
# worker for days before the guard ever fires.
_TIMEOUT_KEYS = {"OMNIVOICE_GENERATE_TIMEOUT_S", "OMNIVOICE_CPU_GENERATE_TIMEOUT_S"}
_MAX_GENERATE_TIMEOUT_S = 21600.0 # 6 hours
@router.post("/system/set-env")
async def set_env_var(body: dict):
@@ -873,7 +1057,7 @@ async def set_env_var(body: dict):
Persistent keys (proxy, FFMPEG_PATH, translation provider keys, ) are
saved to ``prefs.json`` so they survive backend restarts (restored at
startup in ``main.py``). HF_TOKEN is persisted via
``huggingface_hub.login()`` (and cleared via ``logout()``). Other keys
``huggingface_hub.login()`` (and cleared with the shared token-file helper). Other keys
are set on ``os.environ`` for the running process.
The loopback-origin gate that previously lived inline here is now applied
@@ -908,6 +1092,22 @@ async def set_env_var(body: dict):
status_code=400,
detail=f"Invalid port for {key}: must be between 1024 and 65535.",
)
if key in _TIMEOUT_KEYS:
try:
timeout_n = float(value)
except (TypeError, ValueError):
raise HTTPException(
status_code=400,
detail=f"Invalid timeout for {key}: '{value}' is not a number.",
)
if not (0 < timeout_n <= _MAX_GENERATE_TIMEOUT_S):
raise HTTPException(
status_code=400,
detail=(
f"Invalid timeout for {key}: must be greater than 0 "
f"and at most {_MAX_GENERATE_TIMEOUT_S:.0f} seconds."
),
)
os.environ[key] = value
logger.info("Environment variable set (length=%d)", len(value))
@@ -932,14 +1132,14 @@ async def set_env_var(body: dict):
# Mirror the persistence on clear — wipe the saved token file too.
if key == "HF_TOKEN":
try:
from huggingface_hub import logout as _hf_logout
_hf_logout()
logger.info("HF token cleared from $HF_HOME/token via logout()")
except Exception as e:
logger.warning("Could not clear HF token file: %s", e)
from services.token_resolver import clear_hf_cli_tokens
clear_hf_cli_tokens()
logger.info("Local Hugging Face token files cleared")
except Exception:
raise HTTPException(status_code=500, detail="Could not clear local Hugging Face token files") from None
# HF_TOKEN persistence is handled above via huggingface_hub.login()/
# logout() — it never touches prefs.json. Everything else in
# clear_hf_cli_tokens() — it never touches prefs.json. Everything else in
# PERSISTENT_KEYS (proxy, FFMPEG_PATH, translation provider keys, …) is
# saved to prefs.json so it survives backend restarts (restored at
# startup in main.py). Non-persistent keys stay process-local.
@@ -950,7 +1150,13 @@ async def set_env_var(body: dict):
else:
prefs_delete(prefs_key)
return {"key": key, "set": bool(value)}
# #1787 review fix: tell the caller up front when the value just saved is
# being shadowed by an external env var — set at THIS process's startup,
# before our own prefs restore ran, so it predicts the next restart too.
# A response that just said {"set": True} let the Settings panel promise
# a restart would apply a value that never will.
from core.prefs import is_env_shadowed
return {"key": key, "set": bool(value), "shadowed": is_env_shadowed(key)}
@router.post("/clean-audio")
@@ -1041,7 +1247,7 @@ def asr_backends():
def hf_token_state():
"""Return the 3-source HF token cascade state for the Settings UI
(Wave 2 React panel consumes this). Never returns the raw token
only a masked preview, whoami username, and per-source validity.
only a masked preview and local presence; no outbound validation.
"""
from dataclasses import asdict
from services import token_resolver
+7 -4
View File
@@ -174,11 +174,14 @@ async def ws_tts(websocket: WebSocket):
# close on `unavailable`, a one-time `routing` frame on
# cpu_fallback / accelerated-with-caveat (before any audio).
from core.device_caps import detect_host_caps
from services.engine_routing import resolve_routing, routing_notice
from services.engine_routing import (
routing_notice,
runtime_compute_profile_async,
)
from core.scrub import scrub_text
_routing = resolve_routing(
getattr(backend, "gpu_compat", ("cpu",)), detect_host_caps(),
getattr(backend, "min_vram_gb", 0.0))
_routing = await runtime_compute_profile_async(
backend, detect_host_caps()
)
if _routing["routing_status"] == "unavailable":
await websocket.send_json({
"type": "error",
+394
View File
@@ -0,0 +1,394 @@
"""Speech-to-speech voice changer — Studio's Convert method (POST /convert).
The user drops (or records) a source clip, picks an existing voice profile,
and gets the same words back in that profile's voice: the active ASR backend
transcribes the clip (no word timestamps the text is all we need), the
active TTS engine re-synthesizes it conditioned on the profile's reference
audio, and by default the take is pitch-preservingly time-stretched
(ffmpeg atempo, clamped to one well-behaved 0.52.0 stage) so it lands near
the source clip's duration.
Deliberately reuses the /generate choke points instead of re-deriving them:
* profile row conditioning via ``generation._resolve_profile_conditioning``
(lock wins, ``kind`` authoritative, #533 language fill),
* engine resolution via ``services.tts_backend.resolve_generation_backend``
(never a silent OmniVoice fallback; ``require_cloning=True`` refuses
clone-less engines with the actionable switch-engine message),
* synthesis via ``generation._run_backend_inference`` on the guarded GPU
pool (#730 bound + reset; busy/timeout → retryable 503),
* provenance + persistence via ``services.watermark.mark_synthetic_async``
and ``generation._finalize_generation`` (watermark WAV in OUTPUTS_DIR
history row retention prune), marked AFTER the stretch so the take users
keep carries exactly one whole-take mark.
Local-first: no network calls; ASR-model-less installs get the same typed
409 download CTA as /transcribe; a backend mid-shutdown surfaces the global
503 ``[shutting_down]`` (ModelLoadInterruptedByShutdown main.py handler).
Reachability matches /generate: loopback bind by default, with the shared
network-share PIN / API-key middleware gating any non-loopback exposure.
"""
from __future__ import annotations
import asyncio
import functools
import logging
import os
import tempfile
import time
from fastapi import APIRouter, File, Form, HTTPException, UploadFile
router = APIRouter()
logger = logging.getLogger("omnivoice.convert")
#: ffmpeg's atempo filter is well-behaved in [0.5, 2.0] per stage. Convert
#: clamps to ONE stage by design: needing more than 2× either way means the
#: synthesized speech differs so much from the source that "matching" it
#: would produce chipmunk/slow-motion artifacts worse than the mismatch.
ATEMPO_MIN = 0.5
ATEMPO_MAX = 2.0
#: Within this relative tolerance the durations already match — stretching
#: would resample the whole take for an inaudible gain.
_MATCH_TOLERANCE = 0.02
#: Convert clips are short conversational inputs, not long-form media. Stream
#: them to disk in bounded chunks so a network-share client cannot make the
#: backend materialize an arbitrarily large multipart upload in memory.
_MAX_SOURCE_AUDIO_BYTES = 64 * 1024 * 1024
_UPLOAD_CHUNK_BYTES = 1024 * 1024
async def _copy_source_upload(audio: UploadFile, destination) -> int:
"""Stream ``audio`` into ``destination`` with the Convert upload cap."""
total = 0
while True:
chunk = await audio.read(_UPLOAD_CHUNK_BYTES)
if not chunk:
return total
total += len(chunk)
if total > _MAX_SOURCE_AUDIO_BYTES:
raise HTTPException(
status_code=413,
detail="Source audio is too large (maximum 64 MB).",
)
destination.write(chunk)
def _clamped_tempo_ratio(tts_duration_s: float, source_duration_s: float) -> "float | None":
"""The atempo ratio that fits the take into the source duration, or None.
ratio > 1 speeds the take up (it came out longer than the source),
ratio < 1 slows it down. Clamped to a single atempo stage's [0.5, 2.0];
None when either duration is unusable or they already match.
"""
if not source_duration_s or source_duration_s <= 0:
return None
if not tts_duration_s or tts_duration_s <= 0:
return None
ratio = tts_duration_s / source_duration_s
if abs(ratio - 1.0) <= _MATCH_TOLERANCE:
return None
return min(ATEMPO_MAX, max(ATEMPO_MIN, ratio))
async def _match_source_duration(audio_tensor, sample_rate: int, source_duration_s: float):
"""Best-effort pitch-preserving stretch of the take toward the source
clip's duration. Returns the input unchanged when no stretch is needed
or ffmpeg fails a duration mismatch is better than a failed convert."""
n_samples = int(audio_tensor.shape[-1])
ratio = _clamped_tempo_ratio(n_samples / sample_rate, source_duration_s)
if ratio is None:
return audio_tensor
target_samples = max(1, int(round(n_samples / ratio)))
from services.ffmpeg_utils import _pitch_preserving_stretch
try:
return await _pitch_preserving_stretch(audio_tensor, target_samples, sample_rate)
except Exception as e: # noqa: BLE001 — stretch is opt-in polish, never fatal
logger.warning("duration match skipped — atempo stretch failed: %s", e)
return audio_tensor
async def _transcribe_source(tmp_path: str, *, source_lease=None) -> dict:
"""Active-ASR transcription of the uploaded clip (no word timestamps).
Mirrors POST /transcribe: typed 409 + download CTA before any backend
is constructed (never a silent multi-GB auto-download), the guarded GPU
pool dispatch (#730), 504 on timeout, and the same 409 when the loader
degrades onto an engine with no weights on disk (#1185).
"""
from services.asr_backend import (
ASRModelMissingError,
ASRTimeoutError,
asr_model_missing_detail,
asr_model_missing_error,
run_transcribe_guarded,
)
missing = await asyncio.to_thread(asr_model_missing_error, purpose="transcribe")
if missing is not None:
raise HTTPException(
status_code=409,
detail={**missing, "message": asr_model_missing_detail(missing)},
)
def _run():
# `load_*`, not `get_*`: the loader runs ensure_loaded() and degrades
# past an engine whose deep import chain is broken (#1185).
from services.asr_backend import load_active_asr_backend
backend = load_active_asr_backend()
return backend.transcribe(tmp_path, word_timestamps=False)
from services.model_manager import _gpu_pool
release = source_lease.acquire() if source_lease is not None else None
abandoned = False
try:
return await run_transcribe_guarded(
_gpu_pool,
_run,
what="Voice convert",
on_abandon=release,
)
except asyncio.CancelledError:
# The guard now owns the lease token until the native worker drains.
abandoned = True
raise
except ASRTimeoutError as e:
abandoned = True
logger.warning("Convert transcription timed out: %s", e)
raise HTTPException(status_code=504, detail=str(e))
except ASRModelMissingError as e:
raise HTTPException(
status_code=409,
detail={**e.payload, "message": asr_model_missing_detail(e.payload)},
)
finally:
if release is not None and not abandoned:
release()
@router.post("/convert")
async def convert_speech(
audio: UploadFile = File(...),
profile_id: str = Form(...),
match_duration: bool = Form(True),
):
"""Convert a spoken clip into an existing voice profile's voice.
Multipart form: ``audio`` (the source clip), ``profile_id`` (an existing
voice profile), optional ``match_duration`` (default on atempo the take
toward the source clip's length, clamped to 0.52.0×).
Returns JSON ``{audio_url, text, duration_s, id}`` the take is saved to
OUTPUTS_DIR and served from the ``/audio`` mount like every other take.
"""
from core.db import db_conn
from api.routers.generation import _resolve_profile_conditioning, _TempReferenceLease
# ── Profile first: strict 404, unlike /generate's silent skip — Convert
# has no meaning without a target voice.
with db_conn() as conn:
row = conn.execute(
"SELECT * FROM voice_profiles WHERE id=?", (profile_id,)
).fetchone()
if not row:
raise HTTPException(
status_code=404,
detail="That voice profile doesn't exist. It may have been deleted from another tab.",
)
cond = _resolve_profile_conditioning(row)
# ── Save the upload before loading an engine. Every ASR backend (and
# ffprobe) needs a file path; the bounded streaming copy rejects oversized
# network-share requests without materializing them in process memory or
# starting heavyweight model work.
ext = os.path.splitext(audio.filename or "audio.wav")[1] or ".wav"
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=ext)
source_lease = None
try:
try:
await _copy_source_upload(audio, tmp)
finally:
tmp.close()
source_lease = _TempReferenceLease(tmp.name)
# ── Engine gate before ASR/TTS work: the shared resolver refuses a
# clone-less engine with the actionable switch-engine message (→ 400),
# and a backend mid-shutdown raises ModelLoadInterruptedByShutdown out
# of the model load → the global 503 [shutting_down] handler.
from services.tts_backend import resolve_generation_backend
try:
backend = await resolve_generation_backend(
require_cloning=True, cloning_purpose="voice conversion",
)
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
result = await _transcribe_source(tmp.name, source_lease=source_lease)
segments = result.get("segments", [])
text = result.get("text", "")
if not text and segments:
text = " ".join(s.get("text", "") for s in segments).strip()
# Same final-text hygiene as /transcribe: strip Whisper hallucination
# loops, then deterministic polish (leading capital + terminal
# punctuation) so the TTS input reads as typed text.
from services.refinement import collapse_repetitive_artifacts
from services.text_polish import polish_text
text = polish_text(collapse_repetitive_artifacts(text))
if not text or not text.strip():
raise HTTPException(
status_code=422,
detail=(
"No speech was recognized in the source clip, so there is "
"nothing to convert. Record or drop a clip with clear, "
"audible speech and try again."
),
)
# #308/#1032 parity with /generate: a clone profile saved without a
# transcript conditions better when its reference clip is transcribed,
# and that transcript is cached onto the row so it happens ONCE, not
# per convert. Best-effort exactly like /generate — a timeout/failure
# degrades to ref_text=None and the engine's own fallback. The ASR
# model is already warm here (the source transcribe above just used it).
if cond["ref_audio_path"] and not cond["ref_text"]:
from api.routers.generation import (
_generate_timeout_s,
_persist_profile_ref_text,
)
from services.asr_backend import transcribe_reference
from services.model_manager import run_on_gpu_pool_guarded
try:
cond["ref_text"] = await run_on_gpu_pool_guarded(
functools.partial(transcribe_reference, cond["ref_audio_path"]),
what="Reference transcribe",
timeout=_generate_timeout_s(""),
)
except TimeoutError as e:
logger.warning(
"reference transcribe hung (%s); using engine ASR fallback", e,
)
cond["ref_text"] = None
if cond["ref_text"] and cond["persist_ref_text"]:
_persist_profile_ref_text(profile_id, cond["ref_text"])
# Source duration for the optional match: the container's own length
# (ffprobe), falling back to the last ASR segment end. Best-effort —
# None just skips the stretch.
source_duration_s = None
if match_duration:
from services.ffmpeg_utils import probe_duration
source_duration_s = await probe_duration(
tmp.name, allowed_root=os.path.dirname(tmp.name),
)
if not source_duration_s and segments:
source_duration_s = max((s.get("end", 0) or 0) for s in segments) or None
# ── Same text choke point as /generate: engine-agnostic normalization
# (numbers→words, junk strip) on the fully resolved language.
from services.text_normalization import normalize_for_tts
language = cond["language"]
text = normalize_for_tts(text, language)
used_seed = cond["seed"]
if used_seed is None:
import random
used_seed = random.randint(0, 2**31 - 1)
from api.routers.generation import (
_finalize_generation,
_generate_timeout_s,
_run_backend_inference,
)
from services.model_manager import (
GpuJobTimeoutError,
GpuPoolBusyError,
run_on_gpu_pool_guarded,
)
from core.device_caps import detect_host_caps
from services.engine_routing import runtime_compute_profile_async
compute_profile = await runtime_compute_profile_async(
backend, detect_host_caps()
)
if compute_profile["routing_status"] == "unavailable":
raise HTTPException(
status_code=400,
detail=compute_profile["routing_reason"],
)
start_time = time.time()
_render = functools.partial(
_run_backend_inference,
backend, text, language, cond["ref_audio_path"], cond["ref_text"],
cond["instruct"],
None, # duration — the model picks; match_duration owns pacing
16, 2.0, # num_step / guidance_scale (the /generate defaults)
1.0, # speed
True, True, # denoise / postprocess_output
used_seed,
)
try:
audio_tensor = await run_on_gpu_pool_guarded(
_render,
what="Voice convert",
timeout=_generate_timeout_s(
text,
execution_device=compute_profile["effective_device"],
min_vram_gb=compute_profile["min_vram_gb"],
hardware_family=compute_profile.get("runtime_hardware_family"),
vram_gb=compute_profile.get("runtime_vram_gb"),
),
min_vram_gb=compute_profile["min_vram_gb"],
)
except GpuPoolBusyError as e:
raise HTTPException(
status_code=503, detail=str(e),
headers={"Retry-After": str(e.retry_after),
"X-OmniVoice-Retryable": "true"},
) from e
except GpuJobTimeoutError as e:
raise HTTPException(
status_code=503, detail=str(e),
headers={"Retry-After": "30", "X-OmniVoice-Retryable": "true"},
) from e
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e)) from e
sample_rate = backend.sample_rate
if match_duration and source_duration_s:
audio_tensor = await _match_source_duration(
audio_tensor, sample_rate, source_duration_s,
)
# Provenance mark AFTER the stretch (one whole-take mark on the audio
# the user actually keeps), then the shared finalize tail — WAV in
# OUTPUTS_DIR, self-healing history row, retention prune, event emit.
from services.watermark import mark_synthetic_async
audio_tensor = await mark_synthetic_async(
audio_tensor, sample_rate, context="convert.finalize",
)
_, meta = await _finalize_generation(
audio_tensor, sample_rate, text=text, history_mode="convert",
ref_audio_path=cond["ref_audio_path"], language=language,
instruct=cond["instruct"], resolved_profile_id=profile_id,
used_seed=used_seed, start_time=start_time,
already_marked=True,
)
return {
"id": meta["id"],
"audio_url": f"/audio/{meta['filename']}",
"text": text,
"duration_s": meta["duration"],
"gen_time_s": meta["gen_time"],
}
finally:
if source_lease is not None:
source_lease.finish_request()
else:
try:
os.unlink(tmp.name)
except OSError:
pass
+15
View File
@@ -26,6 +26,21 @@ class SystemInfoResponse(BaseModel):
model_config = ConfigDict(extra="allow")
app_version: str = ""
# Effective compute-time budgets (seconds) for one synthesis job — the
# values services/model_manager.py's GPU_JOB_TIMEOUT_S / CPU_JOB_TIMEOUT_S
# captured at backend import time (#1787). A value just saved via
# /system/set-env is NOT reflected here until the next restart.
generate_timeout_s: float = 300.0
cpu_generate_timeout_s: float = 600.0
# True when an external env var (shell, `.env`, Docker, …) is currently
# shadowing a prefs.json save for this key — see core.prefs.is_env_shadowed.
generate_timeout_shadowed: bool = False
cpu_generate_timeout_shadowed: bool = False
# #1770: the desktop attach handshake's code fingerprint — whatever
# Tauri set OMNIVOICE_BUILD_FINGERPRINT to when it spawned this process,
# echoed back verbatim. Blank when unset (dev mode, a manually started
# backend). See frontend/src-tauri/src/backend.rs::code_fingerprint_is_current.
code_fingerprint: str = ""
data_dir: str
outputs_dir: str
crash_log_path: str
+11
View File
@@ -28,6 +28,9 @@
# their own (weights live in referenced sub-repos). Such
# a cache is legitimately tiny, so the truncated-download
# (weights-missing) detector must NOT flag it incomplete.
# allow_patterns (optional) — restrict installation to these repository paths.
# Use for multi-package repos so an explicit install
# never downloads unrelated model variants.
# ─────────────────────────────────────────────────────────────────────────
models:
@@ -40,6 +43,14 @@ models:
required: true
curated_on: [all]
- repo_id: "audio-cpp/audio.cpp-gguf"
label: "Breeze-TTS-2 Q8_0 for audio.cpp (English + Chinese, clone + design)"
role: TTS
size_gb: 4.73
allow_patterns:
- "Breeze-TTS-2-GGUF/breeze-tts-2-q8_0.gguf"
note: "Optional audio.cpp model. Research/non-commercial weights and self-hosted outputs; install only after reviewing the license."
# ── ASR (optional — curated per platform) ─────────────────────────────
# No ASR model is required to boot: TTS-only installs work. Dubbing,
# dictation, and clone-reference transcription prompt for the curated
+20
View File
@@ -15,6 +15,18 @@ def get_app_data_dir():
return os.path.expanduser("~/.omnivoice")
def _configured_hf_token_path():
"""Match Hub's token location without importing or refreshing credentials."""
default_cache = os.path.join(os.path.expanduser("~"), ".cache")
hf_home = os.environ.get("HF_HOME", os.path.join(os.environ.get("XDG_CACHE_HOME", default_cache), "huggingface"))
return os.path.expandvars(os.path.expanduser(os.environ.get("HF_TOKEN_PATH", os.path.join(hf_home, "token"))))
# Snapshot recognized locations before automatic model-cache redirection.
# Explicit cache/token overrides restrict clearing to their selected location.
HF_CLI_TOKEN_PATHS = (_configured_hf_token_path(),)
def _ensure_short_hf_cache_on_windows():
"""Redirect HuggingFace cache to a short path on Windows.
@@ -38,6 +50,14 @@ def _ensure_short_hf_cache_on_windows():
return
short_cache = os.path.join(local_app, "OmniVoice", "hf_cache")
os.makedirs(short_cache, exist_ok=True)
if "HF_TOKEN_PATH" not in os.environ:
global HF_CLI_TOKEN_PATHS
canonical = HF_CLI_TOKEN_PATHS[0]
legacy = os.path.join(short_cache, "token")
HF_CLI_TOKEN_PATHS = tuple(dict.fromkeys((canonical, legacy)))
# Keep existing app-written logins usable without copying credentials.
selected = canonical if os.path.exists(canonical) or not os.path.exists(legacy) else legacy
os.environ.setdefault("HF_TOKEN_PATH", selected)
os.environ["HF_HOME"] = short_cache
os.environ["HF_HUB_CACHE"] = short_cache
+141 -34
View File
@@ -3,13 +3,14 @@
The desktop owns the backend with an OS process group/Job. Engine and
installer operations also need an independently terminable subtree: killing
only their direct child on a timeout leaves uv/git/model workers holding pipes
and mutating files. A small direct-child supervisor bridges both lifetimes.
and mutating files.
On POSIX the supervisor is the unreaped leader of a nested process group. A
control-pipe EOF (including kernel EOF when the backend dies) kills that group;
the parent also drains the group before reaping its stable leader. On Windows
the supervisor assigns the operation, while suspended, to a nested
kill-on-close Job. The outer desktop Job still contains both levels.
On POSIX a small supervisor is the unreaped leader of a nested process group.
A control-pipe EOF (including kernel EOF when the backend dies) kills that
group; the parent also drains the group before reaping its stable leader. On
Windows the backend retains a nested kill-on-close Job directly and assigns
the suspended operation before resuming it. The outer desktop Job remains the
terminal fallback.
Standalone/server launches use the same nested owner, preserving their
independently terminable subtree without relying on ``taskkill`` or discovery.
@@ -263,42 +264,148 @@ class OwnedPopen:
pass
def spawn_owned(argv: list[str], **kwargs: Any) -> "subprocess.Popen | OwnedPopen":
class WindowsJobPopen:
"""Popen-compatible handle whose child tree lives in a retained Job.
Windows Job handles already provide the stable ownership that POSIX needs
a supervisor process group for. Keeping the handle in the backend means an
abrupt backend exit closes it in the kernel and kills the whole operation
tree, without inserting a second Python process in the sidecar loader path
(#1734).
"""
def __init__(self, proc: subprocess.Popen, job: Any, kernel32: Any) -> None:
self._proc = proc
self._job = job
self._kernel32 = kernel32
self._lock = threading.RLock()
self.stdin = proc.stdin
self.stdout = proc.stdout
self.stderr = proc.stderr
@property
def pid(self) -> int:
return self._proc.pid
@property
def args(self) -> Any:
return self._proc.args
@property
def returncode(self) -> Optional[int]:
return self._proc.returncode
def _close_job(self, *, terminate: bool) -> None:
job, self._job = self._job, None
if job is None:
return
try:
if terminate:
self._kernel32.TerminateJobObject(job, 1)
finally:
self._kernel32.CloseHandle(job)
def poll(self) -> Optional[int]:
with self._lock:
rc = self._proc.poll()
if rc is None:
return None
# A successful direct child may leave helpers behind. Match the
# supervisor contract by draining the retained Job before return.
self._close_job(terminate=True)
return rc
def wait(self, timeout: Optional[float] = None) -> int:
try:
rc = self._proc.wait(timeout=timeout)
except subprocess.TimeoutExpired:
raise
with self._lock:
self._close_job(terminate=True)
return rc
def terminate(self) -> None:
with self._lock:
self._close_job(terminate=True)
def kill(self) -> None:
self.terminate()
def __getattr__(self, name: str) -> Any:
return getattr(self._proc, name)
def __del__(self) -> None:
try:
self._close_job(terminate=True)
except Exception:
pass # interpreter shutdown; closing the OS handle is best-effort
def _spawn_windows_owned(argv: list[str], kwargs: dict[str, Any]) -> WindowsJobPopen:
"""Start *argv* suspended, assign its tree to a Job, then resume it."""
import ctypes
job, kernel32, wintypes = _windows_job()
child: Optional[subprocess.Popen] = None
popen_kwargs = dict(kwargs)
supplied_env = popen_kwargs.get("env")
operation_env = dict(os.environ if supplied_env is None else supplied_env)
operation_env.pop(_DRAIN_FD_ENV, None)
operation_env.pop(_DESKTOP_MARKER, None)
popen_kwargs["env"] = operation_env
supplied_flags = int(popen_kwargs.pop("creationflags", 0))
popen_kwargs["creationflags"] = supplied_flags | 0x08000000 | 0x00000004
try:
child = subprocess.Popen(argv, **popen_kwargs)
assign = kernel32.AssignProcessToJobObject
assign.argtypes = (wintypes.HANDLE, wintypes.HANDLE)
assign.restype = wintypes.BOOL
if not assign(job, wintypes.HANDLE(child._handle)):
raise OSError(ctypes.get_last_error(), "AssignProcessToJobObject")
_resume_windows_process(kernel32, wintypes, child.pid)
return WindowsJobPopen(child, job, kernel32)
except BaseException:
kernel32.TerminateJobObject(job, 1)
if child is not None:
try:
child.kill()
except OSError:
pass # the suspended child may already have exited
try:
child.wait(timeout=5)
except (OSError, subprocess.TimeoutExpired):
pass # Job termination remains the authoritative cleanup
kernel32.CloseHandle(job)
raise
def spawn_owned(
argv: list[str], **kwargs: Any
) -> "subprocess.Popen | OwnedPopen | WindowsJobPopen":
"""Spawn an operation with a stable, independently terminable owner."""
drain_fd = backend_drain_fd(required=True) if os.name == "posix" else None
if os.name == "nt":
return _spawn_windows_owned(argv, kwargs)
drain_fd = backend_drain_fd(required=True)
control_read, control_write = os.pipe()
result_read, result_write = os.pipe()
control_token = control_read
result_token = result_write
if os.name == "nt":
import msvcrt
control_token = msvcrt.get_osfhandle(control_read)
result_token = msvcrt.get_osfhandle(result_write)
wrapper_argv = _supervisor_argv(
control_token,
result_token,
control_read,
result_write,
argv,
)
wrapper_kwargs = dict(kwargs)
if os.name == "posix":
wrapper_kwargs["start_new_session"] = True
pass_fds = [control_read, result_write]
if drain_fd is not None:
pass_fds.append(drain_fd)
if wrapper_kwargs.get("env") is not None:
wrapper_env = dict(wrapper_kwargs["env"])
wrapper_env[_DESKTOP_MARKER] = "1"
wrapper_env[_DRAIN_FD_ENV] = str(drain_fd)
wrapper_kwargs["env"] = wrapper_env
wrapper_kwargs["pass_fds"] = tuple(pass_fds)
else:
# Python's Windows fd inheritance requires inheritable CRT handles.
# All unrelated descriptors are non-inheritable by default (PEP 446).
os.set_handle_inheritable(control_token, True)
os.set_handle_inheritable(result_token, True)
wrapper_kwargs["close_fds"] = False
wrapper_kwargs["start_new_session"] = True
pass_fds = [control_read, result_write]
if drain_fd is not None:
pass_fds.append(drain_fd)
if wrapper_kwargs.get("env") is not None:
wrapper_env = dict(wrapper_kwargs["env"])
wrapper_env[_DESKTOP_MARKER] = "1"
wrapper_env[_DRAIN_FD_ENV] = str(drain_fd)
wrapper_kwargs["env"] = wrapper_env
wrapper_kwargs["pass_fds"] = tuple(pass_fds)
try:
proc = subprocess.Popen(wrapper_argv, **wrapper_kwargs)
except BaseException:
+2 -1
View File
@@ -274,7 +274,8 @@ _BASE_SCHEMA = """
started_at REAL,
finished_at REAL,
lease_expires_at REAL,
grace_expires_at REAL
grace_expires_at REAL,
deadlines_json TEXT
);
CREATE INDEX IF NOT EXISTS idx_remote_attempts_task ON remote_task_attempts(task_id);
CREATE INDEX IF NOT EXISTS idx_remote_attempts_worker ON remote_task_attempts(worker_id, state);
+25 -4
View File
@@ -35,7 +35,8 @@ import sys
from dataclasses import dataclass
from typing import Literal
DeviceFamily = Literal["cuda", "rocm", "mps", "xpu", "cpu"]
DeviceFamily = Literal["cuda", "rocm", "mps", "xpu", "npu", "cpu"]
ACCELERATOR_PRIORITY = ("cuda", "rocm", "xpu", "npu", "mps")
# Stable substring stamped onto notes that represent a real kernel-launch risk
# (arch/driver mismatch) — as opposed to advisory notes (multi-GPU, VRAM query
@@ -533,9 +534,13 @@ def _probe() -> HostCaps:
# is the whole truth in that case (CodeRabbit, #1425).
notes.extend(why_no_gpu(torch))
# ── Intel XPU via IPEX ───────────────────────────────────────────────
# Older builds register XPU through IPEX; modern torch exposes it directly.
try:
import intel_extension_for_pytorch # noqa: F401
except Exception:
# Optional IPEX may be absent or incompatible; still probe native torch XPU.
pass
try:
if hasattr(torch, "xpu") and torch.xpu.is_available():
detected.append("xpu")
if not device_name:
@@ -546,7 +551,23 @@ def _probe() -> HostCaps:
pass
notes.append("XPU VRAM not queried (unreliable across IPEX versions)")
except Exception:
# IPEX absent or XPU probe failed — no XPU on this host.
# XPU probe failed — no usable XPU on this host.
pass
# Vendor extensions may register an NPU with torch. Probe only an already
# registered backend; never install or import an optional vendor package.
try:
if hasattr(torch, "npu") and torch.npu.is_available():
detected.append("npu")
if not device_name:
try:
device_name = torch.npu.get_device_name(0)
except Exception:
# An unavailable display name does not invalidate a usable NPU.
pass
notes.append("NPU VRAM not queried")
except Exception:
# Missing or broken vendor backends mean no usable NPU; continue probing.
pass
# ── Apple Silicon MPS ────────────────────────────────────────────────
@@ -579,7 +600,7 @@ def _probe() -> HostCaps:
# Preferred family by priority; cpu when nothing accelerated was detected.
family: DeviceFamily = "cpu"
for pref in ("cuda", "rocm", "xpu", "mps"):
for pref in ACCELERATOR_PRIORITY:
if pref in detected:
family = pref # type: ignore[assignment]
break
+14 -3
View File
@@ -28,6 +28,7 @@ import shutil
import sys
from core.config import DATA_DIR
from core.device_caps import KERNEL_RISK_MARKER
from core.scrub import scrub_text
from core.version import APP_VERSION
@@ -189,7 +190,7 @@ def _check_ram() -> dict:
def _check_engines() -> dict:
try:
from services.tts_backend import list_backends, active_backend_id
backends = list_backends()
backends = list_backends(include_hidden=True)
active = active_backend_id()
except Exception as e:
return _check("engines", "TTS engines", WARN, f"could not enumerate: {e}")
@@ -230,11 +231,16 @@ def _check_gpu_routing() -> dict:
host = v.get("host_family", "cpu")
if status == "accelerated":
if reason: # driver/arch caveat — accelerated but at risk
if reason and KERNEL_RISK_MARKER in reason: # driver/arch caveat — at risk
return _check("gpu_routing", "GPU routing", WARN,
f"{engine} -> {dev}: {reason}",
"The GPU is selected but may fail at kernel launch — "
"update drivers / reinstall torch for this GPU arch.")
if reason: # low-VRAM caveat — not a driver/arch issue
return _check("gpu_routing", "GPU routing", WARN,
f"{engine} -> {dev}: {reason}",
"Unload other models before generating, keep the text "
"short, or pick a lighter engine.")
return _check("gpu_routing", "GPU routing", OK, f"{engine} -> {dev} (accelerated)")
if status == "cpu_fallback":
return _check("gpu_routing", "GPU routing", WARN,
@@ -374,7 +380,12 @@ def run_diagnostics(include_network: bool = True, deep: bool = False) -> dict:
try:
module = importlib.import_module(f"services.{family}_backend")
active = module.active_backend_id()
row = next((item for item in module.list_backends() if item.get("id") == active), None)
rows = (
module.list_backends(include_hidden=True)
if family == "tts"
else module.list_backends()
)
row = next((item for item in rows if item.get("id") == active), None)
if row is not None:
engine_execution.append({
"family": family,
+48
View File
@@ -97,6 +97,9 @@ _HINTS: dict[str, str] = {
"TRANSFORMERS_IMPORT": "Your transformers install is incomplete, or a package it loads models through (torchaudio, torchvision) is missing or mismatched with your torch — a torch/torchvision version mismatch fails with exactly this wording. Reinstall them together at the pinned versions (`uv pip install --python .venv --reinstall torch==2.8.0 torchaudio==2.8.0 torchvision==0.23.0 transformers` in the project folder), then restart the backend. If only transcription is affected, switching ASR to faster-whisper (Model Catalogue → Models) also works around it.",
"WINDOWS_APP_CONTROL_BLOCKED": "Windows refused to load a file VoiceStudio needs — an Application Control policy (Smart App Control, WDAC, or AppLocker) blocked it. On a personal PC: Windows Security → App & browser control → Smart App Control → Off (Windows only lets you turn it off once — re-enabling requires a Windows reset), then restart VoiceStudio. On a managed/work PC, ask IT to allow the VoiceStudio install folder.",
"WINDOWS_PAGING_FILE_TOO_SMALL": "Windows ran out of virtual memory while mapping the model into memory — its paging file is smaller than the model needs. This is not the same as your RAM being full, and closing other apps usually won't fix it: Windows has to be allowed to back the mapping. Set a bigger paging file — Settings → System → About → Advanced system settings → Performance → Settings → Advanced → Virtual memory → Change: untick \"Automatically manage\", pick your system drive, choose \"Custom size\" and set both Initial and Maximum to at least 32768 MB (more than the model's size), then OK and restart Windows. A smaller/quantized engine (OmniVoice GGUF, Supertonic-3) also avoids the large mapping entirely.",
"WINDOWS_UNTRUSTED_MOUNT": "Windows refused to walk a folder on the way to this file because the path crosses a mount point it does not trust (WinError 448). That is a Windows rule about the VOLUME, not about VoiceStudio or the file itself — it turns up on Dev Drives, on mounted VHD/ReFS volumes, and on junctions pointing into another user profile, so retrying the same link cannot help. Point VoiceStudio at a folder on an ordinary local drive instead: Settings → Storage → data directory, or the download/output folder named in the message. If that folder has to stay where it is, trust the volume with `fsutil devdrv trust <drive>:` from an elevated prompt and restart.",
"INPUT_TOO_SHORT": "The input was too short for this engine to process — its first convolution needs more frames than the text (or the reference clip) produced. This is a hard limit of the model, not a transient failure, so retrying the same input will fail the same way. Give it a few more words, or a longer reference clip: a short phrase rather than one or two characters, and about a second of speech rather than a fragment.",
"CLONE_REFERENCE_MISSING": "This engine was asked to clone a voice but got no reference audio to clone FROM, and the model folder carries no built-in voice either. Pick a voice profile that has a saved reference clip, or record/upload a few seconds of clean speech as the reference, then generate again. A designed voice with no saved reference cannot be cloned from — synthesize with it directly instead.",
"MEDIA_TOOL_MISSING": "VoiceStudio's media engine (ffmpeg/ffprobe) wasn't on the system path when a component went looking for it. Open Settings → Audio tools and use Download/Repair to fetch the bundled copy, then retry — a restart picks it up for everything. If you'd rather use a system install, install ffmpeg (macOS: `brew install ffmpeg`; Windows: `winget install Gyan.FFmpeg`; Linux: your package manager) and restart VoiceStudio, or point FFMPEG_PATH / OMNIVOICE_FFPROBE_PATH at the binaries in Settings.",
"AUDIO_IO_FAILED": "An audio file couldn't be read or written at the OS level. Check the drive isn't full, that the output and temp folders exist and are writable, and that antivirus or OneDrive isn't locking them (add a VoiceStudio exclusion if you use one).",
"VIDEO_DOWNLOAD_OS_ERROR": "The OS refused a file operation while saving the downloaded video — this is a disk/folder problem, not a network one, so retrying the same link won't help. The download is written to a job folder under your VoiceStudio data directory (Settings → Storage shows the path): check that drive isn't full, that the folder exists and is writable, and that antivirus or a cloud-sync client (OneDrive, Dropbox) isn't locking it — add a VoiceStudio exclusion if you use one. If your data directory sits on a synced or network drive, move it to a local one.",
@@ -308,6 +311,23 @@ _CONTEXT_FREE_HINT_CLASSES = frozenset({
# a Windows virtual-memory setting rather than a connectivity problem, and
# the detailed hint we already had for it never reached them.
"WINDOWS_PAGING_FILE_TOO_SMALL",
# #1957: triggered by WinError 448 or the literal "untrusted mount
# point" — both unmistakable, and it reaches the user as a bare
# download failure with only the OS sentence attached.
"WINDOWS_UNTRUSTED_MOUNT",
# #1826: torch's own conv wording, which nothing else produces, and it
# reaches the user through the generic 500.
"INPUT_TOO_SHORT",
# #1879: matched on wording no other failure produces, and it reaches the
# user as a bare 400 carrying only the library sentence.
"CLONE_REFERENCE_MISSING",
# Its trigger is a VoiceStudio-authored sentence — "the TTS model cache
# for … is incomplete" plus "could not be auto-repaired" / "weights
# missing" — so it cannot be produced by an unrelated library. The 500
# handler is the surface a corrupt cache actually reaches, and dropping
# its hint there would leave the user with no way to know a redownload
# is the fix.
"MODEL_CACHE_CORRUPT",
})
@@ -569,6 +589,34 @@ def classify(reason: str) -> str:
or "application control policy" in low
):
return "WINDOWS_APP_CONTROL_BLOCKED"
# #1957: the path to a download or output file crosses a mount point
# Windows will not traverse (Dev Drive, mounted VHD/ReFS, a junction into
# another profile). Matched on the numeric code first because the OS
# translates the sentence, with the English phrase as a fallback.
if "[winerror 448]" in low or "untrusted mount point" in low:
return "WINDOWS_UNTRUSTED_MOUNT"
# #1826: a degenerate-length input reaches a conv layer whose kernel is
# wider than the tensor, and torch says so in its own terms — "Calculated
# padded input size per channel: (1). Kernel size: (2). Kernel size can't
# be greater than actual input size". That arrived doubly wrapped in
# "Underlying error:" and told the user nothing they could act on, when
# the fix is simply "type more than one character".
if "kernel size can't be greater than actual input size" in low or (
"calculated padded input size per channel" in low
):
return "INPUT_TOO_SHORT"
# #1879: mlx-audio (and the Chatterbox-family models under it) raise a
# bare ValueError naming their own parameters — "No conditionals
# available. Either provide audio_prompt/audio_prompt_sr ... or ensure
# conds.safetensors is in the model directory." The generate route passed
# that straight through as the 400 detail, so the user was told to supply
# an argument they have no way to name and to check for a file they have
# never heard of. What actually happened is "you asked to clone without a
# reference clip".
if "no conditionals available" in low or (
"audio_prompt" in low and "conds.safetensors" in low
):
return "CLONE_REFERENCE_MISSING"
# #1221: libsndfile failed an OS-level audio read/write. Its own wording is
# a bare "System error.", so match the library name — audio_io already
# prefixes the target path and free space onto the write-path failures.
+77 -3
View File
@@ -4,7 +4,14 @@ from __future__ import annotations
import os
import sys
import threading
from typing import BinaryIO, Callable
import time
from typing import Any, BinaryIO, Callable, Optional
# Poll cadence for the Windows pipe watcher. Exit latency after the desktop
# closes its end is bounded by this; the desktop's own kill-on-close Job is the
# hard backstop, so a quarter second is plenty and costs nothing measurable.
WINDOWS_PIPE_POLL_INTERVAL_S = 0.25
_FILE_TYPE_PIPE = 3 # winbase.h FILE_TYPE_PIPE
def _watch_parent_pipe(reader: BinaryIO, exit_process: Callable[[int], None]) -> None:
@@ -18,6 +25,64 @@ def _watch_parent_pipe(reader: BinaryIO, exit_process: Callable[[int], None]) ->
exit_process(0)
def _watch_parent_pipe_handle(
handle: int,
exit_process: Callable[[int], None],
*,
peek: Optional[Callable[[int], Any]] = None,
read_file: Optional[Callable[[int, int], Any]] = None,
sleep: Callable[[float], None] = time.sleep,
interval: float = WINDOWS_PIPE_POLL_INTERVAL_S,
) -> None:
"""Windows twin of :func:`_watch_parent_pipe` that never leaves a read
pending on the pipe.
A synchronous ``ReadFile`` parked on the stdin pipe whether issued through
the C runtime's ``read()`` or straight to the kernel — deadlocks the
OpenBLAS DLL initializer that ``import torch`` reaches (numpy's
``_multiarray_umath``) in the startup worker: every desktop-spawned backend
on Windows froze at "Loading ML runtime (PyTorch)" while the identical
command from a terminal, with no stdin pipe and no watchdog, started in
seconds. A thread that merely sleeps does not trigger it; only the pending
read on that pipe does. So instead of blocking in a read, poll with
``PeekNamedPipe``: it returns immediately, holds no I/O on the file object,
drains any keepalive bytes the desktop might write, and fails with
``ERROR_BROKEN_PIPE`` the moment the desktop closes its end which is the
same EOF signal the POSIX reader gets.
"""
if peek is None or read_file is None:
import _winapi # Windows-only stdlib module; the caller gates on the platform
peek = peek or _winapi.PeekNamedPipe
read_file = read_file or _winapi.ReadFile
try:
while True:
available, _ = peek(handle)
if available:
# Bytes are already buffered, so this read cannot block.
read_file(handle, available)
else:
sleep(interval)
except OSError:
# ERROR_BROKEN_PIPE (109) is how the closed parent end surfaces here.
pass
exit_process(0)
def _windows_pipe_handle(reader: Any) -> Optional[int]:
"""The OS handle behind ``reader`` when it is a pipe, else None."""
try:
import msvcrt
import _winapi
handle = msvcrt.get_osfhandle(reader.fileno())
if _winapi.GetFileType(handle) != _FILE_TYPE_PIPE:
return None
return handle
except (OSError, ValueError, AttributeError, ImportError):
return None
def arm_desktop_parent_watchdog() -> bool:
"""Use stdin EOF as an unforgeable parent-liveness signal for desktop runs."""
if os.environ.get("OMNIVOICE_DESKTOP_CONTAINED") != "1":
@@ -25,9 +90,18 @@ def arm_desktop_parent_watchdog() -> bool:
reader = getattr(sys.stdin, "buffer", None)
if reader is None:
return False
target: Callable[..., None] = _watch_parent_pipe
args: tuple = (reader, os._exit)
if os.name == "nt":
handle = _windows_pipe_handle(reader)
if handle is not None:
target = _watch_parent_pipe_handle
args = (handle, os._exit)
# A non-pipe stdin (file, NUL) cannot have a read pending against a
# pipe file object, so the blocking reader stays correct there.
threading.Thread(
target=_watch_parent_pipe,
args=(reader, os._exit),
target=target,
args=args,
name="desktop-parent-watchdog",
daemon=True,
).start()
+43 -16
View File
@@ -7,6 +7,7 @@ only the unguessable capability token crosses loopback HTTP.
from __future__ import annotations
import json
import logging
import os
import re
import secrets
@@ -14,6 +15,8 @@ import stat
from core.config import DATA_DIR
logger = logging.getLogger("omnivoice.path_authorization")
_TOKEN_RE = re.compile(r"[0-9a-f]{64}\Z")
_KINDS = {
"models_dir",
@@ -40,25 +43,49 @@ def consume(token: str, expected_kind: str) -> str:
if expected_kind not in _KINDS or not _TOKEN_RE.fullmatch(token or ""):
raise PathAuthorizationError("Invalid or expired desktop authorization")
root = _AUTH_DIR
# Distinguish "the store exists but this token isn't in it" (expired /
# already consumed / never issued — normal, no server-side signal) from
# "the store doesn't exist at all" (the desktop app and this backend are
# very likely pointed at different data directories, e.g. a dev backend
# started without OMNIVOICE_DATA_DIR, or a stale custom data folder — see
# #1781). The client-facing message is byte-identical either way (never
# leak local filesystem paths, or even which case occurred, over HTTP —
# CWE-200); the mismatch case additionally gets a server log line so it's
# diagnosable instead of a silent 403. That log line is deliberately
# path-free too (CWE-532: per-user filesystem paths, e.g. a home
# directory username, are sensitive and don't belong in application
# logs) — it names the failure mode, not the directory.
try:
entries = os.scandir(root)
except FileNotFoundError as exc:
logger.warning(
"path authorization store does not exist; the desktop app and "
"this backend likely resolved different data directories "
"(see #1781)"
)
raise PathAuthorizationError("Invalid or expired desktop authorization") from exc
except OSError as exc:
raise PathAuthorizationError("Invalid or expired desktop authorization") from exc
candidate = None
try:
for entry in os.scandir(root):
if not _TOKEN_RE.fullmatch(entry.name.removesuffix(".json")):
continue
if not entry.is_file(follow_symlinks=False):
continue
try:
with open(entry.path, "r", encoding="utf-8") as handle:
probe = json.load(handle)
except (OSError, UnicodeError, json.JSONDecodeError):
continue # Ignore corrupt/stale capabilities; they authorize nothing.
if isinstance(probe, dict) and secrets.compare_digest(
str(probe.get("token", "")), token
):
candidate = entry.path
break
with entries:
for entry in entries:
if not _TOKEN_RE.fullmatch(entry.name.removesuffix(".json")):
continue
if not entry.is_file(follow_symlinks=False):
continue
try:
with open(entry.path, "r", encoding="utf-8") as handle:
probe = json.load(handle)
except (OSError, UnicodeError, json.JSONDecodeError):
continue # Ignore corrupt/stale capabilities; they authorize nothing.
if isinstance(probe, dict) and secrets.compare_digest(
str(probe.get("token", "")), token
):
candidate = entry.path
break
if candidate is None:
raise OSError("capability not found")
raise PathAuthorizationError("Invalid or expired desktop authorization")
claimed = os.path.join(root, f".consuming-{os.getpid()}-{secrets.token_hex(16)}")
os.replace(candidate, claimed)
except OSError as exc:
+50
View File
@@ -91,3 +91,53 @@ def resolve(key: str, *, env: Optional[str] = None, default: Any = None) -> Any:
if v:
return v
return get(key, default)
# ── external-override detection (#1787 review fix) ──────────────────────────
# restore_env() below uses os.environ.setdefault(), so a value already present
# in the process's environment (shell profile, `.env`, Docker `-e`, systemd
# unit, …) silently wins over anything saved in prefs.json — the setdefault
# call is a no-op. That is the right behavior (env stays authoritative,
# matching resolve()'s contract above), but a Settings control that persists a
# value to prefs.json must not tell the user it "took effect after restart"
# when an external source will keep shadowing it on every future restart too.
#
# _EXTERNALLY_PROVIDED records, once per process start, every bare key that
# was ALREADY present in os.environ the moment restore_env() ran — i.e.
# before our own setdefault() calls could have put it there, and before any
# value our Settings UI ever wrote (Settings only ever writes prefs.json plus
# the CURRENT process's os.environ; it never touches a shell profile or `.env`
# file). Snapshotting unconditionally — not only for keys prefs.json already
# has an entry for — means is_env_shadowed() also answers correctly for a key
# a user is about to save for the FIRST time. Membership is stable for the
# life of the process (nothing removes an inherited env var), and since a
# plain restart re-inherits the same shell / container environment, it is
# also a reliable predictor for the NEXT start: if the external source is
# still exporting the key, the next restart will be shadowed again the same
# way.
_EXTERNALLY_PROVIDED: frozenset[str] = frozenset()
def restore_env(data: dict) -> None:
"""Restore ``env.*`` prefs into ``os.environ`` (startup only).
Called once from main.py's ``env_prefs`` step, before any user code reads
``os.environ``. Snapshots which keys were already externally provided
see :func:`is_env_shadowed` then applies every saved ``env.*`` pref via
``setdefault`` (never overriding an explicitly-set env var).
"""
global _EXTERNALLY_PROVIDED
_EXTERNALLY_PROVIDED = frozenset(os.environ.keys())
for k, v in data.items():
if not k.startswith("env.") or not v:
continue
os.environ.setdefault(k[len("env."):], str(v))
def is_env_shadowed(key: str) -> bool:
"""Whether *key* was already present in the environment from a source
other than our own prefs restore, as of the last time :func:`restore_env`
ran. If prefs.json holds (or will hold) a saved value for *key*, that
value is being silently ignored and will be again on the next restart
unless the external source is removed."""
return key in _EXTERNALLY_PROVIDED
+33 -4
View File
@@ -32,8 +32,8 @@ def stream_failure(code: str) -> dict[str, object]:
"code": "generation_timeout",
"detail": (
"Generation exceeded the compute-time limit. The backend is "
"still running; try a shorter passage or raise the generation "
"timeout."
"still running; try a shorter passage, or raise the "
"compute-time budget in Settings → Performance & Device."
),
"retryable": True,
},
@@ -94,6 +94,16 @@ def stream_generation_failure(error: BaseException | object) -> dict[str, object
replace the failure being diagnosed.
"""
payload = stream_failure("generation_failed")
if isinstance(error, BaseException):
# The exception's TYPE NAME, never its message. Two failures that both
# render the floor message "Generation failed. Check the selected
# engine and try again." are indistinguishable in an auto-filed report,
# so every unclassified streaming failure arrives as the same issue and
# none of them can be triaged (#1800). A class name is VoiceStudio-safe
# by the same reasoning that already puts it on the wire as
# `error_class` in the dub routes and on the analytics allowlist: it is
# a Python type, not user text, and no substring of `error` is copied.
payload["error_class"] = type(error).__name__
try:
enriched = public_exception_response(error, fallback=str(payload["detail"]))
except Exception:
@@ -149,12 +159,31 @@ def public_exception_response(error: BaseException, *, fallback: str) -> dict[st
Classification may inspect the private diagnostic locally, but response
values come exclusively from VoiceStudio-owned constants. No substring of
``error`` is copied into the payload.
Every caller is a CONTEXT-FREE surface the global 500 handler, the
streaming generate error frame, the dub GPU-OOM 503 so the topic is
filtered through ``failure._CONTEXT_FREE_HINT_CLASSES`` before its hint is
attached. Without that filter a topic whose trigger is a generic phrase
stamps a confidently wrong remediation on an unrelated failure: #1943 is a
macOS mlx-audio TTS 500 that came back advising the user that "the
connection to the video server dropped mid-download", because
VIDEO_DOWNLOAD_NETWORK triggers on a bare "timed out" / "connection
reset". The allowlist already existed and already named that class as the
example of what must not appear here; only :func:`failure.append_hint`
honoured it, and this helper replaced ``append_hint`` on the 500 path
without carrying the rule across.
HF_MIRROR_UNREACHABLE is allowed alongside it: its hint is dynamic (it
names the configured mirror) and its trigger requires that a mirror is
configured at all, so it cannot fire on an unrelated failure (#874).
"""
from core.failure import classify, public_hint_for_topic
from core.failure import _CONTEXT_FREE_HINT_CLASSES, classify, public_hint_for_topic
try:
topic = classify(str(error))
hint = public_hint_for_topic(topic)
if topic and topic not in _CONTEXT_FREE_HINT_CLASSES and topic != "HF_MIRROR_UNREACHABLE":
topic = ""
hint = public_hint_for_topic(topic) if topic else ""
except Exception:
topic = ""
hint = ""
+43
View File
@@ -0,0 +1,43 @@
"""The PyTorch wheel index VoiceStudio installs CUDA builds from.
A local-version pin such as ``torch==2.9.1+cu128`` exists only on PyTorch's
own index, never on PyPI. The app's own ``pyproject.toml`` routes torch there
through ``[tool.uv.sources]``, but a sidecar engine is installed with
``uv pip install`` into its own venv, which knows nothing about that config
so every CUDA-pinned sidecar install has to name the index itself.
MOSS-TTS-v1.5's install did not, and its ``[torch-runtime]`` extra
(``torch==2.9.1+cu128``) could never resolve: ``uv pip compile`` reports it
unsatisfiable without this index and resolves it with it. One definition here,
imported by the one-click installer and by the engine's own bootstrap, so the
two cannot drift apart again. ``tests/test_sidecar_install.py`` pins the URL
to the ``pytorch-cuda`` index declared in the app's ``pyproject.toml``.
"""
PYTORCH_CU128_INDEX_URL = "https://download.pytorch.org/whl/cu128"
# `unsafe-best-match`: the PyTorch index also mirrors common dependencies
# (numpy, pillow, sympy, …) at a narrower range of versions than PyPI. uv's
# default first-index strategy would stop at whichever index lists a name first
# and could pin an old mirror copy or fail outright. The index is PyTorch's
# official one, so the dependency-confusion risk the name warns about does not
# apply to it.
UV_PIP_CU128_ARGS: tuple[str, ...] = (
"--extra-index-url",
PYTORCH_CU128_INDEX_URL,
"--index-strategy",
"unsafe-best-match",
)
PYTORCH_CPU_INDEX_URL = "https://download.pytorch.org/whl/cpu"
# For an engine that runs torch only on the CPU (PocketTTS). On Linux, PyPI's
# torch is the CUDA build and pulls ~15 NVIDIA packages the engine never uses;
# this index serves `+cpu` builds for Linux and Windows and the regular build
# for macOS.
UV_PIP_CPU_ARGS: tuple[str, ...] = (
"--extra-index-url",
PYTORCH_CPU_INDEX_URL,
"--index-strategy",
"unsafe-best-match",
)
+1 -1
View File
@@ -24,7 +24,7 @@ from pathlib import Path
# tests/test_app_version.py::test_all_version_files_in_lockstep and bumped by
# release.yml's version-bump job, so it stays equal to
# pyproject/tauri.conf/Cargo/package.json.
_FALLBACK_VERSION = "0.5.1"
_FALLBACK_VERSION = "0.5.2"
def _fallback_version() -> str:
+590
View File
@@ -0,0 +1,590 @@
"""audio.cpp TTS backend — Breeze-TTS-2 via a managed native server.
audio.cpp (0xShug0/audio.cpp) is a pure-C++ ggml runtime: prebuilt
``audiocpp_server`` binaries for Windows/macOS/Linux, no Python venv, no
``transformers`` pin so this engine needs neither the venv-isolation
(``engines.dots_tts``) nor the per-generate CLI-spawn (``engines
.omnivoice_gguf``) patterns. The parent instead:
1. resolves the binary + GGUF model (``bootstrap.py``),
2. spawns ONE long-lived ``audiocpp_server`` on 127.0.0.1 (lazy model load,
so model memory is only held after the first generate), and
3. speaks its OpenAI-style ``POST /v1/audio/speech`` per generate.
v1 serves the ``breeze_tts`` family only (Breeze-TTS-2, en+zh, voice clone
+ voice design + voice direction). The server is task-agnostic on the
speech route reference-audio presence selects clone/direction vs design
so a single ``task: tts`` model entry covers all three modes.
License honesty: Breeze-TTS-2 weights (``BreezeBlue/Breeze-TTS-2`` and the
audio.cpp GGUF repack) are RESEARCH AND NON-COMMERCIAL ONLY
(``BreezeBlue Research and Non-Commercial License``); only the audio.cpp
code is Apache-2.0. There is no in-tree acceptance dialog for this engine
yet (settings ``/license`` allow-list), so the restriction is surfaced in
the display name, the install hint, and ``docs/engines/audio-cpp.md``
not silently.
"""
from __future__ import annotations
import atexit
import base64
import io
import json
import logging
import os
import secrets
# Used only for stream constants; spawn_owned performs the process launch.
import subprocess # nosec B404
import threading
import time
import urllib.error
import urllib.request
from pathlib import Path
from typing import TYPE_CHECKING, Any
from core.contained_subprocess import spawn_owned
from services.tts_backend import TTSBackend, TTSInputError
if TYPE_CHECKING:
import torch
logger = logging.getLogger("omnivoice.audiocpp")
#: Engine id in the TTS registry.
ENGINE_ID = "audiocpp"
#: How long to wait for ``/health`` after spawning the server (first spawn
#: extracts nothing heavy — the model loads lazily on first generate).
_HEALTH_TIMEOUT_S = 120.0
#: Finish the inner HTTP request before the canonical generation guard can
#: abandon its worker thread. This leaves enough time to terminate the owned
#: native process and release its model memory synchronously.
_TERMINATE_GRACE_S = 5.0
_TERMINATE_KILL_S = 5.0
_GENERATE_TIMEOUT_MARGIN_S = (
_TERMINATE_GRACE_S + _TERMINATE_KILL_S + 5.0
)
# ── pure request/config builders (unit-tested, no I/O) ──────────────────────
def _cpu_thread_count() -> int:
"""Use up to 16 physical cores, with a stdlib fallback."""
try:
import psutil
cores = psutil.cpu_count(logical=False)
except (ImportError, OSError):
cores = None
return min(16, max(1, cores or os.cpu_count() or 1))
def _device_min_vram_gb(device) -> float:
"""Dedicated-memory comfort floor for one discovered native device."""
return 6.0 if (
device
and device.kind == "GPU"
and (
device.backend == "vulkan"
or device.hardware_family in {"cuda", "rocm"}
)
) else 0.0
def build_server_config(
*, model_id: str, family: str, model_path: str, port: int,
backend: str = "cpu", device: int = 0,
execution_target: str | None = None,
) -> dict:
"""``server.json`` dict for the managed ``audiocpp_server``.
``lazy_load`` defers the ~4.73 GiB GGUF load to the first generate;
``max_loaded_models: 1`` bounds residency to the one model we serve.
"""
return {
"host": "127.0.0.1",
"port": port,
"backend": backend,
"device": device,
# The pinned CPU runtime scales strongly through 16 workers while
# producing byte-identical audio.
"threads": _cpu_thread_count()
if (execution_target or backend) == "cpu" else 1,
"lazy_load": True,
"max_loaded_models": 1,
"models": [
{
"id": model_id,
"family": family,
"path": model_path,
"task": "tts",
"mode": "offline",
}
],
}
def build_speech_payload(
*, model_id: str, text: str, ref_audio: str | None = None,
ref_text: str | None = None, instructions: str | None = None,
guidance_scale: float | None = None, seed: int | None = None,
) -> dict:
"""``POST /v1/audio/speech`` JSON body.
Field spellings verified against ``app/server/runtime.cpp``
(``build_speech_request``): ``instructions`` (plural, OpenAI spelling)
feeds the ``instruction`` request option; ``reference_text`` and
``guidance_scale``/``seed`` pass through top-level; ``voice_ref`` takes
a ``{"type": "path", ...}`` object so the reference stays on disk
(the 5 MiB base64 cap never bites). ``response_format: json`` returns
the WAV base64-in-JSON one round trip, no binary framing.
"""
payload: dict[str, Any] = {
"model": model_id,
"input": text,
"response_format": "json",
}
if instructions:
payload["instructions"] = instructions
if ref_audio:
payload["voice_ref"] = {"type": "path", "path": str(ref_audio)}
if ref_text:
payload["reference_text"] = ref_text
if guidance_scale is not None:
payload["guidance_scale"] = float(guidance_scale)
if seed is not None:
payload["seed"] = int(seed)
return payload
def decode_speech_json(obj: dict) -> tuple[int, object]:
"""``(sample_rate, mono float32 numpy)`` from a ``response_format=json``
speech body. Raises ``ValueError`` on a server error payload."""
if not isinstance(obj, dict):
raise TypeError(f"audio.cpp speech reply is not JSON: {obj!r:.120}")
if "audio" not in obj:
raise ValueError(f"audio.cpp speech failed: {obj.get('error', obj)!r:.300}")
import numpy as np
import soundfile as sf
wav_bytes = base64.b64decode(obj["audio"])
wav, sr = sf.read(io.BytesIO(wav_bytes), dtype="float32", always_2d=False)
wav = np.asarray(wav, dtype=np.float32)
if wav.ndim > 1:
wav = wav.mean(axis=-1)
return int(sr), wav
# ── backend ─────────────────────────────────────────────────────────────────
class AudioCPPBackend(TTSBackend):
"""Breeze-TTS-2 through a parent-managed ``audiocpp_server``."""
id = ENGINE_ID
display_name = (
"audio.cpp · Breeze-TTS-2 (native GGUF, en+zh, clone+design; "
"weights research/non-commercial)"
)
supports_voice_design = True
applies_own_mastering = True # model-decoded 24 kHz studio output
gpu_compat = ("cpu",)
runs_out_of_process = True
# Same marker SubprocessBackend sets: this engine lives in another OS
# process. Consumers only branch the matrix label and the self-test
# route (spawn-and-ping instead of in-process synth) — both correct
# here; nothing assumes the stdio protocol from it.
_is_subprocess_isolated = True
_DEFAULT_SAMPLE_RATE = 24000 # Breeze-TTS-2 native rate
def __init__(self) -> None:
self._proc: Any | None = None
self._port: int | None = None
self._server_model_id: str | None = None
self._sr = self._DEFAULT_SAMPLE_RATE
self._lock = threading.RLock()
self._server_json: Path | None = None
self._selection = None
self._device = None
self._provider = None
# ── availability ────────────────────────────────────────────────────
@classmethod
def is_available(cls) -> tuple[bool, str]:
from engines.audiocpp import bootstrap
try:
bootstrap.resolve_server_binary()
bootstrap.resolve_model_file()
except RuntimeError as exc:
return False, str(exc)
return True, "ready"
@classmethod
def runtime_compute_profile(cls, caps) -> dict:
from dataclasses import replace
from engines.audiocpp import bootstrap
from services.engine_routing import low_vram_caveat
try:
selection = bootstrap.resolve_compute_selection(caps)
targets = bootstrap.runtime_targets()
except RuntimeError as exc:
return {
"gpu_compat": cls.gpu_compat,
"min_vram_gb": 0.0,
"effective_device": "cpu",
"routing_status": "unavailable",
"routing_reason": str(exc),
"runtime_backend": None,
"runtime_device_index": None,
"runtime_device_name": None,
"runtime_hardware_family": None,
"runtime_vram_gb": None,
"runtime_device_verified": False,
}
selected = selection.device
accelerated = selected.target != "cpu"
min_vram_gb = _device_min_vram_gb(selected)
dedicated = min_vram_gb > 0
reason = selection.fallback_reason
if accelerated and dedicated and reason is None:
selected_caps = replace(
caps,
device_name=selected.name,
vram_gb=selection.verified_vram_gb,
)
reason = low_vram_caveat(
selected_caps,
min_vram_gb,
family=selected.hardware_family,
vram_gb=selection.verified_vram_gb,
)
status = "accelerated" if accelerated else (
"cpu_fallback" if selection.fallback_reason else "cpu_only"
)
return {
"gpu_compat": targets,
"min_vram_gb": min_vram_gb,
"effective_device": selected.target,
"routing_status": status,
"routing_reason": reason,
"runtime_backend": selected.backend,
"runtime_device_index": selected.index,
"runtime_device_name": selected.name,
"runtime_hardware_family": selected.hardware_family,
"runtime_vram_gb": selection.verified_vram_gb,
"runtime_device_verified": selection.verified_vram_gb > 0,
}
# ── TTSBackend protocol ─────────────────────────────────────────────
@property
def sample_rate(self) -> int:
return self._sr
@property
def supported_languages(self) -> list[str]:
return ["en", "zh"]
def model_identity(self) -> str | None:
from engines.audiocpp import bootstrap
return f"{bootstrap.FAMILY}/{bootstrap.package_filename()}"
# ── server lifecycle ────────────────────────────────────────────────
def _base_url(self) -> str:
return f"http://127.0.0.1:{self._port}"
def _ensure_loaded(self) -> None:
"""Spawn the server (once) and wait for ``/health``. Idempotent."""
with self._lock:
if self._proc is not None and self._proc.poll() is None:
return
self._proc = None # stale handle — respawn below
from engines.audiocpp import bootstrap
binary = bootstrap.resolve_server_binary()
selection = bootstrap.resolve_compute_selection()
model_file = bootstrap.resolve_model_file()
self._port = bootstrap.server_port()
# The random model id is a per-launch challenge. Before sending
# speech text or a reference path, _verify_server_identity asks
# /v1/models to prove this is the child configured by this process,
# not an unrelated listener that pre-bound the loopback port.
self._server_model_id = f"{bootstrap.MODEL_ID}-{secrets.token_hex(16)}"
config = build_server_config(
model_id=self._server_model_id,
family=bootstrap.FAMILY,
model_path=str(model_file),
port=self._port,
backend=selection.device.backend,
device=selection.device.index,
execution_target=selection.device.target,
)
self._selection = selection
self._device = selection.device.target
self._provider = selection.device.backend
from core.config import DATA_DIR
workdir = Path(str(DATA_DIR)) / "audiocpp"
workdir.mkdir(parents=True, exist_ok=True)
self._server_json = workdir / "server.json"
flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC
config_fd = os.open(self._server_json, flags, 0o600)
try:
if os.name != "nt":
os.fchmod(config_fd, 0o600)
with os.fdopen(config_fd, "w", encoding="utf-8") as config_fh:
config_fd = -1
json.dump(config, config_fh, indent=2)
finally:
if config_fd >= 0:
os.close(config_fd)
log_path = workdir / "server.log"
logger.info(
"audio.cpp: starting %s (backend=%s, device=%d, port=%d, model=%s)",
binary.name, selection.device.backend, selection.device.index,
self._port, model_file.name,
)
with open(log_path, "ab") as log_fh:
self._proc = spawn_owned(
[str(binary), "--config", str(self._server_json)],
stdout=log_fh,
stderr=subprocess.STDOUT,
stdin=subprocess.DEVNULL,
)
atexit.register(self._terminate_server)
self._wait_for_health()
def _wait_for_health(self) -> None:
if self._proc is None or self._port is None:
raise RuntimeError("managed audio.cpp server was not started")
deadline = time.monotonic() + _HEALTH_TIMEOUT_S
last_err = "unknown"
url = self._base_url() + "/health"
while time.monotonic() < deadline:
if self._proc.poll() is not None:
raise RuntimeError(
"audiocpp_server exited during startup "
f"(code {self._proc.returncode}). See the server log next "
"to server.json under the app data audiocpp/ directory — "
"the managed port may already be in use."
)
try:
# ``url`` is always the hard-coded loopback host plus a
# validated integer port; arbitrary schemes are impossible.
with urllib.request.urlopen(url, timeout=5) as resp: # nosec B310
if resp.status == 200:
self._verify_server_identity()
if self._proc.poll() is None:
logger.info(
"audio.cpp: managed server is healthy on loopback"
)
return
last_err = f"HTTP {resp.status}"
except Exception as exc: # noqa: BLE001 — still starting; retry
last_err = f"{type(exc).__name__}: {exc}"
time.sleep(1.0)
self._terminate_server()
raise RuntimeError(
f"audiocpp_server did not become healthy within "
f"{_HEALTH_TIMEOUT_S:.0f}s (last: {last_err})."
)
def _get_json(self, path: str, timeout: float = 5.0) -> dict:
"""GET one loopback JSON endpoint without sending request content."""
if self._port is None:
raise RuntimeError("managed audio.cpp server port is missing")
req = urllib.request.Request(self._base_url() + path, method="GET")
with urllib.request.urlopen(req, timeout=timeout) as resp: # nosec B310
obj = json.loads(resp.read().decode("utf-8"))
if not isinstance(obj, dict):
raise TypeError("audio.cpp returned an invalid JSON response")
return obj
def _verify_server_identity(self) -> None:
"""Prove the loopback listener owns this launch's random model id."""
if self._proc is None or self._proc.poll() is not None:
raise RuntimeError("managed audio.cpp server is not running")
expected = self._server_model_id
if not expected:
raise RuntimeError("managed audio.cpp server identity is missing")
obj = self._get_json("/v1/models")
data = obj.get("data", [])
if not isinstance(data, list):
raise TypeError("managed audio.cpp server identity is invalid")
model_ids = {
item.get("id") for item in data
if isinstance(item, dict)
}
if expected not in model_ids or self._proc.poll() is not None:
raise RuntimeError(
"loopback listener did not prove managed audio.cpp ownership"
)
def _post_json(self, path: str, payload: dict, timeout: float) -> dict:
"""Verify child ownership, then POST JSON to the managed server."""
if self._port is None:
raise RuntimeError("managed audio.cpp server port is missing")
self._verify_server_identity()
body = json.dumps(payload).encode("utf-8")
req = urllib.request.Request(
self._base_url() + path,
data=body,
headers={"Content-Type": "application/json"},
method="POST",
)
try:
# ``req`` targets only ``_base_url()`` (127.0.0.1 + validated
# integer port), never a caller-provided URL.
with urllib.request.urlopen(req, timeout=timeout) as resp: # nosec B310
return json.loads(resp.read().decode("utf-8"))
except urllib.error.HTTPError as exc:
detail = exc.read().decode("utf-8", errors="replace")[:500]
raise RuntimeError(
f"audio.cpp {path} failed (HTTP {exc.code}): {detail}"
) from exc
except urllib.error.URLError as exc:
if isinstance(exc.reason, TimeoutError):
raise TimeoutError("audio.cpp request timed out") from exc
raise
def _terminate_server(self) -> None:
proc, self._proc = self._proc, None
self._server_model_id = None
if proc is None:
return
try:
proc.terminate()
proc.wait(timeout=_TERMINATE_GRACE_S)
except Exception: # noqa: BLE001 — kill as last resort, never raise
try:
proc.kill()
proc.wait(timeout=_TERMINATE_KILL_S)
except Exception as exc: # noqa: BLE001 — process is already failing
logger.debug("audio.cpp: final server kill failed: %s", exc)
# ── generate ────────────────────────────────────────────────────────
def generate(self, text: str, **kw) -> torch.Tensor:
import torch
from services.model_manager import (
GENERATE_PROGRESS_GRACE_S,
generate_timeout_s,
report_generate_progress,
)
if not text or not text.strip():
raise TTSInputError(
"audio.cpp: the input contains no speakable text — "
"send at least one word."
)
ref_audio = kw.get("ref_audio")
ref_text = kw.get("ref_text")
if ref_text and not ref_audio:
logger.info(
"audio.cpp: ref_text supplied without ref_audio; ignoring."
)
ref_text = None
# Voice design: our `description=` (no ref) and voice direction
# (`instruct=` + ref) both ride the server's `instructions` field —
# verified spelling against app/server/runtime.cpp.
instruct = kw.get("instruct") or kw.get("description") or None
language = kw.get("language")
if language and str(language).strip().lower() not in {
"auto", "en", "english", "zh", "chinese",
}:
logger.info(
"audio.cpp (Breeze-TTS-2) is en+zh only; ignoring "
"language=%r.", language,
)
if kw.get("speed", 1.0) != 1.0:
logger.info("audio.cpp: speed is not supported; ignoring.")
request_started = time.monotonic()
with self._lock:
self._ensure_loaded()
selected = self._selection.device if self._selection else None
min_vram_gb = _device_min_vram_gb(selected)
request_budget = generate_timeout_s(
text,
execution_device=selected.target if selected else "cpu",
min_vram_gb=min_vram_gb,
hardware_family=selected.hardware_family if selected else None,
vram_gb=self._selection.verified_vram_gb
if self._selection else 0.0,
)
if not self._server_model_id:
raise RuntimeError("managed audio.cpp server identity is missing")
payload = build_speech_payload(
model_id=self._server_model_id,
text=text,
ref_audio=str(ref_audio) if ref_audio else None,
ref_text=ref_text,
instructions=instruct,
guidance_scale=kw.get("guidance_scale", 1.0),
seed=kw.get("seed"),
)
# Device discovery and server startup can consume part of the soft
# budget. This fresh synthesis lease gives the lazy model load and
# request a bounded window. The inner request always expires early
# enough to reap the owned server before the outer guard abandons us.
report_generate_progress()
soft_remaining = request_budget - (time.monotonic() - request_started)
timeout = (
max(soft_remaining, GENERATE_PROGRESS_GRACE_S)
- _GENERATE_TIMEOUT_MARGIN_S
)
if timeout <= 0:
self._terminate_server()
raise TimeoutError(
"audio.cpp startup exhausted the generation time budget"
)
try:
obj = self._post_json(
"/v1/audio/speech", payload, timeout=timeout,
)
except TimeoutError:
self._terminate_server()
raise RuntimeError(
"audio.cpp generation timed out; its managed server was reset"
) from None
sr, wav_np = decode_speech_json(obj)
self._sr = sr
wav = torch.from_numpy(wav_np).float()
if wav.ndim == 0:
raise RuntimeError("audio.cpp produced empty audio")
return wav.unsqueeze(0)
# ── lifecycle ───────────────────────────────────────────────────────
def unload(self) -> None:
"""Free the model server-side, then stop it. Idempotent."""
with self._lock:
if self._port is not None and self._proc is not None \
and self._proc.poll() is None:
try:
self._post_json("/v1/tasks/unload_all_models", {}, timeout=30)
except Exception as exc: # noqa: BLE001 — best effort
logger.warning("audio.cpp: server unload failed: %s", exc)
self._port = None
self._terminate_server()
super().unload()
__all__ = [
"ENGINE_ID",
"AudioCPPBackend",
"build_server_config",
"build_speech_payload",
"decode_speech_json",
]
+738
View File
@@ -0,0 +1,738 @@
"""audio.cpp binary probe + model resolution.
audio.cpp (0xShug0/audio.cpp) is a pure-C++ ggml inference engine with
prebuilt release binaries no Python venv, no ``transformers`` pin, so
none of the dependency-isolation machinery in ``engines._venv_probe`` or
``services.subprocess_backend`` applies. The parent instead:
1. locates a user-installed ``audiocpp_server`` (env var, user dir, or this
package's ``bin/``), and
2. resolves an explicitly installed GGUF model file from a direct path or
the shared Hugging Face cache.
Probe order for the server binary (existing installs win, zero migration):
1. ``${OMNIVOICE_AUDIOCPP_BIN}`` absolute path to the binary itself.
2. ``${OMNIVOICE_AUDIOCPP_DIR}/audiocpp_server[.exe]`` a user-managed
install dir (e.g. an extracted release zip, or a self-built tree).
3. ``backend/engines/audiocpp/bin/audiocpp_server[.exe]`` an explicitly
installed local copy.
``is_installed()`` is a cheap file-existence check no spawn, no network.
VoiceStudio never downloads executable code for this engine.
"""
from __future__ import annotations
import errno
import functools
import logging
import os
import platform
import subprocess # nosec B404 -- fixed argv probes a user-selected executable
import sys
from dataclasses import dataclass
from pathlib import Path
logger = logging.getLogger("omnivoice.audiocpp.bootstrap")
#: Pinned audio.cpp release. BreezeTTS-2 support landed in 0.7.2 — older
#: binaries have no ``breeze_tts`` family, so the floor is also the pin.
VERSION = "v0.7.2"
#: GitHub repo serving the prebuilt binaries.
GH_REPO = "0xShug0/audio.cpp"
#: HuggingFace repo serving the GGUF model packages (not gated).
HF_MODEL_REPO = "audio-cpp/audio.cpp-gguf"
# Immutable repository revision used for the v0.7.2 Breeze-TTS-2 package.
# Pinning prevents a later upstream file replacement from silently changing
# the model exercised by this backend.
HF_MODEL_REVISION = "dc6fecccc2b0c6bdda0a8b2f38fa61394fee0b9c"
#: Model id used in the generated ``server.json`` and in speech requests.
MODEL_ID = "breeze-tts-2"
#: audio.cpp family name for BreezeTTS 2 (``--family`` / server ``family``).
FAMILY = "breeze_tts"
#: GGUF package directory inside :data:`HF_MODEL_REPO`.
PACKAGE_DIR = "Breeze-TTS-2-GGUF"
#: Default package (Q8_0, the upstream-recommended GGUF). ``bf16`` is
#: available via ``OMNIVOICE_AUDIOCPP_PACKAGE``.
DEFAULT_PACKAGE = "breeze-tts-2-q8_0.gguf"
#: Env var pointing directly at the ``audiocpp_server`` binary.
BIN_ENV = "OMNIVOICE_AUDIOCPP_BIN"
#: Env var pointing at a directory containing ``audiocpp_server``.
DIR_ENV = "OMNIVOICE_AUDIOCPP_DIR"
#: Env var overriding the GGUF package filename (e.g. the bf16 package).
PACKAGE_ENV = "OMNIVOICE_AUDIOCPP_PACKAGE"
#: Optional advanced overrides for a binary that exposes several runtimes or
#: devices. Device indices are local to the selected backend registry.
BACKEND_ENV = "OMNIVOICE_AUDIOCPP_BACKEND"
DEVICE_ENV = "OMNIVOICE_AUDIOCPP_DEVICE"
#: Env var overriding the loopback port the managed server binds.
PORT_ENV = "OMNIVOICE_AUDIOCPP_PORT"
#: Default loopback port. High and engine-specific to avoid clashing with
#: the app itself or a user-run ``audiocpp_server`` (default 8080).
DEFAULT_PORT = 17860
#: This package's owned binary dir (probe 3).
_PKG_BIN_DIR: Path = Path(__file__).parent / "bin"
# Recommended (asset filename, sha256) per platform slug, from the v0.7.2
# release. Windows and Linux use the vendor-neutral Vulkan build, which also
# exposes the native CPU backend. Upstream publishes the macOS builds under
# the Metal package name. No linux-aarch64 prebuilt exists in v0.7.2.
_ASSETS: dict[str, tuple[str, str]] = {
"windows-x64": (
"audio-v0.7.2-bin-windows-x64-vulkan.zip",
"15b8232eae740e21e507d87f827a89966de9451b085a45932d9e214e032962c1",
),
"linux-x64": (
"audio-v0.7.2-bin-ubuntu-x64-vulkan.tar.gz",
"fee1f978cee76453cf17f00196554bc2ee294645739538af0726a143b6a69a23",
),
"darwin-arm64": (
"audio-v0.7.2-bin-macos-arm64-metal.tar.gz",
"c01e4f82971bedbe341697e63a9cebd5a5d1f72d5a9bcb51a3191f95ddab7a95",
),
"darwin-x64": (
"audio-v0.7.2-bin-macos-x64-metal.tar.gz",
"3862270f33439077225324169313f727064f727305b54d8ce920244d75ddcc24",
),
}
#: Binary filename per platform.
_BINARY_NAMES = {"windows-x64": "audiocpp_server.exe"}
_REGISTRY_BACKENDS = {
"CPU": "cpu",
"CUDA": "cuda",
"MUSA": "cuda",
"HIP": "hip",
"ROCm": "hip",
"Vulkan": "vulkan",
"Metal": "metal",
"MTL": "metal",
}
_BACKEND_ALIASES = {
"cpu": "cpu",
"cuda": "cuda",
"hip": "hip",
"rocm": "hip",
"vulkan": "vulkan",
"metal": "metal",
}
@dataclass(frozen=True)
class AudioCPPDevice:
"""One immutable device from audio.cpp's backend-local registry."""
registry: str
backend: str
index: int
name: str
kind: str
target: str
hardware_family: str
@dataclass(frozen=True)
class AudioCPPSelection:
"""The runtime/device chosen for the next managed server."""
device: AudioCPPDevice
fallback_reason: str | None = None
verified_vram_gb: float = 0.0
@dataclass(frozen=True)
class _ProbeOutcome:
devices: tuple[AudioCPPDevice, ...] = ()
error: str | None = None
def _cpu_probe_fallback(error: RuntimeError) -> AudioCPPSelection:
"""A usable automatic fallback when native device discovery fails."""
return AudioCPPSelection(
AudioCPPDevice(
registry="CPU",
backend="cpu",
index=0,
name="Host CPU",
kind="CPU",
target="cpu",
hardware_family="cpu",
),
f"{error}; running on CPU",
)
def _vulkan_hardware_family(name: str) -> str:
low = name.casefold()
if any(token in low for token in ("nvidia", "geforce", "quadro", "tesla")):
return "cuda"
if any(token in low for token in ("amd", "radeon")):
return "rocm"
if any(token in low for token in ("intel", "arc ")):
return "xpu"
return "vulkan"
def _device_families(registry: str, name: str, kind: str) -> tuple[str, str]:
# Software adapters such as Vulkan llvmpipe may be listed by a GPU
# registry but still execute on the CPU. Keep their runtime backend for
# explicit overrides while reporting and routing them as CPU work.
if kind == "CPU":
return "cpu", "cpu"
if registry in {"CUDA", "MUSA"}:
return "cuda", "cuda"
if registry in {"HIP", "ROCm"}:
return "rocm", "rocm"
if registry in {"Metal", "MTL"}:
return "mps", "mps"
if registry == "Vulkan":
return "vulkan", _vulkan_hardware_family(name)
return "cpu", "cpu"
def parse_device_list(output: str) -> tuple[AudioCPPDevice, ...]:
"""Parse the stable stdout contract of ``--list-devices``.
Backend diagnostics are emitted on stderr and deliberately never enter
this parser. Unknown future registries are ignored; malformed entries for
a registry we understand fail closed instead of selecting the wrong GPU.
"""
devices: list[AudioCPPDevice] = []
seen: set[tuple[str, int]] = set()
for raw in str(output or "").splitlines():
line = raw.strip()
registry, colon, detail = line.partition(":")
if not colon or registry not in _REGISTRY_BACKENDS:
continue
index_text, space, remainder = detail.strip().partition(" ")
if not space or not index_text.isascii() or not index_text.isdecimal():
raise RuntimeError(
f"malformed audio.cpp {registry} device entry"
)
index = int(index_text)
remainder = remainder.strip()
kind_start = remainder.rfind("[")
if kind_start < 0 or not remainder.endswith("]"):
raise RuntimeError(
f"malformed audio.cpp {registry} device entry"
)
name_field = remainder[:kind_start].strip()
if name_field:
if len(name_field) < 2 or name_field[0] != '"' or name_field[-1] != '"':
raise RuntimeError(
f"malformed audio.cpp {registry} device entry"
)
name = name_field[1:-1]
else:
name = ""
kind = remainder[kind_start + 1:-1].strip().upper()
if kind not in {"CPU", "GPU", "IGPU", "ACCEL", "META"}:
raise RuntimeError("unknown audio.cpp device kind")
# Registry aliases such as HIP/ROCm share one backend-local index
# namespace and therefore cannot safely describe different devices.
key = (_REGISTRY_BACKENDS[registry], index)
if key in seen:
raise RuntimeError(
f"duplicate audio.cpp device entry: {registry}:{index}"
)
seen.add(key)
target, hardware_family = _device_families(registry, name, kind)
devices.append(AudioCPPDevice(
registry=registry,
backend=_REGISTRY_BACKENDS[registry],
index=index,
name=name,
kind=kind,
target=target,
hardware_family=hardware_family,
))
if not devices:
raise RuntimeError("audio.cpp reported no recognized compute devices")
return tuple(devices)
def _platform_slug() -> str:
system = sys.platform
machine = platform.machine().lower()
if system == "win32":
return "windows-x64"
if system == "darwin":
return "darwin-arm64" if machine in ("arm64", "aarch64") else "darwin-x64"
if machine in ("x86_64", "amd64"):
return "linux-x64"
return f"linux-{machine}"
def binary_name(slug: str | None = None) -> str:
"""``audiocpp_server`` filename for ``slug`` (``.exe`` on Windows)."""
return _BINARY_NAMES.get(slug or _platform_slug(), "audiocpp_server")
def _probe_paths() -> list[Path]:
out: list[Path] = []
direct = os.environ.get(BIN_ENV, "").strip()
if direct:
out.append(Path(direct))
user_dir = os.environ.get(DIR_ENV, "").strip()
if user_dir:
out.append(Path(user_dir) / binary_name())
out.append(_PKG_BIN_DIR / binary_name())
return out
def is_installed() -> bool:
"""Cheap precedence-aware check for a usable server binary."""
try:
resolve_server_binary()
except RuntimeError:
return False
return True
def resolve_server_binary() -> Path:
"""Resolve the ``audiocpp_server`` binary. Raises ``RuntimeError`` with
install instructions when none is found."""
for cand in _probe_paths():
if cand.is_file():
if os.name == "nt" or os.access(cand, os.X_OK):
return cand
raise RuntimeError(
"audiocpp_server is not executable. Run `chmod +x "
"audiocpp_server` on the configured binary, then restart "
"VoiceStudio. See docs/engines/audio-cpp.md."
)
slug = _platform_slug()
asset = _ASSETS.get(slug)
if asset is None:
raise RuntimeError(
f"audio.cpp ships no prebuilt binary for this platform ({slug}). "
"Build from https://github.com/0xShug0/audio.cpp and set "
f"{BIN_ENV} to your audiocpp_server binary. See "
"docs/engines/audio-cpp.md."
)
raise RuntimeError(
"audiocpp_server not found. Download "
f"https://github.com/{GH_REPO}/releases/download/{VERSION}/{asset[0]} "
f"(SHA-256 {asset[1]}), verify and extract it, and set {BIN_ENV} to the "
"audiocpp_server binary (or "
f"{DIR_ENV} to its directory). See docs/engines/audio-cpp.md."
)
@functools.lru_cache(maxsize=4)
def _probe_device_outcome(binary: str) -> _ProbeOutcome:
try:
proc = subprocess.run( # nosec B603 -- executable is the resolved engine binary
[binary, "--list-devices"],
capture_output=True,
text=True,
timeout=10,
check=False,
)
except subprocess.TimeoutExpired:
return _ProbeOutcome(
error="audiocpp_server device discovery timed out after 10 seconds"
)
except OSError as exc:
return _ProbeOutcome(
error=(
"audiocpp_server device discovery could not start: "
f"{type(exc).__name__}"
)
)
if proc.returncode != 0:
return _ProbeOutcome(
error=(
"audiocpp_server device discovery failed "
f"(code {proc.returncode}). Check the audio.cpp server log "
"for details."
)
)
try:
return _ProbeOutcome(devices=parse_device_list(proc.stdout))
except RuntimeError as exc:
return _ProbeOutcome(error=str(exc))
def _probe_devices(binary: str) -> tuple[AudioCPPDevice, ...]:
outcome = _probe_device_outcome(binary)
if outcome.error:
raise RuntimeError(outcome.error)
return outcome.devices
def probe_devices() -> tuple[AudioCPPDevice, ...]:
"""Return the installed binary's devices without loading a model."""
return _probe_devices(str(resolve_server_binary()))
def _priority(device: AudioCPPDevice) -> tuple[int, int]:
if device.kind == "META":
# Tensor-parallel meta devices are valid explicit targets, but their
# resource footprint is not safe to choose implicitly over CPU.
rank = 8
elif device.backend != "cpu" and device.kind == "CPU":
# Native CPU is the predictable fallback. Software adapters remain
# available to an explicit backend override but never win auto mode.
rank = 7
elif device.backend == "cuda":
rank = 0
elif device.backend == "hip":
rank = 1
elif device.backend == "metal":
rank = 2
elif device.backend == "vulkan" and device.kind == "GPU":
rank = 3
elif device.backend == "vulkan" and device.kind in {"IGPU", "ACCEL"}:
rank = 4
elif device.backend == "cpu":
rank = 6
else:
rank = 5
return rank, device.index
def select_device(
devices: tuple[AudioCPPDevice, ...],
*,
requested_family: str = "auto",
backend_override: str | None = None,
device_override: int | None = None,
preferred_name: str = "",
) -> AudioCPPSelection:
"""Resolve one device with explicit overrides and discrete-GPU priority."""
if backend_override:
normalized = _BACKEND_ALIASES.get(backend_override.strip().lower())
if normalized is None:
valid = ", ".join(_BACKEND_ALIASES)
raise RuntimeError(
f"unknown audio.cpp backend '{backend_override}' (valid: {valid})"
)
candidates = [device for device in devices if device.backend == normalized]
if device_override is not None:
candidates = [
device for device in candidates if device.index == device_override
]
if not candidates:
suffix = "" if device_override is None else f" device {device_override}"
available = ", ".join(
f"{device.backend}:{device.index}" for device in devices
)
raise RuntimeError(
f"audio.cpp backend '{backend_override}'{suffix} is unavailable "
f"(available: {available})"
)
# An explicit runtime request should still prefer a compute device to
# a software adapter when no backend-local index was supplied. META is
# valid here because the user explicitly chose this registry.
return AudioCPPSelection(min(
candidates,
key=lambda device: (device.kind == "CPU", _priority(device)),
))
if device_override is not None:
raise RuntimeError(
f"{DEVICE_ENV} requires {BACKEND_ENV} because device indices are "
"backend-local"
)
family = (requested_family or "auto").strip().lower()
if family != "auto":
candidates = [
device for device in devices if device.hardware_family == family
]
if candidates:
preferred = preferred_name.casefold().strip()
if preferred:
named = [
device for device in candidates
if device.name
and (
preferred in device.name.casefold()
or device.name.casefold() in preferred
)
]
if named:
candidates = named
return AudioCPPSelection(min(candidates, key=_priority))
cpu = [device for device in devices if device.backend == "cpu"]
if cpu:
return AudioCPPSelection(
min(cpu, key=_priority),
f"requested {family.upper()} device is not exposed by the "
"installed audio.cpp binary; running on CPU",
)
raise RuntimeError(
f"requested {family.upper()} device is not exposed by the "
"installed audio.cpp binary"
)
return AudioCPPSelection(min(devices, key=_priority))
def resolve_compute_selection(caps=None) -> AudioCPPSelection:
"""Select the runtime from engine env overrides, Settings, then auto."""
backend_override = os.environ.get(BACKEND_ENV, "").strip() or None
raw_device = os.environ.get(DEVICE_ENV, "").strip()
device_override: int | None = None
if raw_device:
try:
device_override = int(raw_device)
except ValueError as exc:
raise RuntimeError(
f"{DEVICE_ENV} must be a non-negative integer"
) from exc
if device_override < 0:
raise RuntimeError(f"{DEVICE_ENV} must be a non-negative integer")
if caps is None:
from core.device_caps import detect_host_caps
caps = detect_host_caps()
requested = getattr(caps, "requested_family", "auto") or "auto"
try:
devices = probe_devices()
except RuntimeError as exc:
if backend_override or raw_device or requested != "auto":
raise
return _cpu_probe_fallback(exc)
selection = select_device(
devices,
requested_family=requested,
backend_override=backend_override,
device_override=device_override,
preferred_name=getattr(caps, "device_name", "") or "",
)
# HostCaps measures the preferred accelerator's device 0. Reuse that VRAM
# only when the selected native registry has exactly one device with the
# same normalized name. Multi-GPU peers with identical names stay unknown.
selected_name = " ".join(selection.device.name.casefold().split())
host_name = " ".join(
str(getattr(caps, "device_name", "") or "").casefold().split()
)
peers = [
device for device in devices
if device.backend == selection.device.backend
and " ".join(device.name.casefold().split()) == host_name
]
if (
selected_name
and selected_name == host_name
and len(peers) == 1
and float(getattr(caps, "vram_gb", 0.0) or 0.0) > 0
):
return AudioCPPSelection(
selection.device,
selection.fallback_reason,
float(caps.vram_gb),
)
return selection
def runtime_targets(devices: tuple[AudioCPPDevice, ...] | None = None) -> tuple[str, ...]:
"""Actual compute backends compiled into the selected binary."""
if devices is not None:
found = devices
else:
try:
found = probe_devices()
except RuntimeError:
if (
os.environ.get(BACKEND_ENV, "").strip()
or os.environ.get(DEVICE_ENV, "").strip()
):
raise
return ("cpu",)
ordered: list[str] = []
for device in sorted(found, key=_priority):
if device.target not in ordered:
ordered.append(device.target)
return tuple(ordered)
def invalidate() -> None:
"""Forget cached binary capability discovery after an install change."""
_probe_device_outcome.cache_clear()
def default_asset() -> tuple[str, str] | None:
"""``(filename, sha256)`` of the release asset for this host, or None
when upstream ships no prebuilt for it."""
return _ASSETS.get(_platform_slug())
def server_port() -> int:
"""Loopback port for the managed server (env override or default)."""
raw = os.environ.get(PORT_ENV, "").strip()
if raw:
try:
port = int(raw)
if 1 <= port <= 65535:
return port
logger.warning("Ignoring %s=%r: out of range.", PORT_ENV, raw)
except ValueError:
logger.warning("Ignoring %s=%r: not a number.", PORT_ENV, raw)
return DEFAULT_PORT
def package_filename() -> str:
"""GGUF package filename (env override or the Q8_0 default)."""
return os.environ.get(PACKAGE_ENV, "").strip() or DEFAULT_PACKAGE
def _materialize_gguf_cache_path(model_file: Path) -> Path:
"""Return a real ``.gguf`` path when the HF snapshot is a symlink.
audio.cpp canonicalizes model paths before inspecting the suffix. The
Hugging Face cache points the friendly ``.gguf`` snapshot name at an
extensionless content-addressed blob, so passing that symlink makes the
server reject a valid model. A hard link beside the snapshot keeps the
required suffix without copying a multi-gigabyte model or escaping the
snapshot's cleanup lifecycle.
"""
resolved = model_file.resolve()
if resolved.suffix.lower() == ".gguf":
return model_file
if model_file.suffix.lower() != ".gguf":
raise RuntimeError(f"audio.cpp model must be a .gguf file: {model_file}")
def _link(alias: Path) -> Path:
for attempt in range(2):
try:
os.link(resolved, alias)
except FileExistsError:
if (
not alias.is_symlink()
and alias.is_file()
and os.path.samefile(resolved, alias)
):
return alias
if attempt == 0 and alias.is_symlink():
alias.unlink()
continue
raise RuntimeError(
f"audio.cpp model alias points at a different file: {alias}"
) from None
return alias
raise RuntimeError(f"audio.cpp model alias could not be created: {alias}")
alias = model_file.with_name(
f".{model_file.stem}-{HF_MODEL_REVISION[:12]}.audiocpp.gguf"
)
try:
return _link(alias)
except OSError as exc:
if exc.errno == errno.EXDEV:
# An explicit symlink may live on a different filesystem from its
# target. Put the suffix-preserving hard link beside the resolved
# file so no multi-gigabyte copy is needed.
target_alias = resolved.with_name(
f".{resolved.name}-{HF_MODEL_REVISION[:12]}.audiocpp.gguf"
)
try:
return _link(target_alias)
except OSError as target_exc:
exc = target_exc
raise RuntimeError(
"audio.cpp cannot materialize the Hugging Face cache symlink as "
f"a .gguf hard link: {exc}"
) from exc
def resolve_model_file() -> Path:
"""Resolve an explicitly installed Breeze-TTS-2 GGUF file.
An explicit ``OMNIVOICE_AUDIOCPP_MODEL`` path wins (file or directory
containing the package file). Otherwise only the local Hugging Face cache
is inspected. Downloads must be started explicitly from Model Catalogue
Models, so generation can never silently transfer the 4.73 GiB package.
"""
override = os.environ.get("OMNIVOICE_AUDIOCPP_MODEL", "").strip()
if override:
cand = Path(override)
if cand.is_file():
return _materialize_gguf_cache_path(cand)
if cand.is_dir():
inner = cand / package_filename()
if inner.is_file():
return _materialize_gguf_cache_path(inner)
raise RuntimeError(
f"OMNIVOICE_AUDIOCPP_MODEL={override} is not a GGUF file or a "
"directory containing one."
)
from huggingface_hub import snapshot_download
from huggingface_hub.utils import LocalEntryNotFoundError
try:
cached = Path(
snapshot_download(
repo_id=HF_MODEL_REPO,
# Full immutable commit SHA declared above; Bandit cannot follow
# the module constant through this call.
revision=HF_MODEL_REVISION, # nosec B615
allow_patterns=[f"{PACKAGE_DIR}/{package_filename()}"],
local_files_only=True,
)
)
except (LocalEntryNotFoundError, OSError) as exc:
raise RuntimeError(
"Breeze-TTS-2 is not installed. Install the audio.cpp Breeze-TTS-2 "
"model from Model Catalogue → Models, or set "
"OMNIVOICE_AUDIOCPP_MODEL to an existing GGUF file."
) from exc
model_file = cached / PACKAGE_DIR / package_filename()
if not model_file.is_file():
raise RuntimeError(
f"Breeze-TTS-2 package {package_filename()} is not completely "
"installed. Reinstall it from Model Catalogue → Models."
)
return _materialize_gguf_cache_path(model_file)
__all__ = [
"AudioCPPDevice",
"AudioCPPSelection",
"BACKEND_ENV",
"BIN_ENV",
"DEFAULT_PACKAGE",
"DEFAULT_PORT",
"DEVICE_ENV",
"DIR_ENV",
"FAMILY",
"HF_MODEL_REPO",
"HF_MODEL_REVISION",
"MODEL_ID",
"PACKAGE_DIR",
"PACKAGE_ENV",
"PORT_ENV",
"VERSION",
"_materialize_gguf_cache_path",
"binary_name",
"default_asset",
"invalidate",
"is_installed",
"package_filename",
"parse_device_list",
"probe_devices",
"resolve_compute_selection",
"resolve_model_file",
"resolve_server_binary",
"runtime_targets",
"server_port",
]
+4 -4
View File
@@ -56,15 +56,15 @@ class Confucius4Backend(SubprocessBackend):
id = "confucius4-tts"
display_name = (
"Confucius4-TTS (LLM, 14 langs, cross-lingual zero-shot clone, CUDA/CPU, Apache-2.0)"
"Confucius4-TTS (LLM, 14 langs, cross-lingual zero-shot clone, Apache-2.0)"
)
supports_voice_design = False # timbre comes from a reference clip
# Upstream vocoder rate (config target_sample_rate) — confirmed 22 050 Hz by
# a live run (2026-07-02); still re-read from the sidecar's ready/audio frames.
_DEFAULT_SAMPLE_RATE = 22050
# CUDA fast path + CPU fallback, both exercised (CPU end-to-end validated).
# No MPS claim — upstream has no Metal path.
gpu_compat = ("cuda", "cpu")
# Match device propagation into upstream .to(device). XPU/NPU routing is
# contract-tested, not a claim of physical-hardware synthesis validation.
gpu_compat = ("cuda", "rocm", "xpu", "npu", "cpu")
@classmethod
def is_available(cls) -> tuple[bool, str]:
+13 -2
View File
@@ -104,7 +104,7 @@ def _ensure_clone_on_sys_path() -> None:
def _load_model(stdout):
"""Cold-construct the Confucius4 model (CUDA, else CPU — both validated)."""
"""Cold-construct using an available torch accelerator, with CPU fallback."""
global _model
if _model is not None:
return _model
@@ -115,7 +115,18 @@ def _load_model(stdout):
import torch
from confuciustts.cli.inference import ConfuciusTTS # type: ignore[import-not-found]
device = "cuda" if torch.cuda.is_available() else "cpu"
try:
# Existing manually provisioned venvs may predate torch.accelerator.
current_accelerator = getattr(getattr(torch, "accelerator", None), "current_accelerator", None)
if current_accelerator is None:
device = torch.device("cuda") if torch.cuda.is_available() else None
else:
device = current_accelerator(check_available=True)
device = device.type if device is not None else "cpu" # 'cuda', 'npu', 'mps', 'xpu', 'cpu'
except Exception:
device = "cpu" # Broken accelerator drivers must not block CPU loading.
if device == "mps":
device = "cpu" # MPS was slower than CPU in the existing validation run
_send(stdout, {"op": "progress", "stage": "loading_model", "percent": 50})
_model = ConfuciusTTS(config_path=_config_path(), device=device)
+6 -1
View File
@@ -115,7 +115,12 @@ def _load_runtime(stdout):
from dots_tts.runtime import DotsTtsRuntime # type: ignore[import-not-found]
repo = os.environ.get("OMNIVOICE_DOTS_TTS_MODEL", _DEFAULT_REPO)
default_precision = "bfloat16" if torch.cuda.is_available() else "float32"
# Match DotsTtsRuntime's own CUDA/CPU selection. Its _check_torch_env
# rejects half precision without CUDA, even when an XPU/NPU is available.
try:
default_precision = "bfloat16" if torch.cuda.is_available() else "float32"
except Exception:
default_precision = "float32" # Probe failure must not force half precision.
precision = os.environ.get("OMNIVOICE_DOTS_TTS_PRECISION", default_precision)
optimize = os.environ.get("OMNIVOICE_DOTS_TTS_OPTIMIZE", "0") == "1"
+11 -15
View File
@@ -29,15 +29,11 @@ Do NOT import ``main.py`` from the parent process — it runs under a
different venv (``transformers==5.0.0``) and importing it in-process would
re-introduce the exact conflict this isolation exists to avoid.
Hardware honesty (cross-platform rule): MOSS-TTS-v1.5's upstream documents
only CUDA and CPU. There is **no documented or tested MPS path** the
custom ``trust_remote_code`` modelling code and the separate audio
tokenizer are unverified on Apple Silicon. We therefore advertise
``gpu_compat = ("cuda", "cpu")`` and the sidecar selects ``cuda`` when
present else ``cpu`` it never silently routes to MPS where it might
crash. On Apple Silicon the engine honestly resolves to CPU (slow but
correct), and the engine is opt-in regardless, so it never becomes a
broken default on any platform.
Hardware routing follows the sidecar's runtime-available PyTorch accelerator:
CUDA/ROCm, XPU, or a registered NPU. MPS remains excluded; CPU is the fallback.
XPU/NPU routing is covered with mocked device contracts, not physical-hardware
synthesis certification; users need a compatible torch/vendor runtime in the
isolated engine venv.
"""
from __future__ import annotations
@@ -85,13 +81,13 @@ class MossTTSV15Backend(SubprocessBackend):
id = "moss-tts-v15"
display_name = (
"MOSS-TTS-v1.5 (8B, 31 langs, zero-shot clone, CUDA/CPU, Apache-2.0)"
"MOSS-TTS-v1.5 (8B, 31 langs, zero-shot clone, Apache-2.0)"
)
supports_voice_design = False # requires ref audio for timbre cloning
_DEFAULT_SAMPLE_RATE = 24000
# Honest hardware surface: upstream documents CUDA + CPU only. MPS is
# undocumented / untested, so we do NOT claim it (cross-platform rule).
gpu_compat = ("cuda", "cpu")
# Accelerator routing requires its matching runtime in the isolated venv.
# MPS remains untested and is deliberately excluded.
gpu_compat = ("cuda", "rocm", "xpu", "npu", "cpu")
# ── availability ───────────────────────────────────────────────────────
@@ -111,7 +107,7 @@ class MossTTSV15Backend(SubprocessBackend):
return False, (
"MOSS-TTS-v1.5 venv not found. Set OMNIVOICE_MOSS_TTS_V15_DIR "
"to your MOSS-TTS clone (the directory containing pyproject.toml) "
"and restart VoiceStudio. CUDA or CPU only (no MPS). See "
"and restart VoiceStudio. Install the matching PyTorch runtime. See "
"docs/engines/moss-tts-v15.md for the full install walk-through."
)
if not MOSS_TTS_V15_SIDECAR_SCRIPT.exists():
@@ -119,7 +115,7 @@ class MossTTSV15Backend(SubprocessBackend):
"MOSS-TTS-v1.5 sidecar script missing at "
f"{MOSS_TTS_V15_SIDECAR_SCRIPT} — reinstall VoiceStudio."
)
return True, "ok (CUDA when present, else CPU)"
return True, "ok (runtime-available accelerator or CPU; no MPS)"
@classmethod
def venv_python(cls):
+11 -5
View File
@@ -222,8 +222,7 @@ def _bootstrap_engines_venv(clone_dir: Path) -> Path:
Runs ``uv venv <engines_venv>`` then ``uv pip install --python
<engines_venv>/bin/python -e "<clone>[torch-runtime]"``. Verifies the
result by re-probing the import a successful uv invocation that still
can't import the stack indicates a deeper environment problem (e.g. the
``+cu128`` torch-runtime extra can't resolve on a non-CUDA host) and we
can't import the stack indicates a deeper environment problem, and we
raise with whatever stderr we captured plus a docs pointer.
"""
uv = _locate_uv()
@@ -254,6 +253,8 @@ def _bootstrap_engines_venv(clone_dir: Path) -> Path:
f"{exc.stderr.decode('utf-8', errors='replace') if exc.stderr else exc}"
) from exc
from core.torch_indexes import UV_PIP_CU128_ARGS
python_path = _venv_python_path(_ENGINES_VENV_DIR)
try:
subprocess.run(
@@ -261,6 +262,10 @@ def _bootstrap_engines_venv(clone_dir: Path) -> Path:
uv, "pip", "install",
"--python", str(python_path),
"-e", f"{clone_dir}[torch-runtime]",
# The extra pins torch==2.9.1+cu128, which exists only on
# PyTorch's index — without it this could never resolve, on
# any host (core.torch_indexes).
*UV_PIP_CU128_ARGS,
],
check=True,
timeout=_UV_PIP_INSTALL_TIMEOUT_S,
@@ -270,9 +275,10 @@ def _bootstrap_engines_venv(clone_dir: Path) -> Path:
except subprocess.CalledProcessError as exc:
raise RuntimeError(
"uv pip install -e failed during MOSS-TTS-v1.5 bootstrap "
f"({clone_dir}). On a non-CUDA host the upstream '[torch-runtime]' "
"extra (cu128) cannot resolve — set up the venv manually per "
"docs/engines/moss-tts-v15.md. Error: "
# uv's own error names what failed; the PyTorch index is always
# supplied now, so a guess about the host would only mislead.
f"({clone_dir}). See docs/engines/moss-tts-v15.md for the manual "
"install. Error: "
f"{exc.stderr.decode('utf-8', errors='replace') if exc.stderr else exc}"
) from exc
+22 -7
View File
@@ -138,11 +138,12 @@ _state = None
def _load_model(stdout):
"""Cold-construct the MOSS-TTS-v1.5 processor + model.
Device selection is CUDA-or-CPU only MOSS's upstream documents no MPS
path and the custom ``trust_remote_code`` modelling code is untested on
Apple Silicon, so we never route to MPS where it might crash. dtype is
bf16 on CUDA, fp32 on CPU (bf16 CPU ops are spotty). Emits progress
frames so the parent can surface the multi-GB cold-load latency.
Device selection uses the torch.accelerator API to support any backend
(CUDA, NPU, XPU, etc.) automatically. MPS is excluded MOSS's upstream
``trust_remote_code`` modelling code is untested on Apple Silicon. dtype is
bf16 on GPU-class accelerators, fp32 on CPU (bf16 CPU ops are spotty).
Emits progress frames so the parent can surface the multi-GB cold-load
latency.
"""
global _state
if _state is not None:
@@ -154,8 +155,22 @@ def _load_model(stdout):
from transformers import AutoModel, AutoProcessor
repo, revision = _model_source()
device = "cuda" if torch.cuda.is_available() else "cpu"
dtype = torch.bfloat16 if device == "cuda" else torch.float32
# current_accelerator() returns None on CPU-only builds (no accelerator
# compiled in) or when no accelerator is available; fall back to "cpu".
# Existing manually provisioned venvs may predate torch.accelerator.
current_accelerator = getattr(getattr(torch, "accelerator", None), "current_accelerator", None)
try:
if current_accelerator is None:
accel = torch.device("cuda") if torch.cuda.is_available() else None
else:
accel = current_accelerator(check_available=True)
except Exception:
# Optional drivers can fail during probing; CPU loading remains usable.
accel = None
device = accel.type if accel is not None else "cpu" # 'cuda', 'npu', 'mps', 'xpu', 'cpu'
if device == "mps":
device = "cpu" # MOSS is untested on MPS; fall back to CPU for safety
dtype = torch.bfloat16 if device != "cpu" else torch.float32
# "sdpa" works on CUDA + CPU and needs no extra dep. flash_attention_2
# (Ampere+ CUDA, optional flash-attn) is opt-in via env.
attn = os.environ.get("OMNIVOICE_MOSS_TTS_V15_ATTN", "sdpa")
+24 -14
View File
@@ -48,6 +48,15 @@ from services.subprocess_backend import SubprocessBackend
logger = logging.getLogger("omnivoice.engines.pockettts")
_VENV_ENV_VAR = "OMNIVOICE_POCKETTTS_DIR"
def _own_venv_python() -> "Path | None":
"""The venv the one-click installer made for this engine, if any."""
from services.sidecar_install import engine_venv_python
return engine_venv_python(_VENV_ENV_VAR)
if TYPE_CHECKING:
import torch # noqa: F401
@@ -121,16 +130,17 @@ class PocketTTSBackend(SubprocessBackend):
def is_available(cls) -> tuple[bool, str]:
if platform_error := cls._platform_error():
return False, platform_error
# Optional-dep gate: the pocket-tts wheel is installed only when the user
# opted in. The interpreter is the parent's own (sys.executable), so
# there is no separate venv to validate.
try:
import pocket_tts # type: ignore[import-not-found] # noqa: F401
except Exception as e:
return False, (
f"pocket_tts package not installed or failed to import ({e}). "
f"Enable in Settings -> Engines (uv sync --extra pockettts)."
)
# Installed either into its own venv by the one-click installer, which
# verified `import pocket_tts` there before saving the path, or into the
# app's environment by `uv sync --extra pockettts`.
if _own_venv_python() is None:
try:
import pocket_tts # type: ignore[import-not-found] # noqa: F401
except Exception as e:
return False, (
f"pocket_tts package not installed or failed to import ({e}). "
"Install it from Model Catalogue → Engines."
)
# The model repository has an additional gated-access agreement and
# prohibited-use conditions beyond its CC-BY-4.0 license. Keep first
@@ -145,10 +155,10 @@ class PocketTTSBackend(SubprocessBackend):
@classmethod
def venv_python(cls) -> Path:
# Parent interpreter: pocket-tts deps (torch>=2.5, scipy, beartype) sit
# happily at the parent's pins, so this isolates for crash recovery, not
# dependency pins (same rationale as omnivoice-subprocess).
return Path(sys.executable)
# Its own venv when the one-click installer made one. Otherwise the
# parent interpreter, where `uv sync --extra pockettts` installs it
# (its deps sit happily at the parent's pins).
return _own_venv_python() or Path(sys.executable)
@classmethod
def sidecar_script(cls) -> Path:
+23 -12
View File
@@ -48,6 +48,15 @@ if TYPE_CHECKING:
logger = logging.getLogger("omnivoice.supertonic3")
_VENV_ENV_VAR = "OMNIVOICE_SUPERTONIC3_DIR"
def _own_venv_python() -> "Path | None":
"""The venv the one-click installer made for this engine, if any."""
from services.sidecar_install import engine_venv_python
return engine_venv_python(_VENV_ENV_VAR)
# Absolute path to the sidecar script ‑‑ same pattern as IndexTTS's
# ``INDEXTTS_SIDECAR_SCRIPT``. SubprocessBackend spawns it with the
@@ -80,11 +89,11 @@ class Supertonic3Backend(SubprocessBackend):
@classmethod
def venv_python(cls) -> Path:
"""Supertonic-3 lives in the main OmniVoice venv ‑‑ no dedicated
venv. ``sys.executable`` is the parent interpreter, which is the
same Python that ``uv sync --extra supertonic`` populated.
"""Its own venv when the one-click installer made one. Otherwise the
parent interpreter, the same Python ``uv sync --extra supertonic``
populated.
"""
return Path(sys.executable)
return _own_venv_python() or Path(sys.executable)
@classmethod
def sidecar_script(cls) -> Path:
@@ -96,14 +105,16 @@ class Supertonic3Backend(SubprocessBackend):
def is_available(cls) -> tuple[bool, str]:
# 1. Optional-dep gate (TTS-02). The ``supertonic`` wheel is only
# installed when the user opted in via ``--extra supertonic``.
try:
import supertonic # type: ignore[import-not-found] # noqa: F401
except ImportError:
return False, (
"supertonic package not installed. Enable in "
"Model Catalogue → Engines (installs `supertonic` via `uv add --optional "
"supertonic supertonic==1.3.1`)."
)
# Its own venv (made by the one-click installer, which verified the
# import there) or the app's environment (`uv sync --extra`).
if _own_venv_python() is None:
try:
import supertonic # type: ignore[import-not-found] # noqa: F401
except ImportError:
return False, (
"supertonic package not installed. Install it from "
"Model Catalogue → Engines."
)
# 2. License acceptance gate (TTS-05). Defence in depth: the
# settings_store helper handles the read; we just refuse
+11 -3
View File
@@ -137,9 +137,17 @@ def _resolve_pinned_sha() -> str:
# Final fallback ‑‑ relative import for when the file is invoked
# via ``python backend/engines/supertonic3/sidecar.py`` rather
# than via ``python -m backend.engines.supertonic3.sidecar``.
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
from engines.supertonic3.constants import PINNED_REVISION_SHA # type: ignore[import-not-found]
return PINNED_REVISION_SHA
# Load constants.py by path. Importing it as `engines.supertonic3…`
# runs the package __init__, which imports the app's backend, and that
# is absent from the engine's own venv (one-click install).
import importlib.util
spec = importlib.util.spec_from_file_location(
"_supertonic3_constants", Path(__file__).resolve().with_name("constants.py"),
)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module) # type: ignore[union-attr]
return module.PINNED_REVISION_SHA
# ── model loading (lazy, on first synthesize) ─────────────────────────────
+52 -15
View File
@@ -585,13 +585,14 @@ def _phase_a_build_inner() -> None:
pass # never block startup on the migration; it retries next launch
# Restore persisted env vars from prefs.json (Settings UI writes them
# there so they survive backend restarts) — before any user code reads
# os.environ, and never overriding an explicitly-set env var.
# os.environ, and never overriding an explicitly-set env var. Also
# snapshots which keys an external source (shell, `.env`, Docker, …)
# already provided, so a Settings control can tell the user their saved
# value is being shadowed instead of silently promising it will apply
# (core.prefs.is_env_shadowed — #1787 review fix).
try:
from core.prefs import _load as _load_all_prefs
_prefs = _load_all_prefs()
for _k, _v in _prefs.items():
if _k.startswith("env.") and _v:
os.environ.setdefault(_k[len("env."):], str(_v))
from core.prefs import _load as _load_all_prefs, restore_env
restore_env(_load_all_prefs())
except Exception:
pass # prefs.json missing or broken — fine on first run
# yt-dlp user-update overlay: must run before anything imports yt_dlp so
@@ -623,7 +624,19 @@ def _phase_a_build_inner() -> None:
_startup_progress.begin_step("ml_imports")
import torchaudio
warnings.filterwarnings("ignore", category=UserWarning)
torchaudio.set_audio_backend("soundfile")
# torchaudio 2.9 REMOVED set_audio_backend(); soundfile has been the only
# backend since 2.0, so the call was already a no-op there and is simply
# absent now. Unguarded it raises AttributeError inside `ml_imports`, and a
# failure in that phase takes the whole backend down — the desktop app sits
# on "starting backend" forever and /health stays 503.
#
# That is not a hypothetical version: RTX 50-series (Blackwell, sm_120)
# users have no choice but to move off the pinned torch 2.8.0, which has no
# sm_120 kernels, and the torch 2.9.x they land on brings torchaudio 2.9
# with it. So the one group forced to upgrade hit a hard startup crash for
# a line that does nothing (#1931).
if hasattr(torchaudio, "set_audio_backend"):
torchaudio.set_audio_backend("soundfile")
from utils import hf_progress
# HF tqdm patch before any library import that can trigger
# hf_hub_download (transformers, mlx_whisper, …).
@@ -685,11 +698,12 @@ def _phase_a_build_inner() -> None:
settings as settings_router, # Phase 1 AUTH-03: HF token save/clear/state
media_tools as media_tools_router, # Audio tools: ffmpeg/ffprobe/yt-dlp
auth as auth_router,
voice_convert, # Studio Convert: speech-to-speech via ASR → TTS
)
from api.routers import mcp_bindings as _mcp_bindings_router # noqa: E402
from api.routers import workers as workers_router # noqa: E402
_router_modules.extend([
system, profiles, exports, generation, dub_core, dub_generate,
system, profiles, exports, generation, voice_convert, dub_core, dub_generate,
dub_export, dub_translate, projects, glossary, engines, tools,
stories, setup, gallery, archetypes, describe_voice, community,
batch, watermark, events, capture, capture_ws, speech_platform, dictation,
@@ -1078,6 +1092,33 @@ async def lifespan(app: FastAPI):
app.state.startup_task = asyncio.create_task(_deferred_startup(app))
yield
# ── Graceful shutdown (SIGTERM from Tauri, Ctrl+C, etc.) ────────────
# Retire the run sentinel FIRST, before any bounded wait below (#1895):
# once uvicorn has begun graceful shutdown the exit is deliberate by
# definition, so the sentinel has already done its job. This is one
# os.remove, against a ~50s worst-case tail of bounded waits plus model
# unload / free_vram() / gc.collect() below. Measured on macOS: a normal
# shutdown takes 5.25s end to end, while the desktop shell allows 2s
# (bootstrap.rs terminate_process_tree) before SIGKILL — so the old
# placement at the very end was killed every time on any run that had
# reached a working state. Doing the deadline-sensitive step first makes
# correctness independent of how much of that tail runs, instead of
# depending on the shell-side deadline being long enough to cover it.
#
# SCOPE, explicitly: this only helps platforms where lifespan teardown
# actually BEGINS. On Windows it does not — tools.rs terminates the job
# object with no graceful phase at all, so this line is never reached and
# a deliberate quit is still misreported as a crash there. That needs the
# shell to signal deliberate intent before the hard kill, which is a
# separate Rust-side change and is tracked separately; nothing here
# should be read as fixing Windows.
#
# sentinel_cleared feeds the truthful "Shutdown: done."/degraded log at
# the end of this function; nothing below re-clears the sentinel, so a
# later failure can't mask this result.
try:
sentinel_cleared = run_sentinel.clear_sentinel()
except Exception:
sentinel_cleared = False
# May run after a startup that never finished (SIGTERM mid-Phase-A/B), so
# every handle is read from app.state with a None default and every
# deferred-phase name is guarded.
@@ -1204,13 +1245,9 @@ async def lifespan(app: FastAPI):
await close_http_client()
except Exception:
pass
# Last thing on a clean shutdown: retire the run sentinel so the next
# startup doesn't misread this exit as a crash (#1164). If clearing fails,
# retain the sentinel and report a degraded shutdown truthfully.
try:
sentinel_cleared = run_sentinel.clear_sentinel()
except Exception:
sentinel_cleared = False
# Sentinel was already retired at the TOP of this block (#1895) — report
# truthfully using that result rather than clearing (or re-checking) it
# again here, so a failure in the steps above can't mask it as "done."
if sentinel_cleared:
logger.info("Shutdown: done.")
else:
+297 -37
View File
@@ -7,8 +7,8 @@ Run standalone:
Tools exposed:
generate_speech text WAV audio (voice clone or design)
clone_voice base64 reference audio new voice profile
transcribe base64 audio text
clone_voice reference audio (base64, or a file path) new voice profile
transcribe audio (base64, or a file path) text
list_voices enumerate saved voice profiles
list_languages available TTS languages
list_personalities voice personality presets
@@ -17,6 +17,18 @@ Tools exposed:
Resources exposed:
voice://{profile_id} voice profile metadata
history://recent last 20 generated audio items
Output mode (OMNIVOICE_MCP_OUTPUT_MODE):
resources generate_speech returns the WAV as base64 inline (the original
contract; default)
files it returns a URL to the render (and, with a base path, a WAV
written there); nothing large ever enters the agent's context
both both of the above
File inputs (OMNIVOICE_MCP_BASE_PATH):
One directory that agents may read audio from (transcribe / clone_voice
`*_path` arguments) and receive files in (files mode). It is the security
boundary: with no base path configured, path-shaped inputs are refused.
"""
from __future__ import annotations
@@ -25,6 +37,8 @@ import base64
import json
import logging
import os
import re
import stat
import sys
logger = logging.getLogger("omnivoice.mcp")
@@ -69,6 +83,244 @@ def _sniff_audio_ext(raw: bytes) -> str:
return ".wav"
# ── Output mode + the base path boundary ─────────────────────────────────
# An LLM agent that receives a WAV as base64 pays for every byte in context:
# a 1.4 s clip already brushes per-result token caps, and a paragraph of
# narration blows them outright. The ElevenLabs MCP settled this with an
# OUTPUT_MODE (files / resources / both) and a BASE_PATH that doubles as the
# security boundary for file-shaped inputs; the same two knobs here, named in
# the OMNIVOICE_* family the rest of the server reads.
_OUTPUT_MODES = ("resources", "files", "both")
_MAX_INPUT_BYTES = 200 * 1024 * 1024
_SAFE_AUDIO_ID = re.compile(r"^[A-Za-z0-9_-]{1,64}$")
def _output_mode() -> str:
"""How generate_speech hands audio back (OMNIVOICE_MCP_OUTPUT_MODE).
'resources' is the original base64-inline contract and stays the default
so existing integrations see no change; 'files' returns a URL to the
render (plus a WAV under the base path when one is configured); 'both'
returns everything. Anything unrecognized falls back to 'resources' with
a warning rather than failing the tool."""
mode = os.environ.get("OMNIVOICE_MCP_OUTPUT_MODE", "resources").strip().lower()
if mode not in _OUTPUT_MODES:
logger.warning(
"OMNIVOICE_MCP_OUTPUT_MODE=%r is not one of %s; using 'resources'",
mode, _OUTPUT_MODES,
)
return "resources"
return mode
def _base_path() -> "str | None":
"""The one directory agents may read audio from and receive files in
(OMNIVOICE_MCP_BASE_PATH), realpath'd; None when unset."""
raw = os.environ.get("OMNIVOICE_MCP_BASE_PATH", "").strip()
if not raw:
return None
return os.path.realpath(os.path.expanduser(raw))
def _resolve_under_base(path: str) -> str:
"""Absolute realpath of ``path`` when it lies inside the base path.
Relative paths resolve against the base; absolute paths must already be
inside it. Both sides are realpath'd, so a symlink pointing outward cannot
smuggle a read in. Raises ValueError with an agent-legible reason when no
base path is configured or the path escapes it."""
base = _base_path()
if base is None:
raise ValueError(
"OMNIVOICE_MCP_BASE_PATH is not set; file paths are refused until it "
"names a directory"
)
candidate = os.path.realpath(os.path.join(base, os.path.expanduser(path)))
if not _path_is_under_base(base, candidate):
raise ValueError(f"{path!r} resolves outside OMNIVOICE_MCP_BASE_PATH")
return candidate
def _opened_file_is_confined(fd: int, resolved: str, base: str) -> bool:
"""Verify that an opened descriptor still names a file under ``base``."""
proc_fd = f"/proc/self/fd/{fd}"
if os.path.exists(proc_fd):
return _path_is_under_base(base, os.path.realpath(proc_fd))
try:
current = os.path.realpath(resolved)
return _path_is_under_base(base, current) and os.path.samestat(
os.fstat(fd), os.stat(current, follow_symlinks=False)
)
except OSError:
return False
def _path_is_under_base(base: str, candidate: str) -> bool:
try:
common = os.path.commonpath([base, candidate])
except ValueError: # different drives on Windows
return False
return os.path.normcase(common) == os.path.normcase(base)
def _open_under_base(path: str, flags: int, *, mode: int = 0o600) -> tuple[int, str]:
"""Open ``path`` without following a component replaced after validation."""
base = _base_path()
if base is None:
raise ValueError(
"OMNIVOICE_MCP_BASE_PATH is not set; file paths are refused until it "
"names a directory"
)
resolved = _resolve_under_base(path)
relative = os.path.relpath(resolved, base)
parts = [part for part in relative.split(os.sep) if part not in ("", ".")]
if not parts or parts[0] == os.pardir:
raise ValueError(f"{path!r} resolves outside OMNIVOICE_MCP_BASE_PATH")
no_follow = getattr(os, "O_NOFOLLOW", 0)
close_on_exec = getattr(os, "O_CLOEXEC", 0)
binary = getattr(os, "O_BINARY", 0)
file_flags = flags | no_follow | close_on_exec | binary
supports_dir_fd = os.open in getattr(os, "supports_dir_fd", ())
directory_flag = getattr(os, "O_DIRECTORY", 0)
if supports_dir_fd and directory_flag:
directory_flags = os.O_RDONLY | directory_flag | no_follow | close_on_exec
directory_fd = os.open(base, directory_flags)
try:
for component in parts[:-1]:
next_fd = os.open(component, directory_flags, dir_fd=directory_fd)
os.close(directory_fd)
directory_fd = next_fd
fd = os.open(parts[-1], file_flags, mode, dir_fd=directory_fd)
finally:
os.close(directory_fd)
else:
fd = os.open(resolved, file_flags, mode)
if not _opened_file_is_confined(fd, resolved, base):
os.close(fd)
raise ValueError(f"{path!r} resolves outside OMNIVOICE_MCP_BASE_PATH")
return fd, resolved
def _read_input_audio(
audio_base64: "str | None",
audio_path: "str | None",
*,
label: str = "audio_base64",
too_big: str = "audio exceeds 200 MB limit",
) -> "tuple[bytes | None, str | None]":
"""Audio bytes from exactly one of the two input lanes, or (None, error).
The base64 lane keeps its data-URI tolerance and 200 MB cap; the path lane
is honored only inside the base path (the security boundary) and applies
the same cap to the file's size before reading it."""
if bool(audio_base64) == bool(audio_path):
return None, f"pass exactly one of {label} or the matching *_path argument"
if audio_path:
try:
fd, _resolved = _open_under_base(audio_path, os.O_RDONLY)
except ValueError as e:
return None, str(e)
except FileNotFoundError:
return None, f"no such file under OMNIVOICE_MCP_BASE_PATH: {audio_path!r}"
except OSError as e:
return None, f"could not safely read {audio_path!r}: {e}"
with os.fdopen(fd, "rb") as handle:
info = os.fstat(handle.fileno())
if not stat.S_ISREG(info.st_mode):
return None, f"{audio_path!r} is not a regular file"
if info.st_size > _MAX_INPUT_BYTES:
return None, too_big
raw = handle.read(_MAX_INPUT_BYTES + 1)
if len(raw) > _MAX_INPUT_BYTES:
return None, too_big
if not raw:
return None, f"{label} is empty"
return raw, None
encoded = (
audio_base64.split(",", 1)[-1]
if audio_base64.startswith("data:")
else audio_base64
)
max_encoded_bytes = 4 * ((_MAX_INPUT_BYTES + 2) // 3)
if len(encoded) > max_encoded_bytes:
return None, too_big
raw = _decode_ref_audio(audio_base64)
if raw is None:
return None, f"{label} is not valid base64"
if not raw:
return None, f"{label} is empty"
if len(raw) > _MAX_INPUT_BYTES:
return None, too_big
return raw, None
def _write_output(audio_id: str, raw: bytes) -> str:
"""Land a render under the base path as ``<audio_id>.wav``; returns the path."""
if not _SAFE_AUDIO_ID.fullmatch(audio_id):
raise ValueError("backend returned an invalid X-Audio-Id header")
base = _base_path()
os.makedirs(base, exist_ok=True)
filename = f"{audio_id}.wav"
fd, path = _open_under_base(filename, os.O_WRONLY | os.O_CREAT | os.O_EXCL)
with os.fdopen(fd, "wb") as handle:
handle.write(raw)
return path
def _post_timeout_s() -> float:
"""Seconds the tools wait on a backend POST (OMNIVOICE_MCP_TIMEOUT_S,
default 120). A CPU host renders a paragraph in minutes and serializes
generations, so an agent behind another render used to hit the fixed
budget with an empty-message timeout; the knob follows the backend's own
OMNIVOICE_GENERATE_TIMEOUT_S when a deployment raises that."""
raw = os.environ.get("OMNIVOICE_MCP_TIMEOUT_S", "").strip()
try:
value = float(raw) if raw else 120.0
except ValueError:
logger.warning("OMNIVOICE_MCP_TIMEOUT_S=%r is not a number; using 120", raw)
return 120.0
return value if value > 0 else 120.0
def _maybe_number(value):
"""A response-header number as a number, or the raw text (e.g. '?')."""
try:
return float(value)
except (TypeError, ValueError):
return value
def _speech_result(audio_id: str, gen_time, duration, raw: bytes, api_base: str) -> dict:
"""The generate_speech reply shaped by the output mode.
The backend already keeps every render on disk and serves it at
``/audio/<audio_id>.wav``, so files mode costs nothing but a URL - plus one
write when a base path invites the WAV into the agent's own directory."""
if not _SAFE_AUDIO_ID.fullmatch(audio_id):
raise ValueError("backend returned an invalid X-Audio-Id header")
mode = _output_mode()
out = {
"audio_id": audio_id,
"generation_time_s": gen_time,
"audio_duration_s": duration,
"format": "wav",
"output_mode": mode,
}
if mode in ("files", "both"):
out["audio_url"] = f"{api_base.rstrip('/')}/audio/{audio_id}.wav"
if _base_path() is not None:
out["output_path"] = _write_output(audio_id, raw)
else:
out["note"] = "set OMNIVOICE_MCP_BASE_PATH to also receive the WAV as a file"
if mode in ("resources", "both"):
out["wav_base64"] = base64.b64encode(raw).decode("ascii")
return out
# ── Lazy imports — keeps startup fast when not using MCP ────────────────
@@ -147,7 +399,7 @@ def create_mcp_server():
async def _api_post_form(path: str, data: dict, files: dict | None = None):
import httpx
async with httpx.AsyncClient(base_url=_api_base(), timeout=120) as c:
async with httpx.AsyncClient(base_url=_api_base(), timeout=_post_timeout_s()) as c:
r = await c.post(path, data=data, files=files or {})
r.raise_for_status()
return r
@@ -190,8 +442,12 @@ def create_mcp_server():
steps: Diffusion steps (8=fast/draft, 16=balanced, 32=quality).
Returns:
JSON with audio_id, generation_time, audio_duration, and
base64-encoded WAV data.
JSON with audio_id, generation_time_s, audio_duration_s and the
audio itself shaped by OMNIVOICE_MCP_OUTPUT_MODE: base64 WAV data
('resources', the default), a URL to the render plus a WAV under
OMNIVOICE_MCP_BASE_PATH when one is set ('files'), or all of the
above ('both'). Prefer 'files' for LLM agents: nothing large
enters the context.
"""
# Per-agent voice binding (Wave 2.2): explicit arg wins; otherwise
# resolve this client's bound profile, then the global default.
@@ -218,18 +474,10 @@ def create_mcp_server():
r = await _api_post_form("/generate", data=form)
audio_id = r.headers.get("X-Audio-Id", "unknown")
gen_time = r.headers.get("X-Gen-Time", "?")
duration = r.headers.get("X-Audio-Duration", "?")
gen_time = _maybe_number(r.headers.get("X-Gen-Time", "?"))
duration = _maybe_number(r.headers.get("X-Audio-Duration", "?"))
wav_b64 = base64.b64encode(r.content).decode("ascii")
return (
f'{{"audio_id":"{audio_id}",'
f'"generation_time_s":{gen_time},'
f'"audio_duration_s":{duration},'
f'"format":"wav",'
f'"wav_base64":"{wav_b64}"}}'
)
return json.dumps(_speech_result(audio_id, gen_time, duration, r.content, _api_base()))
@mcp.tool()
async def list_voices() -> str:
@@ -266,30 +514,39 @@ def create_mcp_server():
)
@mcp.tool()
async def transcribe(audio_base64: str, language: str | None = None) -> str:
async def transcribe(
audio_base64: str | None = None,
audio_path: str | None = None,
language: str | None = None,
) -> str:
"""Transcribe spoken audio to text.
Pass exactly one of audio_base64 or audio_path.
Args:
audio_base64: Base64-encoded audio bytes (wav/mp3/webm/m4a).
audio_path: Path to an audio file under OMNIVOICE_MCP_BASE_PATH
(relative to it, or absolute inside it). The base path is the
security boundary: with none configured, paths are refused.
Prefer this lane for LLM agents - the audio never enters the
agent's context.
language: Optional language hint; omit for auto-detect.
Returns:
JSON with the recognized text, language, and duration.
"""
try:
raw = base64.b64decode(audio_base64, validate=True)
except Exception:
return '{"error":"audio_base64 is not valid base64"}'
# 200 MB cap — same spirit as voicebox's transcribe gate. Keeps a
# buggy/hostile agent from posting an unbounded blob.
if len(raw) > 200 * 1024 * 1024:
return '{"error":"audio exceeds 200 MB limit"}'
# 200 MB cap on both lanes — same spirit as voicebox's transcribe
# gate. Keeps a buggy/hostile agent from posting an unbounded blob.
raw, err = _read_input_audio(audio_base64, audio_path)
if err:
return json.dumps({"error": err})
data = {}
if language:
data["language"] = language
r = await _api_post_form(
"/transcribe", data=data,
files={"audio": ("audio.wav", raw, "application/octet-stream")},
files={"audio": (f"audio{_sniff_audio_ext(raw)}", raw,
"application/octet-stream")},
)
return str(r.json())
@@ -319,15 +576,17 @@ def create_mcp_server():
@mcp.tool()
async def clone_voice(
name: str,
ref_audio_base64: str,
ref_audio_base64: str | None = None,
ref_text: str = "",
instruct: str = "",
language: str = "Auto",
ref_audio_path: str | None = None,
) -> str:
"""Clone a new voice profile from a reference audio sample.
The new voice is immediately available for use with generate_speech
(pass the returned profile_id as the profile_id argument).
(pass the returned profile_id as the profile_id argument). Pass
exactly one of ref_audio_base64 or ref_audio_path.
Args:
name: A human-friendly name for the cloned voice.
@@ -338,19 +597,20 @@ def create_mcp_server():
quality for some engines).
instruct: Optional style instruction (e.g. 'whisper', 'excited').
language: Language of the reference audio (ISO code or 'Auto').
ref_audio_path: Path to the reference audio under
OMNIVOICE_MCP_BASE_PATH (relative to it, or absolute inside
it); refused when no base path is configured. Prefer this
lane for LLM agents - the clip never enters the context.
Returns:
JSON with the new profile's id, name, and kind.
"""
# Reject oversized inputs before decoding (base64 is always larger
# than raw, so this is a safe lower bound on the decoded size).
if len(ref_audio_base64) > 200 * 1024 * 1024:
return '{"error":"reference audio exceeds 200 MB limit"}'
raw = _decode_ref_audio(ref_audio_base64)
if raw is None:
return '{"error":"ref_audio_base64 is not valid base64"}'
if not raw:
return '{"error":"ref_audio_base64 is empty"}'
raw, err = _read_input_audio(
ref_audio_base64, ref_audio_path,
label="ref_audio_base64", too_big="reference audio exceeds 200 MB limit",
)
if err:
return json.dumps({"error": err})
import httpx
try:
r = await _api_post_form(
@@ -0,0 +1,18 @@
"""Retain the dispatch-time deadline policy across worker/control-plane loss."""
from alembic import op
import sqlalchemy as sa
revision = "0011_remote_attempt_deadlines"
down_revision = "0010_remote_worker_schema"
branch_labels = None
depends_on = None
def upgrade() -> None:
columns = op.get_bind().execute(sa.text("PRAGMA table_info(remote_task_attempts)"))
if not any(row[1] == "deadlines_json" for row in columns):
op.add_column("remote_task_attempts", sa.Column("deadlines_json", sa.Text(), nullable=True))
def downgrade() -> None:
op.drop_column("remote_task_attempts", "deadlines_json")
+4 -1
View File
@@ -33,8 +33,11 @@ WS_TICKET_PREFIX = "ovs_ws_ticket_"
_TOKEN_BYTES = 32
_ENCODED_TOKEN_LENGTH = 43
_TOKEN_BODY_RE = re.compile(rf"^[A-Za-z0-9_-]{{{_ENCODED_TOKEN_LENGTH}}}$")
# Every ticketed WebSocket route. The first-party mirror is ``ALLOWED_WS_PATHS``
# in frontend/src/api/authSession.ts — a route missing here mints a 422 and the
# UI consumer fails silently (#1769 added /ws/tts for the live dub preview).
_ALLOWED_WS_PATHS = frozenset(
{"/ws/events", "/ws/transcribe", "/v1/audio/transcriptions/stream"}
{"/ws/events", "/ws/transcribe", "/ws/tts", "/v1/audio/transcriptions/stream"}
)
_ADMIN_CAPABILITIES = frozenset({"consume", "admin"})
_KEY_GENERATION_INFO = b"omnivoice-admin-key-generation-v1"
+145 -19
View File
@@ -24,6 +24,7 @@ faster-whisper because it's available on every platform we ship to).
from __future__ import annotations
import asyncio
import ipaddress
import logging
import os
import re
@@ -31,6 +32,7 @@ import contextlib
import threading
import time
import weakref
from urllib.parse import urlsplit
from utils.containment import contain_system_exit
from abc import ABC, abstractmethod
@@ -147,25 +149,78 @@ def _isolated_engine_hint(streak: int) -> str:
async def run_transcribe_guarded(executor, fn, *, what: str = "ASR",
timeout: float = ASR_TRANSCRIBE_TIMEOUT_S,
timeout_env: str = "OMNIVOICE_ASR_TRANSCRIBE_TIMEOUT_S",
reset_on_timeout: bool = False):
reset_on_timeout: bool = False,
on_abandon=None):
"""Run a blocking transcribe ``fn`` in ``executor`` with a hard wall-clock
bound. On timeout, raise :class:`ASRTimeoutError` with guidance instead of
letting the request hang forever.
``run_in_executor`` cannot cancel the underlying thread, so a timed-out
A future cannot cancel the underlying thread, so a timed-out
in-process CTranslate2/whisperx call still owns its model and device. The
default deliberately leaves that worker accounted for: swapping in a fresh
pool and immediately retrying the same backend overlaps two native calls,
which produced the Windows access violation in #1669. A caller backed by a
genuinely killable process may opt into ``reset_on_timeout``.
``on_abandon`` is called once after a timed-out or cancelled worker can no
longer access its inputs. Queued work cancelled before it starts calls it
immediately; running work calls it from the worker finalizer. Normal
completion leaves cleanup with the caller.
"""
loop = asyncio.get_running_loop()
# Same SystemExit containment as the TTS pool (#1133 class): an ASR
# dependency written as a CLI must not be able to shut the backend down.
fut = loop.run_in_executor(executor, contain_system_exit(fn, what))
inner = contain_system_exit(fn, what)
abandon_lock = threading.Lock()
abandon_state = {
"requested": False,
"finished": False,
"callback_called": False,
}
def _fire_abandon_callback() -> None:
if on_abandon is None:
return
with abandon_lock:
if abandon_state["callback_called"]:
return
abandon_state["callback_called"] = True
try:
on_abandon()
except Exception: # noqa: BLE001 — cleanup cannot hide the ASR result
logger.exception("%s abandon cleanup failed", what)
def _job():
try:
return inner()
finally:
with abandon_lock:
abandon_state["finished"] = True
abandoned = abandon_state["requested"]
if abandoned:
_fire_abandon_callback()
concurrent_fut = executor.submit(_job)
fut = asyncio.wrap_future(concurrent_fut, loop=loop)
def _abandon() -> None:
cancelled_before_start = concurrent_fut.cancel()
with abandon_lock:
abandon_state["requested"] = True
finished = abandon_state["finished"]
fut.cancel()
if cancelled_before_start or finished:
_fire_abandon_callback()
try:
result = await asyncio.wait_for(fut, timeout=timeout)
# Shield the wrapper so timeout does not discard our ability to tell a
# queued cancellation from a native thread that is still running.
result = await asyncio.wait_for(asyncio.shield(fut), timeout=timeout)
except asyncio.CancelledError:
_abandon()
raise
except asyncio.TimeoutError:
_abandon()
if reset_on_timeout:
reset_pool_after_wedge(executor, what=what)
streak = _note_transcribe_timeout()
@@ -1746,9 +1801,7 @@ class SherpaDictationBackend(ASRBackend):
def __init__(self, model_id: str | None = None):
from services import sherpa_dictation as _sd
mid = model_id or os.environ.get(
"OMNIVOICE_SHERPA_ASR_MODEL", _sd.DEFAULT_MODEL_ID
)
mid = model_id or sherpa_engine_model_id()
spec = _sd.get_spec(mid)
if spec is None:
raise ValueError(
@@ -2000,6 +2053,42 @@ _ASR_OPENAI_COMPAT_MODEL_KEY = "asr.openai_compat.model"
_ASR_OPENAI_COMPAT_SECRET_NAME = "asr_openai_compat_key"
def normalize_openai_compat_asr_base_url(value: str) -> str:
"""Normalize a safe ASR endpoint, allowing plain HTTP only on loopback."""
base = (value or "").strip().rstrip("/")
if not base:
return ""
try:
parsed = urlsplit(base)
_ = parsed.port
except (TypeError, ValueError) as exc:
raise ValueError("Invalid OpenAI-compatible ASR base URL") from exc
scheme = parsed.scheme.lower()
if (
scheme not in {"http", "https"}
or not parsed.hostname
or parsed.username is not None
or parsed.password is not None
or parsed.query
or parsed.fragment
):
raise ValueError(
"OpenAI-compatible ASR base URL must be a credential-free HTTP(S) URL"
)
host = parsed.hostname.lower()
loopback = host == "localhost"
if not loopback:
try:
address = ipaddress.ip_address(host)
address = getattr(address, "ipv4_mapped", None) or address
loopback = address.is_loopback
except ValueError:
loopback = False
if scheme == "http" and not loopback:
raise ValueError("Non-loopback OpenAI-compatible ASR endpoints require HTTPS")
return base
def resolve_openai_compat_asr_base_url() -> str:
from services import settings_store
return (
@@ -2063,7 +2152,7 @@ def probe_openai_compat_server(
maps to a translated message:
not_configured no base URL anywhere
invalid_url base URL without an http(s):// scheme
invalid_url malformed URL or non-loopback HTTP endpoint
ok 2xx ``model_found`` says whether the configured
model appears in the server's list (None = unknown)
ok_no_models 404/405/501 reachable, but no /models endpoint
@@ -2078,7 +2167,7 @@ def probe_openai_compat_server(
from core.scrub import scrub_text
base = (base_url if base_url is not None else resolve_openai_compat_asr_base_url()).strip().rstrip("/")
configured_base = base_url if base_url is not None else resolve_openai_compat_asr_base_url()
mdl = (model if model is not None else resolve_openai_compat_asr_model()).strip()
if api_key is None:
key = resolve_openai_compat_asr_api_key()
@@ -2094,9 +2183,11 @@ def probe_openai_compat_server(
"model_found": None,
"detail": None,
}
if not base:
if not configured_base.strip():
return out
if not base.startswith(("http://", "https://")):
try:
base = normalize_openai_compat_asr_base_url(configured_base)
except ValueError:
out["status"] = "invalid_url"
return out
@@ -2107,7 +2198,7 @@ def probe_openai_compat_server(
try:
with httpx.Client(
timeout=httpx.Timeout(timeout_s, connect=min(5.0, timeout_s)),
follow_redirects=True,
follow_redirects=False,
) as client:
resp = client.get(f"{base}/models", headers=headers)
except httpx.TimeoutException as exc:
@@ -2170,13 +2261,20 @@ class OpenAICompatASRBackend(ASRBackend):
gpu_compat = ("cpu",) # network client only — no local compute
def __init__(self):
self._base_url = resolve_openai_compat_asr_base_url()
self._base_url = normalize_openai_compat_asr_base_url(
resolve_openai_compat_asr_base_url()
)
self._model = resolve_openai_compat_asr_model()
@classmethod
def is_available(cls) -> tuple[bool, str]:
if not resolve_openai_compat_asr_base_url():
base_url = resolve_openai_compat_asr_base_url()
if not base_url:
return False, "Configure a server endpoint in Model Catalogue → Engines"
try:
normalize_openai_compat_asr_base_url(base_url)
except ValueError as exc:
return False, str(exc)
try:
import openai # noqa: F401
except ImportError:
@@ -2184,13 +2282,18 @@ class OpenAICompatASRBackend(ASRBackend):
return True, "ready"
def _client(self):
from openai import OpenAI
from openai import DefaultHttpxClient, OpenAI
api_key = resolve_openai_compat_asr_api_key() or "not-needed"
# max_retries=0: mirrors llm_skills.resolve_skill_client — a
# rate-limited/slow server retrying inside the SDK would blow past
# whatever bounded timeout the caller (dub transcribe, dictation)
# expects from a single call.
return OpenAI(base_url=self._base_url, api_key=api_key, max_retries=0)
return OpenAI(
base_url=self._base_url,
api_key=api_key,
max_retries=0,
http_client=DefaultHttpxClient(follow_redirects=False),
)
def transcribe(self, audio_path: str, *, word_timestamps: bool = True) -> dict:
logger.info(
@@ -2942,6 +3045,31 @@ def get_sherpa_dictation_backend(model_id: str) -> "SherpaDictationBackend":
return backend
def sherpa_engine_model_id() -> str:
"""The sherpa model the ``sherpa-onnx-asr`` engine loads when nothing pins
one explicitly: env var (power-user pin) the dictation model the user
picked in Settings / the Engines menu the catalogue default.
Unlike :func:`dictation_model_id` this ignores ``dictation.enabled`` a
user who turned the hotkey off but chose the Sherpa engine for dub/batch
transcription still means *this* model and never returns None: the
engine needs *some* model to construct. A demoted model (decoded nothing
on this host) falls through to the default rather than being re-picked.
"""
from services import sherpa_dictation as _sd
explicit = os.environ.get("OMNIVOICE_SHERPA_ASR_MODEL")
if explicit:
return explicit
try:
from core import prefs
mid = prefs.get("dictation.model_id")
except Exception: # noqa: BLE001 — prefs store unavailable → default
return _sd.DEFAULT_MODEL_ID
if _sd.is_sherpa_model(mid) and not _sd.is_demoted(mid):
return _sd.get_spec(mid).id
return _sd.DEFAULT_MODEL_ID
def dictation_model_id() -> str | None:
"""The selected sherpa dictation model id, or None when dictation is off /
no sherpa model is chosen. Env var wins (power-user pin), then prefs."""
@@ -3216,9 +3344,7 @@ def _offline_asr_repo(backend_id: str | None = None) -> str | None:
# Unknown/none → fail open.
try:
from services import sherpa_dictation as _sd
spec = _sd.get_spec(
os.environ.get("OMNIVOICE_SHERPA_ASR_MODEL", _sd.DEFAULT_MODEL_ID)
)
spec = _sd.get_spec(sherpa_engine_model_id())
return spec.repo_id if spec is not None else None
except Exception: # noqa: BLE001 — preflight must stay best-effort
return None
+1 -1
View File
@@ -65,7 +65,7 @@ _MODE_PREF = "hf_endpoint_mode" # "auto" | "manual"; absent → default
_DECISION_PREF = "hf_endpoint_auto" # cached decision dict (see race())
DECISION_MAX_AGE_S = 7 * 24 * 3600.0 # re-race a decision older than 7 days
PROBE_TIMEOUT_S = 3.0 # short: a probe is not a download
PROBE_TIMEOUT_S = 8.0 # high-latency / China paths often need >3s
MIRROR_SPEEDUP_FACTOR = 3.0 # mirror must be ≥3× faster to win
# Small, stable, long-lived public file for the optional ranged-GET
+10
View File
@@ -33,10 +33,20 @@ _ESTIMATES: dict[str, dict] = {
"destination": "hf_model_cache",
"deduplication": None,
},
"audiocpp": {
"package_download_bytes": None,
"unique_installed_bytes": None,
"potentially_shared_bytes": None,
"temporary_free_bytes": None,
"confidence": "estimated",
"destination": "hf_model_cache",
"deduplication": None,
},
}
_MODEL_REPOS = {
"omnivoice": "k2-fsa/OmniVoice",
"kittentts": "KittenML/kitten-tts-mini-0.8",
"audiocpp": "audio-cpp/audio.cpp-gguf",
}
+23 -3
View File
@@ -88,14 +88,34 @@ def snapshot(
evidence_state = "loaded"
if isolated and provider is None and actual_device is None:
evidence_state = "subprocess_loaded_provider_unreported"
from core.scrub import scrub_text
runtime_device_name = routing.get("runtime_device_name")
device_name = (
getattr(caps, "device_name", "")
if runtime_device_name is None
else runtime_device_name
)
public_device_name = scrub_text(device_name)[:256]
return {
"implementation_variant": f"{engine_cls.__module__}.{engine_cls.__name__}",
"declared_device_families": list(getattr(engine_cls, "gpu_compat", ("cpu",))),
"declared_device_families": list(
routing.get("gpu_compat", getattr(engine_cls, "gpu_compat", ("cpu",)))
),
"evidence_state": evidence_state,
"actual_execution_provider": provider,
"actual_execution_device": actual_device,
"gpu_name": getattr(caps, "device_name", "") or None,
"gpu_architecture": _gpu_architecture(getattr(caps, "family", "cpu")),
"gpu_name": public_device_name or None,
"gpu_architecture": None
if (
routing.get("runtime_hardware_family")
and not routing.get("runtime_device_verified")
)
else _gpu_architecture(
routing.get("runtime_hardware_family")
or getattr(caps, "family", "cpu")
),
"runtime_vram_gb": routing.get("runtime_vram_gb"),
"precision_or_quantization": precision,
"cpu_fallback_reason": runtime_fallback_reason or (routing.get("routing_reason") if fallback else None),
"cpu_fallback_stage": runtime_fallback_stage or ("routing_preflight" if fallback else None),
+92 -19
View File
@@ -14,6 +14,7 @@ carry a home path.
"""
from __future__ import annotations
import asyncio
from typing import Literal, TypedDict
from core.device_caps import (
@@ -31,6 +32,93 @@ class RoutingResult(TypedDict):
routing_reason: str | None # raw, pre-scrub
def runtime_compute_profile(engine_or_cls, caps: HostCaps) -> dict:
"""Return one engine's runtime-aware compute contract.
Native executables may discover providers independently of PyTorch. They
override ``runtime_compute_profile``; all existing engines retain the
exact static routing contract.
"""
hook = getattr(engine_or_cls, "runtime_compute_profile", None)
if callable(hook):
return hook(caps)
cls = engine_or_cls if isinstance(engine_or_cls, type) else type(engine_or_cls)
compat = tuple(getattr(cls, "gpu_compat", ("cpu",)))
floor = float(getattr(cls, "min_vram_gb", 0.0) or 0.0)
return {
"gpu_compat": compat,
"min_vram_gb": floor,
**resolve_routing(compat, caps, floor),
"runtime_backend": None,
"runtime_device_index": None,
"runtime_device_name": None,
"runtime_hardware_family": None,
"runtime_vram_gb": None,
"runtime_device_verified": None,
}
async def runtime_compute_profile_async(engine_or_cls, caps: HostCaps) -> dict:
"""Resolve runtime compute metadata without blocking the event loop."""
return await asyncio.to_thread(runtime_compute_profile, engine_or_cls, caps)
def under_provisioned_vram(
caps: HostCaps,
min_vram_gb: float = 0.0,
*,
family: str | None = None,
vram_gb: float | None = None,
) -> bool:
"""Is this host's DEDICATED VRAM below the engine's declared floor?
The one definition of "under-provisioned", shared by everything that acts
on the verdict: the routing caveat below, the timeout guidance, and since
#1804 — the compute-time budget itself (``model_manager
.generate_timeout_s``). It was written out inline in each of them, which is
how the budget came to disagree with the warning printed next to it.
Dedicated-VRAM families ONLY. CUDA, ROCm, XPU, and a native Vulkan device
report dedicated memory. On MPS, ``HostCaps.vram_gb`` is a heuristic
(system RAM / 2, see device_caps) for a UNIFIED memory pool; comparing it
against a floor measured on discrete CUDA hardware would tell every 8 GB Mac
its 4 GB "VRAM" is too small for an engine that runs fine there. A VRAM
figure of 0 means the probe failed don't guess from it. A floor of 0 means
the engine declares none, and inventing one is worse than staying quiet.
"""
if not min_vram_gb or min_vram_gb <= 0:
return False
if (family or getattr(caps, "family", None)) not in (
"cuda", "rocm", "xpu", "vulkan",
):
return False
raw_vram_gb = getattr(caps, "vram_gb", 0.0) if vram_gb is None else vram_gb
available_vram_gb = float(raw_vram_gb or 0.0)
return 0 < available_vram_gb < float(min_vram_gb)
def low_vram_caveat(
caps: HostCaps,
min_vram_gb: float = 0.0,
*,
family: str | None = None,
vram_gb: float | None = None,
) -> str | None:
"""User-facing advisory for a known under-provisioned dedicated GPU."""
if not under_provisioned_vram(
caps, min_vram_gb, family=family, vram_gb=vram_gb,
):
return None
device = caps.device_name or (family or caps.family).upper()
available_vram_gb = caps.vram_gb if vram_gb is None else vram_gb
return (
f"{device} has {available_vram_gb:.1f} GB VRAM; this engine wants about "
f"{min_vram_gb:.0f} GB. It will run, but expect slow generations "
f"that may time out. Unload other models before generating, keep "
f"the text short, or pick a lighter engine."
)
def _caveat(caps: HostCaps, min_vram_gb: float = 0.0) -> str | None:
"""A caveat string for an otherwise-accelerated host, or None.
@@ -51,24 +139,7 @@ def _caveat(caps: HostCaps, min_vram_gb: float = 0.0) -> str | None:
for note in caps.notes:
if KERNEL_RISK_MARKER in note:
return f"{caps.family.upper()} selected, but: {note}"
# Dedicated-VRAM families ONLY. On MPS, HostCaps.vram_gb is a heuristic
# (system RAM / 2, see device_caps) for a UNIFIED memory pool — comparing
# it against a floor measured on discrete CUDA hardware would tell every
# 8 GB Mac its 4 GB "VRAM" is too small for an engine that runs fine there.
# Different memory model, different (unmeasured) floor; don't guess.
if (
caps.family in ("cuda", "rocm")
and min_vram_gb > 0
and 0 < caps.vram_gb < min_vram_gb
):
device = caps.device_name or caps.family.upper()
return (
f"{device} has {caps.vram_gb:.1f} GB VRAM; this engine wants about "
f"{min_vram_gb:.0f} GB. It will run, but expect slow generations "
f"that may time out. Unload other models before generating, keep "
f"the text short, or pick a lighter engine."
)
return None
return low_vram_caveat(caps, min_vram_gb)
def resolve_routing(
@@ -208,5 +279,7 @@ def routing_fields(
__all__ = [
"RoutingStatus", "RoutingResult", "resolve_routing", "routing_fields",
"routing_notice", "header_safe_reason",
"routing_notice", "header_safe_reason", "low_vram_caveat",
"runtime_compute_profile", "runtime_compute_profile_async",
"under_provisioned_vram",
]
+1
View File
@@ -15,6 +15,7 @@ _SHA = re.compile(r"[0-9a-f]{40}\Z")
CURATED_REVISIONS: dict[str, str] = {
"facebook/nllb-200-distilled-600M": "f8d333a098d19b4fd9a8b18f94170487ad3f821d",
"k2-fsa/OmniVoice": "c5fdb5ccb189668d56333f77ba2629f4cd7535f4",
"audio-cpp/audio.cpp-gguf": "dc6fecccc2b0c6bdda0a8b2f38fa61394fee0b9c",
"Systran/faster-whisper-large-v3": "edaa852ec7e145841d8ffdb056a99866b5f0a478",
"mlx-community/whisper-large-v3-mlx": "49e6aa286ad60c14352c404340ded53710378a11",
"mlx-community/whisper-large-v3-turbo": "a4aaeec0636e6fef84abdcbe3544cb2bf7e9f6fb",
+220
View File
@@ -0,0 +1,220 @@
"""Karaoke (word-highlight) ASS builder for dub hardsub export.
Pure text-in/text-out: no ffmpeg, no models, no filesystem. ``build_ass``
turns subtitle cues into an ASS script whose lines carry ``\\k``/``\\kf``
karaoke tags, so ffmpeg's ``ass=`` filter burns a word-by-word highlight
sweep instead of the static line the SRT path renders.
Word timing sources, in order:
1. ``cue["words"]`` per-word ``{text, start, end}`` persisted at
transcribe time (services.segmentation). Used only when the words still
spell the cue's display text: after translation the persisted ASR words
are source-language tokens, so re-using their timing would burn the
wrong language. The display text is always authoritative.
2. Even split the cue text's whitespace tokens spread uniformly across
``[start, end]``. This is the compatibility path for jobs transcribed
before word persistence and for translated tracks.
Dual-layout karaoke is intentionally unsupported (out of scope): callers
must fall back to the line (SRT) burn when the dual layout is requested.
"""
from __future__ import annotations
import re
from typing import Optional, Sequence
_WS = re.compile(r"\s+")
#: Default ASS canvas. libass scales the script to the real video size, so
#: one reference resolution keeps font/margin proportions stable everywhere.
DEFAULT_PLAY_RES = (1920, 1080)
_HEADER_TEMPLATE = """[Script Info]
; Generated by VoiceStudio karaoke burn-in
ScriptType: v4.00+
PlayResX: {res_x}
PlayResY: {res_y}
WrapStyle: 0
ScaledBorderAndShadow: yes
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Arial,64,&H0000E7FF,&H00FFFFFF,&H00101010,&H7F000000,0,0,0,0,100,100,0,0,1,3,1,2,96,96,48,1
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
"""
def _norm(text: object) -> str:
return _WS.sub(" ", str(text or "").strip())
def _ass_time(seconds: float) -> str:
"""``H:MM:SS.CC`` (centiseconds) — the ASS event timestamp format."""
cs = max(0, int(round(float(seconds) * 100)))
h, rem = divmod(cs, 360000)
m, rem = divmod(rem, 6000)
s, c = divmod(rem, 100)
return f"{h}:{m:02d}:{s:02d}.{c:02d}"
def _ass_escape(text: str) -> str:
"""Escape a display token for an ASS Dialogue text field.
Braces would open an override block (user text like ``{\\b1}`` must render
literally, never execute); newlines become ASS hard line breaks.
"""
return (
str(text)
.replace("{", "\\{")
.replace("}", "\\}")
.replace("\r\n", "\\N")
.replace("\n", "\\N")
.replace("\r", "\\N")
)
def _cs(seconds: float) -> int:
"""Karaoke tag duration in centiseconds; ≥1 so a tag never renders as 0."""
return max(1, int(round(float(seconds) * 100)))
def even_split_words(text: str, start: float, end: float) -> list[dict]:
"""Uniformly distribute the cue text's whitespace tokens over [start, end].
The export fallback for jobs transcribed before per-word persistence and
for translated tracks (whose persisted words are source-language tokens).
"""
tokens = [tok for tok in _WS.split(str(text or "").strip()) if tok]
if not tokens:
return []
start = float(start)
dur = max(0.0, float(end) - start) / len(tokens)
return [
{"text": tok, "start": start + i * dur, "end": start + (i + 1) * dur}
for i, tok in enumerate(tokens)
]
def scale_words(
words: Sequence[dict],
orig_start: float,
orig_end: float,
new_start: float,
new_end: float,
) -> Optional[list[dict]]:
"""Map word times linearly from [orig_start, orig_end] → [new_start, new_end].
Used when Smart Fit moves a cue onto the fitted timeline: the persisted
word times live on the original timeline and must ride along. Returns
``None`` when either span is degenerate (caller should drop the words so
export falls back to an even split over the new span).
"""
orig_span = float(orig_end) - float(orig_start)
new_span = float(new_end) - float(new_start)
if orig_span <= 0 or new_span <= 0:
return None
ratio = new_span / orig_span
out: list[dict] = []
for w in words:
try:
ws = float(w["start"])
we = float(w["end"])
except (KeyError, TypeError, ValueError):
return None
out.append({
**w,
"start": round(float(new_start) + (ws - float(orig_start)) * ratio, 3),
"end": round(float(new_start) + (we - float(orig_start)) * ratio, 3),
})
return out
def _usable_words(cue: dict, text: str) -> Optional[list[tuple[str, float, float]]]:
"""Persisted words, iff well-formed AND they spell the cue's display text."""
words = cue.get("words")
if not isinstance(words, list) or not words:
return None
clean: list[tuple[str, float, float]] = []
for w in words:
if not isinstance(w, dict):
return None
wtext = _norm(w.get("text"))
try:
ws = float(w["start"])
we = float(w["end"])
except (KeyError, TypeError, ValueError):
return None
if wtext:
clean.append((wtext, ws, we))
if not clean:
return None
if _norm(" ".join(t for t, _, _ in clean)) != text:
return None
return clean
def _karaoke_text(cue: dict, text: str, start: float, end: float) -> str:
"""One Dialogue text field: ``{\\k…}`` lead-in + per-word ``{\\kf…}`` tags.
Each word's sweep runs until the next word starts (the classic karaoke
layout inter-word gaps finish the previous word's fill), and the last
word sweeps out to the cue end.
"""
words = _usable_words(cue, text) or [
(w["text"], w["start"], w["end"]) for w in even_split_words(text, start, end)
]
# Clamp into the cue span and enforce monotonic starts so malformed
# persisted data can only mistime the sweep, never corrupt the script.
clamped: list[tuple[str, float]] = []
prev = start
for wtext, ws, _ in words:
ws = min(max(ws, prev), end)
clamped.append((wtext, ws))
prev = ws
parts: list[str] = []
lead = clamped[0][1] - start
if lead > 0.005:
parts.append(f"{{\\k{_cs(lead)}}}")
for i, (wtext, ws) in enumerate(clamped):
nxt = clamped[i + 1][1] if i + 1 < len(clamped) else end
sep = " " if i + 1 < len(clamped) else ""
parts.append(f"{{\\kf{_cs(max(nxt, ws) - ws)}}}{_ass_escape(wtext)}{sep}")
return "".join(parts)
def build_ass(
cues: Sequence[dict],
*,
dual: bool = False,
play_res: tuple[int, int] = DEFAULT_PLAY_RES,
) -> str:
"""Build a karaoke ASS script from subtitle cues ({text, start, end, words?}).
One ``Default`` style; one Dialogue event per cue. ``dual`` exists for
signature parity with the line burn but dual-layout karaoke is out of
scope callers must keep the SRT line burn for dual, so requesting it
here is a contract violation, not a rendering mode.
"""
if dual:
raise ValueError(
"dual-layout karaoke is not supported; use the line (SRT) burn for dual subtitles"
)
res_x, res_y = play_res
lines = [_HEADER_TEMPLATE.format(res_x=int(res_x), res_y=int(res_y))]
for cue in cues or []:
text = _norm(cue.get("text"))
if not text:
continue
start = float(cue["start"])
end = float(cue["end"])
if end <= start:
end = start + 0.1
lines.append(
f"Dialogue: 0,{_ass_time(start)},{_ass_time(end)},Default,,0,0,0,,"
f"{_karaoke_text(cue, text, start, end)}"
)
return "\n".join(lines) + "\n"
+93 -30
View File
@@ -404,7 +404,23 @@ _CONFIGURED_GPU_JOB_TIMEOUT_S = GPU_JOB_TIMEOUT_S
# CPU synthesis is healthy but substantially slower than accelerated inference.
# Keep a separate, bounded floor so a short render on CPU is not abandoned at
# the GPU-oriented five-minute deadline (#1588).
#
# #1787 review fix: an explicit OMNIVOICE_CPU_GENERATE_TIMEOUT_S must ALWAYS
# govern CPU dispatches, even when OMNIVOICE_GENERATE_TIMEOUT_S is ALSO
# explicit. Before this flag existed, `universal_override` below treated any
# explicit GENERATE_TIMEOUT_S as authoritative for CPU too, so the Settings
# panel's "CPU budget" row could be saved and silently never apply whenever
# the "Accelerated" row was also set — the exact defect (a control that looks
# like it works and doesn't) issue #1787 exists to remove. Setting ONLY
# OMNIVOICE_GENERATE_TIMEOUT_S keeps its historical "universal" behavior
# unchanged (test_explicit_universal_generate_timeout_wins_on_cpu) — nobody
# who already relies on that single-var override loses it. The only case that
# changes is the previously-undocumented, previously-broken combination of
# setting BOTH: the more specific (CPU) value now wins for CPU jobs, matching
# what a user who filled in both Settings rows was told would happen.
_CPU_GENERATE_TIMEOUT_EXPLICIT = "OMNIVOICE_CPU_GENERATE_TIMEOUT_S" in os.environ
CPU_JOB_TIMEOUT_S = float(os.environ.get("OMNIVOICE_CPU_GENERATE_TIMEOUT_S", "600.0"))
_CONFIGURED_CPU_JOB_TIMEOUT_S = CPU_JOB_TIMEOUT_S
# Queue-wait budget — a SEPARATE, deliberately generous clock (#1190/#1202).
# The execution bound above must never be spent waiting in line: a job queued
@@ -509,6 +525,8 @@ class GpuPoolBusyError(TimeoutError):
def generate_timeout_s(
text: "str | None", *, engine: object = None, execution_device: "str | None" = None,
min_vram_gb: float = 0.0, hardware_family: "str | None" = None,
vram_gb: "float | None" = None,
) -> float:
"""THE wall-clock execution budget for one synthesis job, scaled to input.
@@ -520,33 +538,74 @@ def generate_timeout_s(
on long inputs. Lives here (not in a router) so every router shares it
without importing generation.py.
Policy: floor at the configured OMNIVOICE_GENERATE_TIMEOUT_S, plus 1s per
40 characters past a 1200-character free allowance generous enough for
Policy: floor at the configured OMNIVOICE_GENERATE_TIMEOUT_S (accelerated
hosts) or OMNIVOICE_CPU_GENERATE_TIMEOUT_S (CPU hosts the latter wins
for CPU whenever it is itself explicit, even if the former also is; see
the #1787 comment on the module-level constants), plus 1s per 40
characters past a 1200-character free allowance generous enough for
CPU-class hardware, still bounded (a wedged job is caught in minutes, not
hours).
#1804: "accelerated" is not one performance class. A card with less VRAM
than the engine declares it needs pages to system RAM over PCIe and renders
SLOWER than the same machine's CPU would — yet, judged by device family
alone, it was handed HALF the CPU budget. That inversion is what three 4 GB
reporters hit (#1226 GTX 1650 Ti, #1222 Quadro P2000, #1804 GTX 1650), all
on the engine that declares a 6 GB floor. Every layer already knew: routing
raises a caveat, the preflight toast warns, and the timeout message names
the card. Only the budget ignored it. So an under-provisioned accelerator
now floors at the CPU budget the class of hardware it actually performs
like. ``min_vram_gb`` is the engine's declared floor; callers that pass
``engine`` get it read off the engine automatically. Native runtimes pass
an explicit ``vram_gb=0`` when their dedicated-memory probe failed; that
unknown capacity gets the same conservative CPU-class budget without
claiming the card is under-provisioned in user-facing diagnostics.
"""
base = GPU_JOB_TIMEOUT_S
try:
from core.device_caps import detect_host_caps
family = execution_device or detect_host_caps().family
caps = detect_host_caps()
family = execution_device or caps.family
if not min_vram_gb and engine is not None:
min_vram_gb = float(getattr(engine, "min_vram_gb", 0.0) or 0.0)
if execution_device is None and engine is not None:
from services.engine_routing import resolve_routing
compat = getattr(engine, "gpu_compat", None)
if compat is None:
compat = getattr(type(engine), "gpu_compat", (family, "cpu"))
if tuple(compat) == ("cpu",):
family = "cpu"
else:
family = resolve_routing(
compat, detect_host_caps(),
float(getattr(engine, "min_vram_gb", 0.0) or 0.0),
)["effective_device"]
from services.engine_routing import runtime_compute_profile
profile = runtime_compute_profile(engine, caps)
family = profile["effective_device"]
min_vram_gb = profile["min_vram_gb"]
hardware_family = profile.get("runtime_hardware_family")
vram_gb = profile.get("runtime_vram_gb")
universal_override = (
_GENERATE_TIMEOUT_EXPLICIT
or GPU_JOB_TIMEOUT_S != _CONFIGURED_GPU_JOB_TIMEOUT_S
)
if family == "cpu" and not universal_override:
# An explicit (env-set, or runtime-changed the same way tests do)
# CPU budget is more specific than the universal override and always
# wins for CPU dispatches — see the #1787 comment above.
cpu_explicit = (
_CPU_GENERATE_TIMEOUT_EXPLICIT
or CPU_JOB_TIMEOUT_S != _CONFIGURED_CPU_JOB_TIMEOUT_S
)
if family == "cpu" and (cpu_explicit or not universal_override):
base = CPU_JOB_TIMEOUT_S
elif not universal_override and family in (
"cuda", "rocm", "vulkan", "xpu",
):
from services.engine_routing import under_provisioned_vram
runtime_family = hardware_family or family
unknown_dedicated_vram = (
min_vram_gb > 0
and runtime_family in ("cuda", "rocm", "xpu", "vulkan")
and vram_gb is not None
and float(vram_gb or 0.0) <= 0
)
if unknown_dedicated_vram or under_provisioned_vram(
caps, min_vram_gb, family=hardware_family, vram_gb=vram_gb,
):
# `max`, never a plain assignment: an operator who raised the
# accelerated budget above the CPU one must not have it cut.
base = max(base, CPU_JOB_TIMEOUT_S)
except Exception:
# Device probing is advisory here; the configured universal bound is
# still safe when a platform probe is unavailable during startup.
@@ -1050,6 +1109,7 @@ def _timeout_guidance(
"""
family = "cuda" # conservative default: GPU wording if the probe fails
device_name, vram_gb = "", 0.0
_caps = None # a failed probe stays None; under_provisioned_vram() reads it safely
try:
from core.device_caps import detect_host_caps
_caps = detect_host_caps()
@@ -1085,7 +1145,7 @@ def _timeout_guidance(
"compute-bound. For a durable fix try shorter text or a lighter "
"engine (OmniVoice GGUF and Supertonic-3 are CPU-tuned). If you "
"expect very long single generations, raise "
"OMNIVOICE_GENERATE_TIMEOUT_S."
"the compute-time budget in Settings → Performance & Device."
)
# #1226/#1222: two users on 4 GB cards were told, generically, that the GPU
# "is VRAM-starved" — true, but it read as a transient contention problem
@@ -1097,11 +1157,9 @@ def _timeout_guidance(
# a threshold applied without knowing whose job it is would confidently
# misdiagnose most of them. And on MPS `vram_gb` is a unified-memory
# heuristic (RAM/2), not a dedicated pool to compare against.
if (
min_vram_gb > 0
and family in ("cuda", "rocm")
and 0 < vram_gb < min_vram_gb
):
from services.engine_routing import under_provisioned_vram
if under_provisioned_vram(_caps, min_vram_gb):
return common + (
f"{device_name or 'this GPU'} has {vram_gb:.1f} GB of VRAM and "
f"this engine wants about {min_vram_gb:.0f} GB — generations here "
@@ -1110,7 +1168,8 @@ def _timeout_guidance(
f"Supertonic-3 are tuned for small/no GPU) or shorter text; "
f"Flush caches / Unload the resident model (top toolbar or "
f"Model Catalogue → Models) frees what little headroom there is. (Raise "
f"OMNIVOICE_GENERATE_TIMEOUT_S if you'd rather let long "
f"the compute-time budget in Settings → Performance & Device if "
f"you'd rather let long "
f"generations run.)"
)
return common + (
@@ -1118,7 +1177,8 @@ def _timeout_guidance(
"contend for memory). For a durable fix, Flush caches / Unload the "
"resident model (top toolbar or Model Catalogue → Models) before retrying, "
"try shorter text, a lighter engine, or set the engine to CPU in "
"Model Catalogue → Models. (Raise OMNIVOICE_GENERATE_TIMEOUT_S for very "
"Model Catalogue → Models. (Raise the compute-time budget in "
"Settings → Performance & Device for very "
"long single generations.)"
)
@@ -1480,14 +1540,17 @@ def get_best_device():
# ── DirectML — universal Windows GPU (probe reports this as "cpu") ─
# Reached only when no torch family was detected (family == "cpu"), which is
# exactly the DirectML case — the probe classifies DirectML hosts as cpu.
try:
import torch_directml
if torch_directml.device_count() > 0:
logger.info("Using DirectML device (GPU %d)", 0)
return str(torch_directml.device(0))
except ImportError:
pass
if family == "cpu":
try:
import torch_directml
if torch_directml.device_count() > 0:
logger.info("Using DirectML device (GPU %d)", 0)
return str(torch_directml.device(0))
except ImportError:
# DirectML is optional; an absent package leaves CPU available.
pass
# Other families need an explicitly compatible loader (e.g. NPU sidecars).
return "cpu"
_COMPILE_ERR_MODULE_PREFIXES = ("torch._dynamo", "torch._inductor", "torch.fx", "triton")
+40
View File
@@ -222,6 +222,46 @@ def entries_for_language(entries, language: Optional[str]) -> dict[str, str]:
return merged
def inert_entries_for_language(entries, language: str | None) -> list[dict]:
"""Enabled entries that MATCH the language but cannot be applied yet.
Settings offers three notations Respelling, IPA, CMU and only
respelling substitutes text today. IPA and CMU rows save cleanly, are
validated, get a badge and can be toggled on, and are then dropped before
term matching. Nothing downstream reads them.
That is Phase 1 behaving as designed; the gap is that it is INVISIBLE.
"Test a sentence" reported "No entries match; spoken as written" for a
term that does match, which is not a degraded answer but a wrong one, and
it sent the user off to re-type an entry that was already correct (#1949).
docs/specs/01-expressive-tts.md asked for exactly the opposite such
entries "passed through and flagged 'phoneme not honored on this
engine' (parity-rule: visible degradation)". This is that flag: the
caller can now say WHY nothing happened instead of implying nothing
matched.
"""
req_prefix = _lang_prefix(language)
out: list[dict] = []
for e in entries or []:
try:
if not int(e["enabled"]):
continue
except (KeyError, IndexError, TypeError, ValueError):
continue
term = (e["term"] or "").strip()
if not term:
continue
etype = (e["type"] or "respelling").strip().lower()
if etype == "respelling":
continue
scope = (e["language"] or _ALL_LANG).strip() or _ALL_LANG
if scope != _ALL_LANG and (req_prefix is None or scope[:2].lower() != req_prefix):
continue
out.append({"term": term, "type": etype})
return out
# ── Inline one-off override: [[term|replacement]] / [[replacement]] ─────────
#
# Double brackets are unambiguous against the single-bracket grammar
+44 -1
View File
@@ -100,10 +100,33 @@ class Segment:
}
def _serialize_words(words: Sequence[Word]) -> list[dict]:
"""Word objects → the ``{text, start, end}`` dicts persisted on segments.
Per-word timing is kept on each segment (``Segment.extra["words"]``, so
``to_dict`` carries it onto the job) to drive the karaoke hardsub export.
"""
return [
{"text": w.text, "start": round(w.start, 3), "end": round(w.end, 3)}
for w in words
]
def _merge_segment_extra(target: Segment, incoming: Segment, *, prepend: bool) -> None:
"""Preserve editor metadata when cleanup folds ``incoming`` into ``target``."""
# Word lists must CONCATENATE in text order (the setdefault below would
# otherwise adopt the incoming list wholesale when the target has none,
# then double it). Capture both sides before setdefault runs.
raw_target_words = target.extra.get("words")
raw_incoming_words = incoming.extra.get("words")
for key, value in incoming.extra.items():
target.extra.setdefault(key, value)
target_words = raw_target_words if isinstance(raw_target_words, list) else []
incoming_words = raw_incoming_words if isinstance(raw_incoming_words, list) else []
if target_words or incoming_words:
target.extra["words"] = (
incoming_words + target_words if prepend else target_words + incoming_words
)
def joined(left: object, right: object) -> str:
return _clean(f"{left or ''} {right or ''}")
@@ -233,7 +256,10 @@ def _build_segments_from_words(words: Sequence[Word]) -> List[Segment]:
if not text:
buf = []
return
segments.append(Segment(start=buf_start, end=buf[-1].end, text=text))
segments.append(Segment(
start=buf_start, end=buf[-1].end, text=text,
extra={"words": _serialize_words(buf)},
))
buf = []
if not force:
buf_start = 0.0
@@ -291,6 +317,7 @@ def _build_segments_from_words(words: Sequence[Word]) -> List[Segment]:
start=buf_start,
end=left_buf[-1].end,
text=_clean(" ".join(x.text for x in left_buf)),
extra={"words": _serialize_words(left_buf)},
))
buf = list(right_buf)
buf_start = right_buf[0].start
@@ -479,11 +506,23 @@ def _apply_scene_cuts(segments: List[Segment], scene_cuts: Iterable[float]) -> L
or (remaining.end - cut) < MIN_DUR
):
continue
# Segment text is the joined word texts, so a whitespace-boundary
# text split maps exactly onto a word-count split of the list.
words = remaining.extra.get("words")
left_extra: dict = {}
right_extra: dict = {}
if isinstance(words, list) and words:
n_left = len(left_text.split())
if n_left and len(words) > n_left:
left_extra = {"words": words[:n_left]}
right_extra = {"words": words[n_left:]}
out.append(Segment(
start=remaining.start, end=cut, text=left_text, speaker_id=remaining.speaker_id,
extra=left_extra,
))
remaining = Segment(
start=cut, end=remaining.end, text=right_text, speaker_id=remaining.speaker_id,
extra=right_extra,
)
out.append(remaining)
return out
@@ -715,6 +754,10 @@ def _resplit_core(
piece["text"] = text
piece["start"] = s0 if k == 0 else ws[0].start
piece["end"] = s1 if k == n_runs - 1 else ws[-1].end
# dict(seg) copied the WHOLE segment's word list into every piece;
# each piece keeps only its own run's words (karaoke burn-in).
if "words" in piece:
piece["words"] = _serialize_words(ws)
if label:
piece["speaker_id"] = label
if piece_no > 0:
+25 -1
View File
@@ -29,6 +29,14 @@ import httpx
_HF_AUTH_HOSTS = ("huggingface.co", "hf.co")
_DEFAULT_CONNECTIONS = 8
_MIN_SEGMENT_BYTES = 4 * 1024 * 1024 # don't split below this — overhead > gain
# Cap on a single segment. Progress is committed to the manifest only when a
# whole segment lands, so the segment size is also the MOST bytes a dropped
# connection can throw away. Sizing segments as size/num_connections made that
# ~100 MB on an 800 MB blob: on a link that drops every ~50 MB no segment ever
# completed, the manifest was never written, and every retry restarted from
# zero (#1224 follow-up). Bounded segments turn the same flaky link into steady
# forward progress.
_MAX_SEGMENT_BYTES = 16 * 1024 * 1024
_READ_CHUNK = 1024 * 1024
@@ -67,8 +75,16 @@ async def _resolve(client: httpx.AsyncClient, url: str, token: Optional[str], ma
def _plan_segments(size: int, num_connections: int) -> list[tuple[int, int]]:
"""Byte ranges to fetch, each at most ``_MAX_SEGMENT_BYTES``.
``num_connections`` controls how many run at once (see the semaphore in
:func:`segmented_download`), NOT how many segments exist a large file is
split into many bounded segments so each one commits to the manifest
quickly and a dropped connection costs at most one segment.
"""
n = max(1, min(num_connections, max(1, size // _MIN_SEGMENT_BYTES)))
step = -(-size // n) # ceil
step = max(_MIN_SEGMENT_BYTES, min(step, _MAX_SEGMENT_BYTES))
segs = []
start = 0
while start < size:
@@ -143,6 +159,10 @@ async def segmented_download(
_preallocate(part, size)
segments = [s for s in _plan_segments(size, num_connections) if s not in done]
lock = asyncio.Lock()
# Segments are bounded, so a big file yields many more of them than
# there are connections. The semaphore — not the segment count — is
# what keeps concurrency at num_connections.
sem = asyncio.Semaphore(max(1, num_connections))
async def _fetch(seg: tuple[int, int]):
start, end = seg
@@ -169,8 +189,12 @@ async def segmented_download(
done.add(seg)
_save_done(part, size, done)
async def _fetch_limited(seg: tuple[int, int]):
async with sem:
await _fetch(seg)
if segments:
await asyncio.gather(*(_fetch(s) for s in segments))
await asyncio.gather(*(_fetch_limited(s) for s in segments))
# ── verify ──────────────────────────────────────────────────────
actual = os.path.getsize(part)
+343 -25
View File
@@ -60,7 +60,7 @@ from pathlib import Path
from typing import Callable, Optional
from core.config import DATA_DIR
from core.contained_subprocess import OwnedPopen, spawn_owned
from core.contained_subprocess import OwnedPopen, WindowsJobPopen, spawn_owned
logger = logging.getLogger("omnivoice.sidecar_install")
@@ -126,6 +126,33 @@ class SidecarSpec:
invalidate: Callable[[], None] = field(default=lambda: None)
# Cheap "is a healthy install already present?" probe (file existence only).
installed_probe: Callable[[], bool] = field(default=lambda: False)
# Extra `uv venv` arguments — an interpreter pin for an upstream that
# declares one, e.g. ("--python", "3.10").
venv_args: tuple[str, ...] = ()
# `uv pip install` target, "{checkout}" substituted. Each upstream installs
# differently (editable, editable with an extra, a requirements file, a
# constraints file); the default is the editable install IndexTTS uses.
install_args: tuple[str, ...] = ("-e", "{checkout}")
# Add PyTorch's CUDA index on a CUDA host. Plain PyPI torch is CPU-only on
# Windows, and `+cuNNN` local-version pins exist nowhere else.
uses_cuda_index: bool = False
# Python that proves the venv works; "{checkout}" / "{checkout_repr}"
# substituted. None means `import <probe_module>`.
probe_code: Optional[str] = None
# The file whose presence proves a fetched checkout is the whole
# repository. Most upstreams ship a pyproject.toml; Confucius4 ships
# only requirements.txt and setup.py.
source_manifest: str = "pyproject.toml"
# False for an engine that is a PyPI package, not a repository: nothing
# is fetched, and the managed root holds only the engine's own venv.
has_source: bool = True
# Add PyTorch's CPU index on every host, for an engine that only ever
# runs torch on the CPU (see core.torch_indexes).
cpu_torch_index: bool = False
# Can the one-click install work on THIS machine? (ok, reason). Consulted
# before an Install button is offered and again when an install starts, so
# a host the upstream does not support never gets a job that can only fail.
host_supported: Callable[[], tuple[bool, str]] = field(default=lambda: (True, ""))
def _indextts_invalidate() -> None:
@@ -138,6 +165,86 @@ def _indextts_installed() -> bool:
return is_indextts_installed()
def _moss_invalidate() -> None:
from engines.moss_tts_v15 import bootstrap
bootstrap.invalidate()
def _moss_installed() -> bool:
from engines.moss_tts_v15.bootstrap import is_moss_tts_v15_installed
return is_moss_tts_v15_installed()
def _confucius4_invalidate() -> None:
from engines.confucius4 import bootstrap
bootstrap.invalidate()
def _confucius4_installed() -> bool:
from engines.confucius4.bootstrap import is_confucius4_installed
return is_confucius4_installed()
def _dots_invalidate() -> None:
from engines.dots_tts import bootstrap
bootstrap.invalidate()
def _dots_installed() -> bool:
from engines.dots_tts.bootstrap import is_dots_tts_installed
return is_dots_tts_installed()
def _host_family() -> str:
"""The accelerator family this host runs, or "cpu" when it cannot tell."""
try:
from core.device_caps import detect_host_caps
return str(detect_host_caps().family)
except Exception: # noqa: BLE001 — a probe failure must not break installs
return "cpu"
def _moss_host() -> tuple[bool, str]:
if _host_family() == "cuda":
return True, ""
return False, (
"MOSS-TTS-v1.5's one-click install uses its CUDA build of PyTorch, and "
"this machine has no NVIDIA GPU available. Its guide covers a manual "
"CPU install."
)
def _dots_host() -> tuple[bool, str]:
if sys.platform != "win32":
return True, ""
return False, (
"dots.tts publishes no Windows install. Run VoiceStudio on Linux or "
"macOS, or under WSL2, to use it."
)
def _pockettts_host() -> tuple[bool, str]:
import platform
if sys.platform == "darwin" and platform.machine().lower() == "x86_64":
return False, (
"PocketTTS needs a PyTorch version that has no Intel Mac build."
)
return True, ""
def _in_app_env(module: str) -> Callable[[], bool]:
"""An install made with ``uv sync --extra`` lives in the app's own
environment. It counts as installed, so the installer never provisions a
second copy over one that works."""
def probe() -> bool:
import importlib.util
try:
return importlib.util.find_spec(module) is not None
except (ImportError, ValueError):
return False
return probe
SPECS: dict[str, SidecarSpec] = {
"indextts2": SidecarSpec(
engine_id="indextts2",
@@ -170,9 +277,165 @@ SPECS: dict[str, SidecarSpec] = {
invalidate=_indextts_invalidate,
installed_probe=_indextts_installed,
),
# Pinned to the upstream commits current on 2026-09-10. Weights are not
# fetched here: each engine downloads them into the shared HF cache on its
# first synthesis, as its manual install always has.
"moss-tts-v15": SidecarSpec(
engine_id="moss-tts-v15",
display_name="MOSS-TTS-v1.5",
repo_url="https://github.com/OpenMOSS/MOSS-TTS.git",
tarball_url=(
"https://github.com/OpenMOSS/MOSS-TTS/archive/"
"934d6826b084c46a0d033402174d5f8ac4ed2519.tar.gz"
),
checkout_dirname="MOSS-TTS",
env_var="OMNIVOICE_MOSS_TTS_V15_DIR",
probe_module="transformers",
probe_code="import transformers, torch",
source_revision="934d6826b084c46a0d033402174d5f8ac4ed2519",
source_required_path="pyproject.toml",
venv_args=("--python", "3.11"),
install_args=("-e", "{checkout}[torch-runtime]"),
uses_cuda_index=True,
host_supported=_moss_host,
docs_path="docs/engines/moss-tts-v15.md",
# ~7 GB CUDA torch venv now, ~16 GB of weights on first synthesis.
required_bytes=24 * _GIB,
dependency_bytes=8 * _GIB,
temporary_free_bytes=8 * _GIB,
disk_confidence="estimated",
invalidate=_moss_invalidate,
installed_probe=_moss_installed,
),
"confucius4-tts": SidecarSpec(
engine_id="confucius4-tts",
display_name="Confucius4-TTS",
repo_url="https://github.com/netease-youdao/Confucius4-TTS.git",
tarball_url=(
"https://github.com/netease-youdao/Confucius4-TTS/archive/"
"4fb32c481302d8858c3aec6a1c2a8b4cea8894c0.tar.gz"
),
checkout_dirname="Confucius4-TTS",
env_var="OMNIVOICE_CONFUCIUS4_TTS_DIR",
probe_module="confuciustts",
# Upstream is not pip-installable; the package resolves from the
# checkout on sys.path, exactly as the engine's sidecar imports it.
probe_code="import sys; sys.path.insert(0, {checkout_repr}); import confuciustts",
source_revision="4fb32c481302d8858c3aec6a1c2a8b4cea8894c0",
# No pyproject.toml upstream: requirements.txt is its manifest.
source_manifest="requirements.txt",
source_required_path="setup.py",
venv_args=("--python", "3.10"),
install_args=("-r", "{checkout}/requirements.txt"),
# torch==2.7.0: CPU-only from PyPI on Windows; the CUDA index supplies
# 2.7.0+cu128, which satisfies the same pin.
uses_cuda_index=True,
docs_path="docs/engines/confucius4-tts.md",
# ~7 GB venv now, ~5 GB of weights on first synthesis.
required_bytes=14 * _GIB,
dependency_bytes=8 * _GIB,
temporary_free_bytes=8 * _GIB,
disk_confidence="estimated",
invalidate=_confucius4_invalidate,
installed_probe=_confucius4_installed,
),
"dots-tts": SidecarSpec(
engine_id="dots-tts",
display_name="dots.tts",
repo_url="https://github.com/rednote-hilab/dots.tts.git",
tarball_url=(
"https://github.com/rednote-hilab/dots.tts/archive/"
"32407a55228630475c48ecdb2c4e2c0f9c09e030.tar.gz"
),
checkout_dirname="dots.tts",
env_var="OMNIVOICE_DOTS_TTS_DIR",
probe_module="dots_tts.runtime",
source_revision="32407a55228630475c48ecdb2c4e2c0f9c09e030",
source_required_path="constraints/recommended.txt",
# Upstream requires-python is >=3.10,<3.13.
venv_args=("--python", "3.11"),
install_args=("-e", "{checkout}", "-c", "{checkout}/constraints/recommended.txt"),
host_supported=_dots_host,
docs_path="docs/engines/dots-tts.md",
# ~7 GB venv now, ~9 GB checkpoint on first synthesis.
required_bytes=18 * _GIB,
dependency_bytes=8 * _GIB,
temporary_free_bytes=8 * _GIB,
disk_confidence="estimated",
invalidate=_dots_invalidate,
installed_probe=_dots_installed,
),
# PyPI packages rather than repositories: nothing to clone, and the managed
# root holds only the engine's own venv. The pins are the app's own
# optional extras (a test ties the two together), so the engine runs the
# same wheel whichever way it was installed.
"supertonic3": SidecarSpec(
engine_id="supertonic3",
display_name="Supertonic-3",
repo_url="",
tarball_url="",
checkout_dirname="supertonic3",
env_var="OMNIVOICE_SUPERTONIC3_DIR",
probe_module="supertonic",
has_source=False,
venv_args=("--python", "3.11"),
install_args=("supertonic==1.3.1",),
docs_path="docs/engines/supertonic3.md",
# onnxruntime + numpy + huggingface_hub, no torch. The ~400 MB of
# weights download on first synthesis into the shared HF cache.
required_bytes=1 * _GIB,
installed_probe=_in_app_env("supertonic"),
),
"pockettts": SidecarSpec(
engine_id="pockettts",
display_name="PocketTTS",
repo_url="",
tarball_url="",
checkout_dirname="pockettts",
env_var="OMNIVOICE_POCKETTTS_DIR",
probe_module="pocket_tts",
has_source=False,
venv_args=("--python", "3.11"),
install_args=("pocket-tts==2.1.0",),
cpu_torch_index=True,
docs_path="docs/engines/pockettts.md",
# CPU torch + scipy. The gated weights download on first use.
required_bytes=3 * _GIB,
installed_probe=_in_app_env("pocket_tts"),
host_supported=_pockettts_host,
),
}
class HostUnsupported(RuntimeError):
"""The one-click install cannot work on this machine. The message is a
VoiceStudio-owned sentence from the spec, safe to show the user."""
def host_support(spec: SidecarSpec) -> tuple[bool, str]:
"""Whether *spec*'s install can work here. A probe that raises counts as
unsupported: offering a button that fails is worse than not offering it."""
try:
ok, why = spec.host_supported()
except Exception: # noqa: BLE001
return False, (
f"Could not check whether {spec.display_name} can be installed on "
f"this machine. Its guide ({spec.docs_path}) has the manual steps."
)
return bool(ok), (why or "")
def installable_engine_ids() -> frozenset[str]:
"""Engines that get an Install button on THIS host."""
return frozenset(eid for eid, spec in SPECS.items() if host_support(spec)[0])
def _expand(value: str, checkout: Path) -> str:
return value.replace("{checkout_repr}", repr(str(checkout))).replace(
"{checkout}", str(checkout)
)
def get_spec(engine_id: str) -> Optional[SidecarSpec]:
return SPECS.get(engine_id)
@@ -196,6 +459,20 @@ def managed_checkout(spec: SidecarSpec) -> Path:
return managed_root(spec) / spec.checkout_dirname
def engine_venv_python(env_var: str) -> Optional[Path]:
"""The interpreter of the install *env_var* points at, if it has one.
For engines that can live in the app's environment or in a venv of their
own (PocketTTS, Supertonic-3): they prefer their own, and fall back to the
app's interpreter for an install made with ``uv sync --extra``.
"""
env_dir = os.environ.get(env_var)
if not env_dir:
return None
py = _venv_python(Path(env_dir) / ".venv")
return py if py.is_file() else None
def _legacy_managed_checkouts(spec: SidecarSpec) -> tuple[Path, ...]:
"""App-owned predecessor checkouts retained during in-place upgrades."""
if spec.engine_id == "indextts2":
@@ -272,13 +549,20 @@ def _default_uv_cache_root() -> Path:
return Path(os.environ.get("XDG_CACHE_HOME") or Path.home() / ".cache") / "uv"
def uv_subprocess_env(cache_parent: Path) -> "dict[str, str] | None":
def uv_subprocess_env(cache_parent: Path) -> "dict[str, str]":
"""Environment for ``uv`` subprocesses that install into *cache_parent*'s volume.
Returns ``None`` (inherit the parent environment untouched) when uv's
default cache already shares a volume with *cache_parent* or the user
pinned both variables themselves. Otherwise returns a copy of
``os.environ`` with the *unset* one(s) of ``UV_CACHE_DIR`` /
Always a copy of ``os.environ`` with ``UV_NO_CONFIG=1``: an engine's
install resolves its own requirements, never VoiceStudio's. The backend
runs inside the app's tree, so uv would otherwise discover the app's
``pyproject.toml`` and apply its ``[tool.uv] constraint-dependencies``
(``torch==2.8.0``) to the engine's venv. An engine pinning another torch
(MOSS-TTS-v1.5, Confucius4) could then never resolve, and one that pins
none got the app's torch instead of its own. Mirrors still apply: they
arrive as ``UV_INDEX_URL``, an environment variable, not a config file.
When uv's default cache is on another volume than *cache_parent*, the
copy also places the *unset* one(s) of ``UV_CACHE_DIR`` /
``UV_PYTHON_INSTALL_DIR`` placed inside *cache_parent*, so downloads, the
unpacked wheel cache, managed Pythons, and the venv all stay on the
target volume and same-volume hardlink installs work again. The two
@@ -291,17 +575,15 @@ def uv_subprocess_env(cache_parent: Path) -> "dict[str, str] | None":
pass the directory that should hold the shared ``.uv-cache`` typically
the common parent of the engine venvs on that volume.
"""
if _same_volume(cache_parent, _default_uv_cache_root()):
return None
env = dict(os.environ)
overrode = False
env["UV_NO_CONFIG"] = "1"
if _same_volume(cache_parent, _default_uv_cache_root()):
return env
if not env.get("UV_CACHE_DIR"): # explicit user choice always wins
env["UV_CACHE_DIR"] = str(Path(cache_parent) / ".uv-cache")
overrode = True
if not env.get("UV_PYTHON_INSTALL_DIR"):
env["UV_PYTHON_INSTALL_DIR"] = str(Path(cache_parent) / ".uv-python")
overrode = True
return env if overrode else None
return env
# ── Disk preflight ─────────────────────────────────────────────────────────
@@ -520,9 +802,13 @@ def _healthy(spec: SidecarSpec) -> bool:
return False
if not _venv_python(checkout / ".venv").is_file():
return False
if spec.weights_repo_id and not _weights_present(spec):
return False
return True
if spec.weights_repo_id:
return _weights_present(spec)
# Nothing downloaded after the dependencies proves they finished; only
# the marker the import probe writes does. IndexTTS (weights) predates
# the marker and keeps its own check, so no existing install is asked
# to reinstall.
return (checkout / _INSTALL_COMPLETE_MARKER).is_file()
def _persist(spec: SidecarSpec) -> None:
@@ -548,6 +834,9 @@ def start_install(engine_id: str) -> dict:
spec = get_spec(engine_id)
if spec is None:
raise KeyError(engine_id)
ok, why = host_support(spec)
if not ok:
raise HostUnsupported(why)
with _jobs_lock:
existing = _jobs.get(engine_id)
if existing and existing["state"] == "running":
@@ -679,6 +968,11 @@ def _step_preflight(spec: SidecarSpec, job: dict) -> None:
def _step_fetch_source(spec: SidecarSpec, job: dict) -> None:
step = _job_step(job, "fetch_source")
checkout = managed_checkout(spec)
if not spec.has_source:
checkout.mkdir(parents=True, exist_ok=True)
step["state"] = "done"
step["detail"] = "PyPI package, no source to fetch"
return
if _source_present(spec, checkout):
step["state"] = "done"
step["detail"] = "source already present"
@@ -717,7 +1011,7 @@ def _step_fetch_source(spec: SidecarSpec, job: dict) -> None:
_fetch_tarball(spec, job, checkout)
if not _source_layout_ok(spec, checkout):
raise _StepError(
f"Fetched source at {checkout} has no pyproject.toml — the download "
f"Fetched source at {checkout} has no {spec.source_manifest} — the download "
"appears incomplete or the upstream layout changed.",
"Re-run the install; if it keeps failing, clone the repository "
f"manually and set {spec.env_var} to the clone (see the engine docs).",
@@ -727,10 +1021,14 @@ def _step_fetch_source(spec: SidecarSpec, job: dict) -> None:
_SOURCE_REVISION_MARKER = ".voicestudio_source_revision"
# Written once the import probe passes. For an engine with no weights
# download, the venv interpreter existing proves nothing: a dependency
# install that died halfway leaves one behind.
_INSTALL_COMPLETE_MARKER = ".voicestudio_install_complete"
def _source_layout_ok(spec: SidecarSpec, checkout: Path) -> bool:
if not (checkout / "pyproject.toml").is_file():
if not (checkout / spec.source_manifest).is_file():
return False
return not spec.source_required_path or (checkout / spec.source_required_path).is_file()
@@ -743,6 +1041,8 @@ def _write_source_marker(spec: SidecarSpec, checkout: Path) -> None:
def _source_present(spec: SidecarSpec, checkout: Path) -> bool:
if not spec.has_source:
return checkout.is_dir()
if not _source_layout_ok(spec, checkout):
return False
if not spec.source_revision:
@@ -836,8 +1136,8 @@ def _step_create_venv(spec: SidecarSpec, job: dict) -> None:
# uv_subprocess_env. The cache parent is the shared engines root, so
# every sidecar engine reuses one cache.
uv_env = uv_subprocess_env(Path(DATA_DIR) / "engines")
rc = _run_logged(job, [uv, "venv", str(venv_dir)], timeout=_UV_VENV_TIMEOUT_S,
env=uv_env)
rc = _run_logged(job, [uv, "venv", str(venv_dir), *spec.venv_args],
timeout=_UV_VENV_TIMEOUT_S, env=uv_env)
if rc != 0 or not py.is_file():
raise _StepError(
f"uv venv failed (exit {rc}) at {venv_dir}.",
@@ -857,17 +1157,28 @@ def _step_install_deps(spec: SidecarSpec, job: dict) -> None:
"""
checkout = managed_checkout(spec)
py = _venv_python(checkout / ".venv")
# A reinstall that fails must not leave the previous run's marker.
(checkout / _INSTALL_COMPLETE_MARKER).unlink(missing_ok=True)
uv = _locate_uv()
_log(job, f"Installing {spec.display_name} into its venv (this can take several minutes) …")
target = [_expand(arg, checkout) for arg in spec.install_args]
if spec.cpu_torch_index:
from core.torch_indexes import UV_PIP_CPU_ARGS
target += list(UV_PIP_CPU_ARGS)
elif spec.uses_cuda_index and _host_family() == "cuda":
from core.torch_indexes import UV_PIP_CU128_ARGS
target += list(UV_PIP_CU128_ARGS)
# Always `--python <this engine's venv>`: the install can only ever land in
# the venv this engine owns, never the app's interpreter.
rc = _run_logged(
job,
[uv, "pip", "install", "--python", str(py), "-e", str(checkout)],
[uv, "pip", "install", "--python", str(py), *target],
timeout=_UV_PIP_INSTALL_TIMEOUT_S,
env=uv_subprocess_env(Path(DATA_DIR) / "engines"),
)
if rc != 0:
raise _StepError(
f"uv pip install -e failed (exit {rc}).",
f"uv pip install failed (exit {rc}).",
"Usually a network hiccup — re-run the install to resume. Behind a "
"proxy, set HTTPS_PROXY in Settings → Environment first.",
)
@@ -879,8 +1190,13 @@ def _step_verify(spec: SidecarSpec, job: dict) -> None:
py = _venv_python(checkout / ".venv")
_log(job, f"Verifying `import {spec.probe_module}` inside the venv …")
try:
probe = (
_expand(spec.probe_code, checkout)
if spec.probe_code
else f"import {spec.probe_module}"
)
proc = subprocess.run(
[str(py), "-c", f"import {spec.probe_module}"],
[str(py), "-c", probe],
capture_output=True, timeout=_IMPORT_PROBE_TIMEOUT_S,
)
except (subprocess.TimeoutExpired, OSError) as exc:
@@ -898,6 +1214,7 @@ def _step_verify(spec: SidecarSpec, job: dict) -> None:
"the engine docs.",
)
_job_step(job, "verify")["detail"] = f"import {spec.probe_module} OK"
(checkout / _INSTALL_COMPLETE_MARKER).write_text(f"{spec.probe_module}\n", encoding="utf-8")
_log(job, "Venv verified.")
@@ -1057,7 +1374,8 @@ def _run_logged(job: dict, argv: list[str], *, timeout: float,
would hang past the timeout waiting for pipe EOF.
"""
# ``spawn_owned`` creates the local timeout group/Job before the operation
# starts and links it to backend death through its control pipe.
# starts. POSIX links it to backend death through a control pipe; Windows
# retains a kill-on-close Job handle in this backend process.
popen_kwargs = _install_containment_kwargs()
try:
proc = spawn_owned(
@@ -1096,14 +1414,14 @@ def _run_logged(job: dict, argv: list[str], *, timeout: float,
def _kill_tree(proc: "subprocess.Popen") -> None:
"""Kill an operation through its stable nested group/Job owner."""
if isinstance(proc, OwnedPopen):
if isinstance(proc, (OwnedPopen, WindowsJobPopen)):
# The retained supervisor/process-group or nested Job is the stable
# per-operation owner. Do not fall back to a direct PID kill.
proc.kill()
try:
proc.wait(timeout=5)
except subprocess.TimeoutExpired:
pass
return
return
# A test double or a legacy caller without the nested owner can only be
# stopped through its stable direct-process handle.
+46 -15
View File
@@ -32,9 +32,9 @@ Threat-model summary (see Plan 02-01 frontmatter):
AUTH-05 installed (``HFTokenRedactor``) on the root logger.
T-02-04 compromised sidecar emitting unexpected ops: parent allowlist
``PARENT_INBOUND_OPS`` rejects everything else.
T-02-05 nested containment: a retained supervisor process group/Job owns
each engine operation and is linked to backend death by a control
pipe, while still permitting independent timeout teardown.
T-02-05 nested containment: a retained POSIX supervisor process group or
Windows Job owns each engine operation, while still permitting
independent timeout teardown and cleanup on backend death.
"""
from __future__ import annotations
@@ -385,6 +385,10 @@ class SubprocessBackend(TTSBackend):
def __init__(self) -> None:
self._proc: Optional[subprocess.Popen] = None
# A failed bounded reap must retain ownership and forbid reuse. This
# lock is separate from _lock: the receive owner joins its watchdog.
self._timeout_quarantine: list[subprocess.Popen] = []
self._timeout_quarantine_lock = threading.Lock()
# Single lock serialises spawn + every send/recv pair so two threads
# can't interleave half-frames on the same pipe.
self._lock = threading.Lock()
@@ -451,6 +455,10 @@ class SubprocessBackend(TTSBackend):
def _spawn(self) -> None:
"""Launch the sidecar if not already running. Blocks on the ready
handshake. Caller must hold self._lock."""
if not self._retry_timeout_cleanup():
raise RuntimeError(
f"{self.id} sidecar is still stopping after a timeout; retry once it exits"
)
if self._proc is not None and self._proc.poll() is None:
return # already up
@@ -542,6 +550,7 @@ class SubprocessBackend(TTSBackend):
"""Idempotent. Sends {op:shutdown}; falls back to terminate/kill."""
proc = self._proc
if proc is None:
self._retry_timeout_cleanup()
return
try:
try:
@@ -577,6 +586,7 @@ class SubprocessBackend(TTSBackend):
pass
finally:
self._proc = None
self._retry_timeout_cleanup()
def _force_kill(self) -> None:
"""Internal: kill a sidecar that never reached the ready state."""
@@ -777,38 +787,59 @@ class SubprocessBackend(TTSBackend):
return msg
def _recv_with_timeout(self, timeout_s: float) -> Optional[dict]:
"""Recv that aborts if the sidecar goes silent.
"""Read one frame, finishing timeout cleanup before the caller can retry.
Implemented by polling the proc for liveness with a deadline. We
don't block on a `select` of the pipe because Windows can't select
on subprocess pipes keeping the implementation cross-platform
means a simpler polling loop here.
A watchdog closes the pipe on timeout; Windows cannot select on pipes.
EOF alone does not prove the owned process/supervisor has exited.
"""
# On Unix we could use selectors; on Windows the pipe is not
# selectable. Use a watchdog thread that kills the sidecar on
# timeout — that triggers EOF on stdout, so _recv returns None
# and the caller raises.
watchdog = threading.Timer(timeout_s, self._timeout_kill)
proc = self._proc
watchdog = threading.Timer(timeout_s, self._timeout_kill, args=(proc,))
watchdog.daemon = True
watchdog.start()
try:
return self._recv()
finally:
watchdog.cancel()
# cancel() cannot stop an already-running callback. Finish its
# bounded reap before another receive or generation starts.
watchdog.join()
self._touch() # any reply (or attempt) counts as recent activity
def _timeout_kill(self) -> None:
proc = self._proc
def _timeout_kill(self, proc: Optional[subprocess.Popen]) -> None:
"""Kill only the child this receive captured, then reap its owner."""
if proc is None:
return
logger.error("[%s] sidecar exceeded recv timeout; killing", self.id)
try:
logger.error(
"[%s] sidecar exceeded recv timeout; killing",
self.id,
)
proc.kill()
except Exception:
# A raced exit can make kill fail, but its owner still needs reaping.
pass
try:
proc.wait(timeout=2)
except Exception:
# Do not discard a possibly live owner, or replace a newer _proc.
with self._timeout_quarantine_lock:
if not any(item is proc for item in self._timeout_quarantine):
self._timeout_quarantine.append(proc)
else:
with self._timeout_quarantine_lock:
self._timeout_quarantine = [
item for item in self._timeout_quarantine if item is not proc
]
def _retry_timeout_cleanup(self) -> bool:
"""Retry bounded cleanup, retaining every owner that could still be live."""
with self._timeout_quarantine_lock:
pending = tuple(self._timeout_quarantine)
for proc in pending:
self._timeout_kill(proc)
with self._timeout_quarantine_lock:
return not self._timeout_quarantine
# ── stderr drain ───────────────────────────────────────────────────────
+88
View File
@@ -112,6 +112,13 @@ _FULL_NAME_TO_CODE = {
"vietnamese": "vi",
"kazakh": "kz",
"standard arabic": "ar",
# Below: inert for num2words (absent from _NUM2WORDS_LANGS, which reads
# digits natively for these scripts), present so _plain_lang_code can
# resolve them for the digit-range rule.
"korean": "ko",
"japanese": "ja",
"chinese": "zh",
"mandarin chinese": "zh",
}
# ISO codes whose num2words locale name differs.
@@ -178,6 +185,82 @@ def _num2words_lang(language: Optional[str]) -> Optional[str]:
return None
def _plain_lang_code(language: Optional[str]) -> Optional[str]:
"""Resolve a request language to a bare ISO code, with no num2words gate.
:func:`_num2words_lang` answers "may I call num2words for this?" and so
returns ``None`` for ko/ja/zh/th/vi. Rules that are not num2words-backed
need the code itself, which is what this returns.
"""
if not language:
return None
s = str(language).strip().lower()
if not s or s == "auto":
return None
code = _FULL_NAME_TO_CODE.get(s)
if code:
return code
m = _ISO_CODE_RE.match(s)
if m:
return _ISO_ALIASES.get(m.group(1), m.group(1))
return None
# ── Digit ranges ─────────────────────────────────────────────────────────────
# "20~30" loses its separator at the engine and reads as ONE number: OmniVoice
# says "이십삼" (23) for "20~30초". Speak the separator instead. Verified by
# rendering each form and transcribing it back (ko, OmniVoice):
# "20~30초" → heard "23초" ✗
# "20에서 30초" → heard "20에서 30초" ✓
# Only the tilde family is rewritten — those are unambiguously range marks
# between digits. An ASCII hyphen is left alone on purpose: it also spells
# dates, phone numbers and product codes, where "to" would be wrong.
#: Spacing is part of the form, not decoration: a Korean postposition binds to
#: the numeral ("20에서 30"), Japanese and Chinese set no spaces at all, and
#: English needs them on both sides.
_RANGE_FORM = {
"ko": "{a}에서 {b}",
"ja": "{a}から{b}",
"zh": "{a}{b}",
"en": "{a} to {b}",
}
#: ASCII tilde, wave dash, fullwidth tilde — Japanese and Korean IMEs emit the
#: latter two, so all three have to match.
#:
#: Match complete signed/decimal endpoints; reject partial numbers and product
#: codes while allowing adjacent CJK units. Guard all tilde forms so malformed
#: chains cannot be partially rewritten, including when their separators have
#: whitespace around them.
_RANGE_MARKS = "~\u301c\uff5e"
_RANGE_ENDPOINT = r"[+-]?(?:\d{1,6}(?:\.\d{1,6})?|\.\d{1,6})"
_NUM_RANGE_RE = re.compile(
rf"(?<![\d.,A-Za-z+{_RANGE_MARKS}-])({_RANGE_ENDPOINT})"
rf"\s*[{_RANGE_MARKS}]\s*({_RANGE_ENDPOINT})"
rf"(?![\d.,A-Za-z+{_RANGE_MARKS}-])"
)
def _speak_number_ranges(text: str, lang: str) -> str:
"""Speak complete tilde ranges only for languages with a verified form."""
form = _RANGE_FORM.get(lang)
if not form:
return text
def replace(match: re.Match) -> str:
before, after = match.start() - 1, match.end()
while before >= 0 and text[before].isspace():
before -= 1
while after < len(text) and text[after].isspace():
after += 1
if ((before >= 0 and text[before] in _RANGE_MARKS)
or (after < len(text) and text[after] in _RANGE_MARKS)):
return match.group(0)
return form.format(a=match.group(1), b=match.group(2))
return _NUM_RANGE_RE.sub(replace, text)
# ── Universal safety filters (all languages) ─────────────────────────────────
# Zero-width & bidi controls, C0/C1 controls (except \t \n \r), BOM, U+FFFD.
@@ -487,6 +570,11 @@ def normalize_text(text: str, language: Optional[str] = None) -> str:
if not text:
return text or ""
out = _safety_filters(text)
# Runs outside the num2words gate below: ko/ja/zh keep their digits (that
# gate returns None for them) but still need the range mark spoken.
plain = _plain_lang_code(language)
if plain:
out = _outside_brackets(out, lambda t: _speak_number_ranges(t, plain))
lang = _num2words_lang(language)
if lang:
if lang in _ABBREV_COMPILED:
+41 -18
View File
@@ -4,7 +4,7 @@ Resolution priority (highest → lowest):
1. app `settings_store.get_hf_token()` (encrypted in SQLite)
2. env `HF_TOKEN` or the legacy `HUGGING_FACE_HUB_TOKEN` env var
3. hf-cli `huggingface_hub.get_token()` (canonical ~/.cache/huggingface/token)
3. hf-cli the selected local Hub token file (`HF_TOKEN_PATH`)
For each candidate, the resolver calls `huggingface_hub.whoami(token=...)`
to verify the token is live; any HTTP error (401, 403, network) skips to
@@ -20,6 +20,7 @@ from __future__ import annotations
import hashlib
import logging
import os
from pathlib import Path
import threading
import time
from dataclasses import dataclass
@@ -46,7 +47,7 @@ class SourceState:
set: bool
masked: Optional[str]
whoami_user: Optional[str]
whoami_ok: bool
whoami_ok: Optional[bool]
# ── module-level cache ────────────────────────────────────────────────────
@@ -79,19 +80,26 @@ def _read_app() -> Optional[str]:
return None
def _clean_token(value: Optional[str]) -> Optional[str]:
if not value:
return None
return value.replace("\r", "").replace("\n", "").strip() or None
def _read_env() -> Optional[str]:
# HF docs explicitly accept either name; user may have either exported.
val = os.environ.get("HF_TOKEN") or os.environ.get("HUGGING_FACE_HUB_TOKEN")
return val or None
return _clean_token(val)
def _read_hf_cli() -> Optional[str]:
try:
import huggingface_hub
tok = huggingface_hub.get_token()
return tok or None
from huggingface_hub import constants
return _clean_token(Path(constants.HF_TOKEN_PATH).read_text(encoding="utf-8"))
except FileNotFoundError:
return None
except Exception:
logger.exception("huggingface_hub.get_token failed")
logger.warning("Could not read the local Hugging Face token file")
return None
@@ -184,17 +192,17 @@ def on_401(active_source: Source) -> Optional[ResolvedToken]:
return resolve(skip=frozenset({active_source}))
def state() -> dict:
def state(*, validate: bool = False) -> dict:
"""Return one SourceState per priority position so the Settings UI can
render the cascade table. Includes a masked token + whoami result;
never includes the raw token."""
never includes the raw token. Reads are local unless validation is explicitly requested."""
rows: list[SourceState] = []
active: Optional[Source] = None
for source in _PRIORITY:
token = _READERS[source]()
if token:
username = _validate(source, token)
ok = username is not None
username = _validate(source, token) if validate else None
ok = (username is not None) if validate else None
rows.append(SourceState(
source=source,
set=True,
@@ -249,15 +257,30 @@ def save_app_token(token: str) -> None:
invalidate_cache()
def clear_hf_cli_tokens() -> None:
"""Remove recognized Hub token files without refreshing or revoking tokens."""
from core.config import HF_CLI_TOKEN_PATHS
from huggingface_hub import constants
# Hub's active path remains authoritative if imported before app config.
paths = set(HF_CLI_TOKEN_PATHS) | {constants.HF_TOKEN_PATH}
failed = False
for token_path in paths:
path = Path(token_path)
for target in (path, path.parent / "stored_tokens"):
try:
target.unlink(missing_ok=True)
except OSError:
failed = True
invalidate_cache()
if failed:
raise OSError("Could not clear all local Hugging Face token files")
def clear_app_token(also_clear_hf_cli: bool = False) -> None:
"""Remove from the encrypted settings store; optionally also call
`huggingface_hub.logout()` to clear the canonical HF file."""
"""Clear the encrypted app token, optionally recognized local Hub files."""
from services import settings_store
settings_store.clear_hf_token()
if also_clear_hf_cli:
try:
import huggingface_hub
huggingface_hub.logout()
except Exception:
logger.exception("huggingface_hub.logout failed (non-fatal)")
clear_hf_cli_tokens()
invalidate_cache()
+63
View File
@@ -17,6 +17,8 @@ from __future__ import annotations
import asyncio
import importlib
import logging
import functools
import re
import os
import shutil
import subprocess
@@ -91,6 +93,8 @@ REGISTRY: dict[str, dict] = {
"probe_module": "openai",
"category": "llm",
"needs_key": True,
# A core dependency: Settings → LLM Providers uses it too.
"builtin": True,
"notes": (
"Uses the LLM provider you configure in Settings → LLM Providers "
"(route it via the 'Dub translation' skill in Settings → LLM Skills): "
@@ -181,6 +185,65 @@ def list_engines() -> list[dict]:
return out
def _normalize(name: str) -> str:
"""A distribution name in PEP 503 form (deep_translator == deep-translator)."""
return re.sub(r"[-_.]+", "-", name).lower()
@functools.lru_cache(maxsize=1)
def _app_dependency_names() -> frozenset[str]:
"""Distribution names VoiceStudio itself requires, normalized.
Read from the installed package metadata, so it follows the lockfile with
no second list to keep in step. Without metadata this guards nothing
rather than failing.
"""
try:
from importlib.metadata import requires
reqs = requires("omnivoice") or []
except Exception: # noqa: BLE001
return frozenset()
names = set()
for req in reqs:
if "extra ==" in req:
continue
names.add(_normalize(re.split(r"[\s;<>=!~\[@(]", req, maxsplit=1)[0]))
return frozenset(names)
def uninstall_blocker(engine_id: str) -> "tuple[int, str] | None":
"""Why removing this engine's package would break something, or None.
`pip uninstall` acts on the app's own environment. A package VoiceStudio
depends on (openai, argostranslate) would break the app, and a package
other translation engines share (deep_translator backs four) would break
those engines too.
"""
entry = REGISTRY.get(engine_id)
pkg = entry.get("pip_package") if entry else None
if not pkg:
return None
if _normalize(pkg) in _app_dependency_names():
return 400, (
f"{entry['display_name']} uses {pkg}, which VoiceStudio itself "
"depends on. Uninstalling it would break the app."
)
sharing = [
other["display_name"]
for other_id, other in REGISTRY.items()
if other_id != engine_id
and other.get("pip_package")
and _normalize(other["pip_package"]) == _normalize(pkg)
]
if sharing:
return 409, (
f"{entry['display_name']} shares {pkg} with {', '.join(sharing)}. "
"Uninstalling it would stop those working too."
)
return None
def get_engine(engine_id: str) -> dict | None:
return REGISTRY.get(engine_id)
+187 -22
View File
@@ -300,6 +300,31 @@ class TTSBackend(ABC):
#: 0 means "no meaningful floor" (CPU-class engines) and never warns.
min_vram_gb: float = 0.0
@classmethod
def runtime_compute_profile(cls, caps) -> dict:
"""Resolved compute metadata for this engine on the current host.
Most engines have one implementation whose static declarations are
sufficient. Native adapters may override this single hook when the
installed executable determines both the available runtimes and the
device actually selected.
"""
from services.engine_routing import resolve_routing
gpu_compat = tuple(getattr(cls, "gpu_compat", ("cpu",)))
min_vram_gb = float(getattr(cls, "min_vram_gb", 0.0) or 0.0)
return {
"gpu_compat": gpu_compat,
"min_vram_gb": min_vram_gb,
**resolve_routing(gpu_compat, caps, min_vram_gb),
"runtime_backend": None,
"runtime_device_index": None,
"runtime_device_name": None,
"runtime_hardware_family": None,
"runtime_vram_gb": None,
"runtime_device_verified": None,
}
#: True when generation allocates in ANOTHER process — a dedicated-venv
#: sidecar (SubprocessBackend) or a spawned binary (omnivoice-gguf).
#: Parent-process accelerator counters cannot see those allocations, so
@@ -566,7 +591,12 @@ def _get_clone_prompt(
):
"""Return a cached/precomputed ``VoiceClonePrompt`` for
(ref_audio, ref_text, preprocess_prompt), or ``None`` to fall back to the
inline ref path. Never raises.
inline ref path.
Raises only on a device OOM that survives a cache-drop retry (#1790): the
inline path is the same allocation on the same device, so falling back to
it after an OOM cannot succeed and has been observed taking the whole
process down instead. Every other failure still falls back silently.
``store=False`` still *reads* the cache (a hit is free) but never inserts:
it exists for single-use references a dub's per-segment ref clips are each
@@ -596,10 +626,43 @@ def _get_clone_prompt(
ref_audio, ref_text=ref_text, preprocess_prompt=preprocess_prompt
)
except Exception as e: # noqa: BLE001 — fall back, never break synthesis
logger.warning(
"voice-clone prompt precompute failed; using inline ref: %s", e
)
return None
# #1790/#1777: a GPU OOM is the one failure this fallback cannot
# absorb. `generate()`'s inline ref path runs the SAME encode on the
# SAME device — the docstring above says so, because producing
# identical output is the point — so returning None after an OOM
# guarantees a second OOM moments later, on a device with even less
# headroom than the first attempt found. Both reporters' backends
# then died with a Windows access violation (exit code
# -1073741819) seconds after this exact log line, mid-generation on
# a GPU that had just refused an 86 MiB allocation.
#
# An OOM here is also the most recoverable kind: the allocator is
# typically holding reserved-but-unallocated blocks (#1790's own
# log reports 90 MiB reserved against an 86 MiB request). Drop them
# and try once more. If it still will not fit, raise — the failure
# layer turns a device OOM into the actionable GPU_OOM message
# ("close other GPU-heavy apps or unload models…"), which is a far
# better answer than walking into a native fault.
from core.failure import is_gpu_oom
if is_gpu_oom(e):
logger.warning(
"voice-clone prompt precompute hit a device OOM (%s) — "
"releasing allocator caches and retrying once", e,
)
try:
from services.model_manager import free_vram
free_vram()
except Exception: # noqa: BLE001 — reclaim is best-effort
logger.debug("VRAM reclaim before OOM retry failed", exc_info=True)
prompt = model.create_voice_clone_prompt(
ref_audio, ref_text=ref_text, preprocess_prompt=preprocess_prompt
)
else:
logger.warning(
"voice-clone prompt precompute failed; using inline ref: %s", e
)
return None
if store:
_prompt_disk_save(key, prompt)
if not store:
@@ -2197,6 +2260,13 @@ _LAZY_REGISTRY: dict[str, tuple[str, str]] = {
# 2026-07-02 (CPU, Apple Silicon; 22.05 kHz output). Gated behind
# OMNIVOICE_CONFUCIUS4_TTS_DIR so it's inert until enabled.
"confucius4-tts": ("engines.confucius4", "Confucius4Backend"),
# audio.cpp (0xShug0/audio.cpp) — pure-C++ ggml runtime, no Python venv.
# v1 serves Breeze-TTS-2 (en+zh, clone+design) through a parent-managed
# audiocpp_server over loopback HTTP. Gated behind a server binary
# (OMNIVOICE_AUDIOCPP_BIN) so it's inert until enabled. Lazy for the
# same import-cycle reason as the entries above (engines.audiocpp
# imports services.tts_backend for TTSBackend).
"audiocpp": ("engines.audiocpp", "AudioCPPBackend"),
}
@@ -2298,9 +2368,10 @@ _INSTALL_HINTS: dict[str, str] = {
"omnivoice-gguf":"Bundled — runs the C++ omnivoice-tts binary in bin/. Quants download lazily from Serveurperso/OmniVoice-GGUF on first generate.",
"supertonic3": "uv sync --extra supertonic (CPU-only ONNX, 31 langs, ~400 MB model on first use; OpenRAIL-M model license)",
"pockettts": "uv sync --extra pockettts (Kyutai, CPU-only, ~100 MB model on first use; MIT code + CC-BY-4.0 weights; HF-gated, review terms and set HF_TOKEN)",
"moss-tts-v15": "git clone OpenMOSS/MOSS-TTS + set OMNIVOICE_MOSS_TTS_V15_DIR (own venv, transformers==5.0; 8B, ~16 GB weights; CUDA/CPU, no MPS; Apache-2.0)",
"moss-tts-v15": "git clone OpenMOSS/MOSS-TTS + set OMNIVOICE_MOSS_TTS_V15_DIR (own venv, transformers==5.0; 8B, ~16 GB weights; CUDA/ROCm/XPU/NPU/CPU, no MPS; Apache-2.0)",
"dots-tts": "git clone rednote-hilab/dots.tts + set OMNIVOICE_DOTS_TTS_DIR (own venv, transformers==4.57; 2B, ~9 GB weights; CUDA/CPU, Linux/macOS only — no Windows; Apache-2.0)",
"confucius4-tts":"git clone netease-youdao/Confucius4-TTS + set OMNIVOICE_CONFUCIUS4_TTS_DIR (own Python 3.10 venv; 14-lang cross-lingual zero-shot clone; ~5 GB weights auto-download; CUDA/CPU, no MPS; Apache-2.0)",
"confucius4-tts":"git clone netease-youdao/Confucius4-TTS + set OMNIVOICE_CONFUCIUS4_TTS_DIR (own Python 3.10 venv; 14-lang cross-lingual zero-shot clone; ~5 GB weights auto-download; CUDA/ROCm/XPU/NPU/CPU, no MPS; Apache-2.0)",
"audiocpp": "download the matching audio.cpp v0.7.2 prebuilt + set OMNIVOICE_AUDIOCPP_BIN, then explicitly install Breeze-TTS-2 in Model Catalogue → Models (native CPU/Vulkan/CUDA/Metal GGUF server, no Python; en+zh clone+design; ~4.73 GiB; weights research/non-commercial only)",
}
@@ -2321,6 +2392,51 @@ _SETUP_SNIPPETS: dict[str, str] = {
}
# Per-engine documentation page, as a repo-relative path (#1866). Every one of
# these docs already exists and several are CI-guarded against the code they
# describe (e.g. tests/test_cosyvoice_install_docs.py), but nothing in the app
# linked to them, so the point of failure — an unavailable engine row — was a
# dead end. Paths rather than URLs so tests/test_engine_docs.py can assert the
# file is really there; the URL is built once, at read time, from core.links.
#
# Keyed on the engine id, so it stays correct when the doc filename does not
# match the id (indextts2 → indextts.md).
_ENGINE_DOCS: dict[str, str] = {
"omnivoice": "docs/engines/omnivoice.md",
"omnivoice-subprocess": "docs/engines/omnivoice-subprocess.md",
"omnivoice-gguf": "docs/engines/omnivoice-gguf.md",
"cosyvoice": "docs/engines/cosyvoice.md",
"kittentts": "docs/engines/kittentts.md",
"mlx-audio": "docs/engines/mlx-audio.md",
"voxcpm2": "docs/engines/voxcpm2.md",
"moss-tts-nano": "docs/engines/moss-tts-nano.md",
"moss-tts-v15": "docs/engines/moss-tts-v15.md",
"dots-tts": "docs/engines/dots-tts.md",
"confucius4-tts": "docs/engines/confucius4-tts.md",
"indextts2": "docs/engines/indextts.md",
"gpt-sovits": "docs/engines/gpt-sovits.md",
"sherpa-onnx": "docs/engines/sherpa-onnx.md",
"supertonic3": "docs/engines/supertonic3.md",
"pockettts": "docs/engines/pockettts.md",
"audiocpp": "docs/engines/audio-cpp.md",
}
def _engine_docs_url(bid: str) -> str | None:
"""Public URL of this engine's doc page, or None when it has none.
VoiceStudio-owned constant either way: the path comes from the registry
above and the base from :mod:`core.links`, so no part of it is derived
from an engine probe. That is what lets it cross the public boundary
intact (see api.public_engine_metadata).
"""
path = _ENGINE_DOCS.get(bid)
if not path:
return None
from core import links
return f"{links.PROJECT_REPO_BLOB_MAIN}/{path}"
# Short, readable labels for mlx-audio's curated models (#981) — surfaced in
# the Model Catalogue → Engines model picker so users see more than a bare key.
# Single-sourced here rather than on MLXAudioBackend.CURATED_MODELS itself so
@@ -2347,14 +2463,24 @@ def _sidecar_installable_ids() -> frozenset[str]:
button into their matrix rows.
"""
try:
from services.sidecar_install import SPECS
return frozenset(SPECS)
# Host-aware: an engine whose installer cannot work on THIS machine
# (dots.tts on Windows, a CUDA-only install on a CPU host) must not get
# an Install button that can only fail.
from services.sidecar_install import installable_engine_ids
return installable_engine_ids()
except Exception: # pragma: no cover — defensive only
return frozenset()
def list_backends() -> list[dict]:
"""Enumerate every registered backend with its availability state.
def list_backends(*, include_hidden: bool = False) -> list[dict]:
"""Enumerate the engine catalogue with each backend's availability state.
On MPS, the canonical ``omnivoice`` id already resolves to the killable
OmniVoice sidecar. The explicit ``omnivoice-subprocess`` compatibility id
is therefore omitted from the normal catalogue so the picker does not
advertise two choices with the same runtime behavior. Internal callers
that must validate or preserve a stored compatibility id can pass
``include_hidden=True``.
Per-entry shape (ENGINE-05 + ENGINE-06):
@@ -2368,10 +2494,11 @@ def list_backends() -> list[dict]:
# e.g. VoxCPM2's >=2.0.3 upgrade hint)
"install_hint": Optional[str],
"setup_snippet": Optional[str], # exact `export VAR=...` for path-gated opt-in engines
"docs_url": Optional[str], # this engine's doc page (registry-authored constant)
"one_click_install": bool, # services.sidecar_install can provision it in-app
"last_error": Optional[str], # cached most-recent failure
"isolation_mode": "in-process" | "subprocess",
"gpu_compat": list[str], # subset of {cuda, rocm, mps, xpu, cpu}
"gpu_compat": list[str], # subset of {cuda, rocm, mps, vulkan, xpu, npu, cpu}
"supports_cloning": Optional[bool], # True/False from the class attr; None when
# model-dependent (property, e.g. mlx-audio)
"effective_device": str, # device this engine uses on THIS host
@@ -2401,12 +2528,17 @@ def list_backends() -> list[dict]:
from core.device_caps import detect_host_caps
from services.engine_disk_usage import disk_summary_for
from services.engine_evidence import snapshot as execution_snapshot
from services.engine_routing import routing_fields
caps = detect_host_caps()
installable = _sidecar_installable_ids()
out: list[dict] = []
for bid, cls in _REGISTRY.items():
if (
not include_hidden
and caps.family == "mps"
and bid == "omnivoice-subprocess"
):
continue
cls = _effective_backend_class(bid, cls, caps.family)
try:
ok, msg = cls.is_available()
@@ -2427,14 +2559,40 @@ def list_backends() -> list[dict]:
isolation = "subprocess"
else:
isolation = "in-process"
gpu_compat = getattr(cls, "gpu_compat", ("cpu",))
from services.engine_routing import resolve_routing, runtime_compute_profile
try:
profile = runtime_compute_profile(cls, caps)
except Exception:
# Runtime-aware native probes remain optional metadata. A broken
# provider probe must not take down the engine picker, especially
# when availability already explains a missing binary or model.
compat = tuple(getattr(cls, "gpu_compat", ("cpu",)))
floor = float(getattr(cls, "min_vram_gb", 0.0) or 0.0)
profile = {
"gpu_compat": compat,
"min_vram_gb": floor,
**resolve_routing(compat, caps, floor),
"runtime_backend": None,
"runtime_device_index": None,
"runtime_device_name": None,
"runtime_hardware_family": None,
"runtime_vram_gb": None,
"runtime_device_verified": None,
}
gpu_compat = profile["gpu_compat"]
# Cloning capability: same descriptor guard as
# cloning_capable_engine_ids() — a class-level getattr on a *property*
# (mlx-audio: capability depends on the picked model) returns the
# descriptor, not a bool, so report None (= model-dependent) there
# instead of an always-truthy false positive.
_clone = getattr(cls, "supports_cloning", True)
routing = routing_fields(gpu_compat, caps, getattr(cls, "min_vram_gb", 0.0))
from core.scrub import scrub_text
routing = {
"effective_device": profile["effective_device"],
"routing_status": profile["routing_status"],
"routing_reason": scrub_text(profile["routing_reason"])
if profile["routing_reason"] else None,
}
loaded_instance = None
if _active_instance_id == bid:
loaded_instance = _active_instance
@@ -2455,6 +2613,10 @@ def list_backends() -> list[dict]:
"install_hint": _INSTALL_HINTS.get(bid),
# Exact `export VAR=...` line for path-gated opt-in engines, or None.
"setup_snippet": _SETUP_SNIPPETS.get(bid),
# This engine's doc page (#1866). Registry-authored constant, so it
# survives api.public_engine_metadata and gives an unavailable row
# somewhere to send the user.
"docs_url": _engine_docs_url(bid),
# True when services.sidecar_install can provision this engine
# in-app (Settings renders an Install button instead of leading
# with the manual setup snippet).
@@ -2464,7 +2626,7 @@ def list_backends() -> list[dict]:
"isolation_mode": isolation,
"gpu_compat": list(gpu_compat),
# effective_device / routing_status / routing_reason (scrubbed):
"min_vram_gb": getattr(cls, "min_vram_gb", 0.0) or None,
"min_vram_gb": profile["min_vram_gb"] or None,
# effective_device / routing_status / routing_reason (scrubbed);
# the reason now also carries the under-provisioned-GPU caveat.
**routing,
@@ -2472,7 +2634,7 @@ def list_backends() -> list[dict]:
engine_id=bid,
engine_cls=cls,
instance=loaded_instance,
routing=routing,
routing={**profile, **routing},
caps=caps,
),
})
@@ -2554,7 +2716,9 @@ def active_routing() -> dict | None:
"""
try:
active = active_backend_id()
for b in list_backends():
# The MPS picker intentionally hides the redundant compatibility id,
# but routing must still describe a saved or environment-pinned id.
for b in list_backends(include_hidden=True):
if b.get("id") == active:
return {
"engine": active,
@@ -2894,10 +3058,9 @@ async def resolve_generation_backend(
raise ValueError(f"TTS engine '{engine_id}' is not available: {_mask_hf_tokens(msg)}")
from core.device_caps import detect_host_caps
from services.engine_routing import resolve_routing
routing = resolve_routing(
getattr(backend_cls, "gpu_compat", ("cpu",)), detect_host_caps(),
getattr(backend_cls, "min_vram_gb", 0.0),
from services.engine_routing import runtime_compute_profile_async
routing = await runtime_compute_profile_async(
backend_cls, detect_host_caps()
)
if routing["routing_status"] == "unavailable":
raise ValueError(routing["routing_reason"])
@@ -2935,4 +3098,6 @@ def __getattr__(name: str): # pragma: no cover - exercised via tests
return _REGISTRY[name if name in _REGISTRY else None]
if name == "IndexTTS2Backend":
return _REGISTRY["indextts2"]
if name == "AudioCPPBackend":
return _REGISTRY["audiocpp"]
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
@@ -7,13 +7,15 @@ old silence-only guard missed it (the buzz is loud, not silent) so the garbage
was cached and served.
These tests cover the fix *without the 5 GB model / a GPU*: they drive the pure
``_spectral_flatness`` / ``_is_unusable_audio`` helpers with synthetic signals,
and assert the render constants didn't regress. The real end-to-end render is
verified manually (spectral flatness back in the speech range + Whisper ASR).
``_spectral_flatness`` / ``_is_unusable_audio`` helpers with synthetic tones and
tracked speech demo renders, and assert the render constants did not regress.
"""
from __future__ import annotations
import math
from pathlib import Path
import soundfile as sf
import pytest
@@ -39,6 +41,13 @@ def _white_noise() -> "torch.Tensor":
return 0.5 * (torch.rand(N, generator=g) * 2 - 1)
def _two_tone_buzz() -> "torch.Tensor":
"""Two inharmonic partials — the other shape a collapsed render takes."""
t = torch.arange(N, dtype=torch.float32) / SR
s = torch.sin(2 * math.pi * 180.0 * t) + 0.6 * torch.sin(2 * math.pi * 361.0 * t)
return 0.8 * s / s.abs().max()
def _speech_like() -> "torch.Tensor":
"""Broadband + harmonic + amplitude-modulated — a coarse stand-in for voiced
speech: several harmonics (formant-ish), additive noise (consonants), and a
@@ -85,6 +94,71 @@ def test_speech_like_is_usable():
assert arch._is_unusable_audio(_speech_like()) is False
# ── Threshold stays between the two things it has to separate ───────────────
# Synthetic broadband speech has much higher flatness than real voiced audio.
# Measure both sides of the threshold against actual inputs, including the
# existing demo renders that the old thresholds rejected.
def test_tonal_ceiling_is_measured_not_assumed():
"""Derive the tonal side of the margin instead of trusting a literal.
A bare constant would keep passing if `_spectral_flatness` stopped scoring
tones near zero, so measure the degenerate signals here and require the
threshold to clear the worst of them tenfold.
"""
tones = [
arch._spectral_flatness(_pure_tone(80.0)),
arch._spectral_flatness(_pure_tone(220.0)),
arch._spectral_flatness(_two_tone_buzz()),
]
assert all(t is not None for t in tones)
assert max(tones) * 10 < arch._DEGENERATE_FLATNESS
_SAMPLES = Path(__file__).resolve().parents[1] / "assets" / "samples"
_SPEECH_FIXTURES = [
"demo_voice.wav",
"demo_clone_output.wav",
*[f"voice_design/demo_voice_design_{name}.wav" for name in (
"audiobook_uk_narrator", "aussie_podcaster", "bedtime_storyteller",
"gravelly_villain", "indian_support_agent", "mandarin_sichuan", "us_news_anchor",
)],
*[f"dictation/{name}.wav" for name in (
"en_conversational", "en_technical", "fr_reservation",
)],
*[f"demo/dubbing/{name}.src.wav" for name in (
"source", "dubbed_es", "dubbed_fr", "dubbed_ja", "dubbed_zh",
)],
]
@pytest.mark.parametrize("fixture", _SPEECH_FIXTURES)
def test_real_shipped_speech_clears_quality_floor(fixture):
# These are existing tracked demo renders, not synthesized stand-ins or
# asserted measurements. Loading PCM needs neither a model nor a network.
audio, _sample_rate = sf.read(_SAMPLES / fixture, dtype="float32", always_2d=True)
speech = torch.from_numpy(audio.T)
flatness = arch._spectral_flatness(speech)
assert flatness is not None
assert flatness > arch._DEGENERATE_FLATNESS * 10
assert arch._is_unusable_audio(speech) is False
def test_flatness_is_not_clip_length_dependent():
"""Repeating a signal must not change what it measures.
The whole-clip FFT this replaced failed exactly here: its frequency
resolution grew with duration, so the same audio measured 0.0229 at 3 s and
~0 at 12 s (100% drift). Framed, the drift is under 0.1%.
"""
short = _speech_like()
long = torch.cat([short] * 4)
a, b = arch._spectral_flatness(short), arch._spectral_flatness(long)
assert a is not None and b is not None
assert abs(a - b) / a < 0.02
# ── Constants didn't regress ────────────────────────────────────────────────
def test_preview_render_constants():
# 16 steps under-converged on the social script; the fix bumped it.
@@ -11,6 +11,7 @@ that the error message tells the user what to do.
import asyncio
import os
import sys
import threading
import time
import pytest
@@ -75,6 +76,62 @@ def test_fast_transcribe_passes_through():
pool.shutdown(wait=True)
def test_timeout_defers_abandon_cleanup_until_running_worker_finishes():
"""A timed-out native worker may still be reading request-owned inputs."""
pool = ThreadPoolExecutor(max_workers=1)
started = threading.Event()
finish = threading.Event()
cleaned = threading.Event()
def _slow():
started.set()
finish.wait(timeout=5)
assert not cleaned.is_set()
return "done"
async def _go():
with pytest.raises(ASRTimeoutError):
await run_transcribe_guarded(
pool,
_slow,
what="Convert",
timeout=0.05,
on_abandon=cleaned.set,
)
assert started.is_set()
assert not cleaned.is_set()
finish.set()
await asyncio.to_thread(cleaned.wait, 2)
assert cleaned.is_set()
try:
asyncio.run(_go())
finally:
finish.set()
pool.shutdown(wait=True)
def test_normal_completion_keeps_abandon_cleanup_with_caller():
pool = ThreadPoolExecutor(max_workers=1)
cleaned = threading.Event()
async def _go():
result = await run_transcribe_guarded(
pool,
lambda: "done",
what="Convert",
timeout=5,
on_abandon=cleaned.set,
)
assert result == "done"
assert not cleaned.is_set()
try:
asyncio.run(_go())
finally:
pool.shutdown(wait=True)
def test_timeout_error_is_a_timeouterror_subclass():
# Routers that catch broad TimeoutError (openai_compat) must also catch ours.
assert issubclass(ASRTimeoutError, TimeoutError)
+36
View File
@@ -112,6 +112,42 @@ class TestEnqueue:
job = client.get(f"/batch/jobs/{job_id}").json()
assert job["filename"] == "test.mp4"
@pytest.mark.asyncio
async def test_upload_is_persisted_in_bounded_chunks(self, batch, tmp_path):
class RecordingUpload:
def __init__(self):
self.read_sizes = []
self.remaining = b"video"
async def read(self, size):
self.read_sizes.append(size)
chunk, self.remaining = self.remaining[:size], self.remaining[size:]
return chunk
upload = RecordingUpload()
destination = tmp_path / "video.mp4"
await batch._save_upload(upload, str(destination))
assert destination.read_bytes() == b"video"
assert upload.read_sizes == [batch._UPLOAD_CHUNK_BYTES, batch._UPLOAD_CHUNK_BYTES]
@pytest.mark.asyncio
async def test_failed_upload_removes_partial_file(self, batch, tmp_path):
class FailingUpload:
calls = 0
async def read(self, _size):
self.calls += 1
if self.calls == 1:
return b"partial"
raise OSError("upload interrupted")
destination = tmp_path / "video.mp4"
with pytest.raises(OSError, match="upload interrupted"):
await batch._save_upload(FailingUpload(), str(destination))
assert not destination.exists()
class TestListJobs:
def test_empty(self, client):
@@ -120,6 +120,7 @@ def test_drain_fd_is_explicitly_inherited_by_wrapper_but_not_operation(monkeypat
proc.wait(timeout=5)
@pytest.mark.skipif(os.name != "posix", reason="Unix drain pipe contract")
def test_invalid_or_missing_desktop_drain_fd_fails_safe(monkeypatch):
monkeypatch.setenv("OMNIVOICE_DESKTOP_CONTAINED", "1")
monkeypatch.setenv("OMNIVOICE_DESKTOP_DRAIN_FD", "not-an-fd")
@@ -257,3 +258,90 @@ def test_windows_assignment_failure_kills_suspended_unowned_child(monkeypatch):
names = [event[0] for event in events]
assert names.index("assign") < names.index("terminate") < names.index("kill")
assert names.index("kill") < names.index("wait") < names.index("write")
def test_windows_direct_job_owner_assigns_before_resume(monkeypatch):
"""Windows skips the extra Python wrapper but retains pre-start Job ownership."""
events = []
job = 99
kernel = type("Kernel", (), {})()
kernel.AssignProcessToJobObject = _Call(
lambda assigned_job, process: events.append(("assign", assigned_job, process)) or True
)
kernel.TerminateJobObject = _Call(
lambda assigned_job, code: events.append(("terminate", assigned_job, code)) or True
)
kernel.CloseHandle = _Call(
lambda handle: events.append(("close", getattr(handle, "value", handle))) or True
)
monkeypatch.setattr(owned, "_windows_job", lambda: (job, kernel, wintypes))
monkeypatch.setattr(
owned,
"_resume_windows_process",
lambda _kernel, _types, pid: events.append(("resume", pid)),
)
class Child:
_handle = 77
pid = 123
args = ["operation.exe"]
stdin = None
stdout = object()
stderr = object()
returncode = None
def poll(self):
return self.returncode
def wait(self, timeout=None):
events.append(("wait", timeout))
return self.returncode
def kill(self):
events.append(("kill",))
child = Child()
def fake_popen(argv, **kwargs):
events.append(("spawn", argv, kwargs))
return child
monkeypatch.setattr(owned.subprocess, "Popen", fake_popen)
proc = owned._spawn_windows_owned(
["operation.exe"],
{
"env": {
"KEEP": "yes",
"OMNIVOICE_DESKTOP_CONTAINED": "1",
"OMNIVOICE_DESKTOP_DRAIN_FD": "42",
},
"creationflags": 0x00000200,
},
)
names = [event[0] for event in events]
assert names[:3] == ["spawn", "assign", "resume"]
spawn_argv, spawn_kwargs = events[0][1:]
assert spawn_argv == ["operation.exe"]
assert spawn_kwargs["creationflags"] == 0x08000204
assert spawn_kwargs["env"] == {"KEEP": "yes"}
assert proc.stdout is child.stdout
child.returncode = 0
assert proc.poll() == 0
assert [event[0] for event in events][-2:] == ["terminate", "close"]
def test_spawn_owned_selects_direct_windows_job_path(monkeypatch):
sentinel = object()
calls = []
monkeypatch.setattr(owned.os, "name", "nt")
monkeypatch.setattr(
owned,
"_spawn_windows_owned",
lambda argv, kwargs: calls.append((argv, kwargs)) or sentinel,
)
assert owned.spawn_owned(["sidecar.exe"], text=True) is sentinel
assert calls == [(["sidecar.exe"], {"text": True})]
@@ -15,6 +15,15 @@ import pytest
from core import contained_subprocess as owned
# This module simulates macOS by deleting os.waitid, then drives the fallback
# with os.waitpid/os.WNOHANG and start_new_session — POSIX-only APIs that
# Windows does not have at all (os.WNOHANG raises AttributeError before the
# first assertion). CI runs this suite on Linux, so nothing is lost by
# skipping; what is gained is a Windows contributor whose checkout runs green.
pytestmark = pytest.mark.skipif(
os.name != "posix", reason="simulates a POSIX platform without os.waitid"
)
def _make_owned(argv):
cr, cw = os.pipe()
+261 -1
View File
@@ -160,6 +160,96 @@ def test_engine_catalogue_reports_effective_mps_isolation(monkeypatch):
assert row["isolation_mode"] == "subprocess"
def test_mps_catalogue_hides_redundant_explicit_omnivoice_sidecar(monkeypatch):
"""The picker advertises the canonical id, while legacy callers retain both."""
from core.device_caps import HostCaps
from services import tts_backend
monkeypatch.setattr(
tts_backend,
"_REGISTRY",
{
"omnivoice": OmniVoiceBackend,
"omnivoice-subprocess": OmniVoiceSubprocessBackend,
},
)
monkeypatch.setattr(
"core.device_caps.detect_host_caps",
lambda: HostCaps(family="mps", available_families=("mps", "cpu")),
)
monkeypatch.setattr(
OmniVoiceSubprocessBackend,
"is_available",
classmethod(lambda cls: (True, "ready")),
)
picker_ids = {item["id"] for item in list_backends()}
assert picker_ids == {"omnivoice"}
assert get_backend_class("omnivoice") is OmniVoiceMPSSubprocessBackend
all_ids = {item["id"] for item in list_backends(include_hidden=True)}
assert all_ids == {"omnivoice", "omnivoice-subprocess"}
assert get_backend_class("omnivoice-subprocess") is OmniVoiceSubprocessBackend
def test_mps_active_routing_preserves_hidden_compatibility_id(monkeypatch):
from core.device_caps import HostCaps
from services import tts_backend
monkeypatch.setattr(
tts_backend,
"_REGISTRY",
{"omnivoice-subprocess": OmniVoiceSubprocessBackend},
)
monkeypatch.setattr(tts_backend, "active_backend_id", lambda: "omnivoice-subprocess")
monkeypatch.setattr(
"core.device_caps.detect_host_caps",
lambda: HostCaps(family="mps", available_families=("mps", "cpu")),
)
monkeypatch.setattr(
OmniVoiceSubprocessBackend,
"is_available",
classmethod(lambda cls: (True, "ready")),
)
assert tts_backend.active_routing() == {
"engine": "omnivoice-subprocess",
"available": True,
"effective_device": "mps",
"routing_status": "accelerated",
"routing_reason": None,
}
@pytest.mark.parametrize("family", ("cuda", "cpu"))
def test_non_mps_catalogue_keeps_explicit_omnivoice_sidecar(monkeypatch, family):
from core.device_caps import HostCaps
from services import tts_backend
monkeypatch.setattr(
tts_backend,
"_REGISTRY",
{
"omnivoice": OmniVoiceBackend,
"omnivoice-subprocess": OmniVoiceSubprocessBackend,
},
)
monkeypatch.setattr(
"core.device_caps.detect_host_caps",
lambda: HostCaps(family=family, available_families=(family, "cpu")),
)
monkeypatch.setattr(
OmniVoiceSubprocessBackend,
"is_available",
classmethod(lambda cls: (True, "ready")),
)
assert {item["id"] for item in list_backends()} == {
"omnivoice",
"omnivoice-subprocess",
}
def test_mps_startup_does_not_preload_native_model(monkeypatch):
from core.device_caps import HostCaps
from services import model_manager
@@ -382,7 +472,17 @@ def test_mps_proxy_survives_fatal_child_exit_and_recovers(stub_sidecar, monkeypa
try:
with pytest.raises(RuntimeError, match="backend is still running"):
b.generate("CRASH")
assert b._proc is not None and b._proc.poll() is not None
assert b._proc is not None
# The child called os._exit; the parent raised the moment its pipe hit
# EOF, which is BEFORE the OS has reaped the process. Asserting poll()
# on the next line is a race the test happened to win on Linux and lost
# every time on Windows. Wait for the death instead of assuming it has
# already been observed — the claim is that the child is gone, not that
# it is gone within one instruction.
deadline = time.monotonic() + 5
while b._proc.poll() is None and time.monotonic() < deadline:
time.sleep(0.02)
assert b._proc.poll() is not None, "the crashed sidecar never died"
assert b.generate("ok").shape[1] == 24000
finally:
b.shutdown()
@@ -523,3 +623,163 @@ def test_generation_proxy_forwards_native_controls_and_seed():
"class_temperature": 0.8,
"seed": 321,
})]
def test_timeout_reaps_captured_process_before_recv_returns(monkeypatch):
import threading
class Process:
def __init__(self):
self.killed = threading.Event()
self.reaped = False
self.wait_entered = threading.Event()
self.release_wait = threading.Event()
def kill(self):
self.killed.set() # EOF may arrive before the process is reaped.
def wait(self, timeout):
assert timeout is not None
self.wait_entered.set()
assert self.release_wait.wait(2)
self.reaped = True
return -9
proc = Process()
backend = OmniVoiceSubprocessBackend()
backend._proc = proc
def recv():
assert proc.killed.wait(2)
return None
monkeypatch.setattr(backend, '_recv', recv)
returned = threading.Event()
results = []
def receive():
results.append(backend._recv_with_timeout(0.01))
returned.set()
reader = threading.Thread(target=receive)
reader.start()
try:
assert proc.wait_entered.wait(2)
assert not returned.wait(0.05), "EOF must not release the caller before process cleanup"
finally:
proc.release_wait.set()
reader.join(2)
backend._proc = None
assert not reader.is_alive()
assert returned.is_set()
assert results == [None]
assert proc.reaped
def test_timeout_never_kills_a_replacement_process(monkeypatch):
from unittest.mock import Mock
import services.subprocess_backend as module
class ManualTimer:
def __init__(self, _timeout, callback, args=()):
self.callback = lambda: callback(*args)
self.daemon = False
def start(self):
pass
def cancel(self):
pass
def join(self):
pass
timers = []
def timer(*args, **kwargs):
result = ManualTimer(*args, **kwargs)
timers.append(result)
return result
monkeypatch.setattr(module.threading, 'Timer', timer)
backend = OmniVoiceSubprocessBackend()
original, replacement = Mock(), Mock()
backend._proc = original
def recv():
backend._proc = replacement
timers[0].callback()
return None
monkeypatch.setattr(backend, '_recv', recv)
try:
backend._recv_with_timeout(1)
original.kill.assert_called_once()
replacement.kill.assert_not_called()
finally:
backend._proc = None
@pytest.mark.parametrize("failure", ["wait", "kill"])
def test_timeout_quarantine_blocks_reuse_and_retains_cleanup_handle(failure):
class StuckProcess:
stdin = None
def __init__(self):
self.exited = False
self.kill_calls = 0
def poll(self):
return 0 if self.exited else None
def kill(self):
self.kill_calls += 1
if failure == "kill" and not self.exited:
raise PermissionError("kill failed")
def terminate(self):
pass
def wait(self, timeout):
if not self.exited:
raise subprocess.TimeoutExpired("stuck-sidecar", timeout)
return 0
backend = OmniVoiceSubprocessBackend()
proc = StuckProcess()
backend._proc = proc
try:
backend._timeout_kill(proc)
with pytest.raises(RuntimeError, match="still stopping"):
backend._spawn()
backend.shutdown()
# Even after shutdown clears the current slot, ownership survives;
# retry must not silently start a second process next to this one.
before = proc.kill_calls
with pytest.raises(RuntimeError, match="still stopping"):
backend._spawn()
assert proc.kill_calls > before
finally:
proc.exited = True
backend.shutdown()
def test_timeout_quarantine_does_not_clear_or_kill_replacement():
from unittest.mock import Mock
backend = OmniVoiceSubprocessBackend()
original = Mock()
original.wait.side_effect = subprocess.TimeoutExpired("old-sidecar", 2)
replacement = Mock()
replacement.poll.return_value = None
backend._proc = replacement
try:
backend._timeout_kill(original)
with pytest.raises(RuntimeError, match="still stopping"):
backend._spawn()
assert backend._proc is replacement
replacement.kill.assert_not_called()
# Once the captured owner is reaped, reuse of the healthy replacement
# is allowed without starting or terminating another process.
original.wait.side_effect = None
original.wait.return_value = 0
backend._spawn()
assert backend._proc is replacement
replacement.kill.assert_not_called()
finally:
original.wait.side_effect = None
backend._proc = None
backend.shutdown()
+87
View File
@@ -113,6 +113,93 @@ def test_unclean_shutdown_yields_crash_record(sentinel_env, monkeypatch):
assert acked is False, "a fresh crash record must be unacknowledged"
def test_lifespan_clears_sentinel_even_if_later_shutdown_raises(monkeypatch, tmp_path):
"""THE #1895 regression: before this fix, ``clear_sentinel()`` was the
LAST statement of ``main.py``'s lifespan shutdown, behind ~50s of bounded
waits plus model unload / ``free_vram()`` / ``gc.collect()`` / httpx
close. The desktop shell's quit path grants only a 2s grace before
SIGKILL (``frontend/src-tauri/src/bootstrap.rs``
``terminate_process_tree``), and Windows grants no graceful phase at all
(``tools.rs``) nowhere near enough, so a deliberate, clean quit
routinely got killed before reaching that last line, leaving the
sentinel behind for the NEXT startup to misreport as "did not shut down
cleanly... likely crashed".
Simulates that class of interruption without an actual SIGKILL: a later
shutdown step (``model_loads_begin_shutdown()``, called unguarded well
after the sentinel clear) raises, so nothing past it in the shutdown
body ever runs for this purpose, the same effect as being killed
mid-teardown.
Fail-before/pass-after: with ``clear_sentinel()`` moved to the TOP of
the shutdown block (immediately after ``yield``), the sentinel is
already gone by the time this raise happens, so the next startup must
not fabricate a crash record.
"""
import asyncio
from fastapi import FastAPI
# Fresh `main`/`core`/`api`/`services` import, mirroring
# tests/test_model_load_shutdown.py's `_reimported_backend_modules`: a
# sibling suite may have purged these names from sys.modules, leaving a
# collection-time alias stale. Purging and re-importing here makes this
# test self-consistent in isolation, not dependent on suite order.
purge_names = ("main", "core", "api", "services")
purge_prefixes = ("core.", "api.", "services.")
saved = {
name: mod for name, mod in sys.modules.items()
if name in purge_names or name.startswith(purge_prefixes)
}
def _purge():
for name in [
n for n in sys.modules
if n in purge_names or n.startswith(purge_prefixes)
]:
sys.modules.pop(name, None)
_purge()
try:
import main as main_mod
from core import run_sentinel as fresh_run_sentinel
monkeypatch.setattr(
fresh_run_sentinel, "SENTINEL_PATH", str(tmp_path / "run_sentinel.json")
)
monkeypatch.setattr(
fresh_run_sentinel, "CRASH_RECORD_PATH", str(tmp_path / "last_run_crash.json")
)
monkeypatch.setattr(
fresh_run_sentinel, "LOG_PATH", str(tmp_path / "omnivoice.log")
)
fresh_run_sentinel._reset_for_tests()
def _boom():
raise RuntimeError("simulated kill: interrupted after the early clear")
monkeypatch.setattr(main_mod, "model_loads_begin_shutdown", _boom)
async def scenario():
app = FastAPI()
async with main_mod.lifespan(app):
pass
with pytest.raises(RuntimeError, match="simulated kill"):
asyncio.run(scenario())
assert not os.path.exists(fresh_run_sentinel.SENTINEL_PATH), (
"sentinel must already be cleared even though a later shutdown "
"step raised before ever reaching the old clear-sentinel line"
)
assert fresh_run_sentinel.detect_unclean_shutdown() is None, (
"a deliberate quit interrupted after the early clear must never "
"be reported as a crash on the next startup"
)
finally:
_purge()
sys.modules.update(saved)
def test_live_pid_means_second_instance_not_a_crash(sentinel_env):
"""A sentinel owned by a LIVE process is a concurrent second instance
sharing DATA_DIR never a crash, and we must not take over or delete
+31 -4
View File
@@ -23,6 +23,8 @@ from __future__ import annotations
import logging
from typing import Optional
from worker.capacity import derive_concurrency
logger = logging.getLogger("omnivoice.worker")
# gpu_compat families that mean "this would run on the CPU here", which is
@@ -74,6 +76,12 @@ def discover(*, include_unavailable: bool = False) -> list[dict]:
gpu_compat = set(entry.get("gpu_compat") or [])
repo_ids = repo_ids_for(entry)
downloaded = _downloaded(repo_ids)
runtime_vram_gb = (entry.get("execution_evidence") or {}).get(
"runtime_vram_gb"
)
engine_free_bytes = free_bytes if runtime_vram_gb is None else int(
float(runtime_vram_gb or 0.0) * 1024**3
)
discovered.append(
{
"engine": engine_id,
@@ -97,7 +105,17 @@ def discover(*, include_unavailable: bool = False) -> list[dict]:
"min_memory_bytes": int(float(entry.get("min_vram_gb") or 0) * 1024**3),
"precision": "",
"backend": entry.get("effective_device") or family,
"free_memory_bytes": free_bytes,
"free_memory_bytes": engine_free_bytes,
# A native provider that works independently of torch may not
# expose memory telemetry. Unknown capacity still gets one
# serial slot; zero must not turn a working Vulkan engine into
# an unschedulable capability.
"derived_concurrency": 1
if (
runtime_vram_gb is not None
and float(runtime_vram_gb or 0.0) <= 0
and routing == "accelerated"
) else 0,
# Capability is not acceleration: an engine present but routed
# to the CPU here should not be preferred for GPU work.
"cpu_fallback": routing in ("cpu_fallback", "cpu_only")
@@ -291,9 +309,18 @@ def max_concurrent_tasks(capabilities: Optional[list[dict]] = None) -> int:
caps = capabilities if capabilities is not None else discover()
if not caps:
return 1
derived = [int(c.get("derived_concurrency") or 0) for c in caps]
positive = [d for d in derived if d > 0]
return min(positive) if positive else 1
derived: list[int] = []
for cap in caps:
concurrency = int(cap.get("derived_concurrency") or 0)
if concurrency <= 0:
concurrency = derive_concurrency(
backend=str(cap.get("backend") or ""),
free_memory_bytes=int(cap.get("free_memory_bytes") or 0),
min_model_bytes=int(cap.get("min_memory_bytes") or 0),
compiled=bool(cap.get("compiled")),
)
derived.append(concurrency)
return min(derived)
__all__ = [
+4 -6
View File
@@ -97,18 +97,16 @@ def derive_concurrency(
) -> int:
"""How many jobs of this model may run at once on this worker.
Returns 0 when the model cannot run here at all a capability mismatch,
which the scheduler must treat as "send it elsewhere", never as a worker
fault.
Under-provisioned accelerators remain usable with one serial slot and the
longer CPU-class deadline. Zero memory means telemetry is unknown, not
that the engine cannot run.
"""
family = (backend or "").strip().lower()
if min_model_bytes and free_memory_bytes < min_model_bytes:
return 0
if compiled:
# Thread-affinity pinning (#315). One job, always.
return 1
if family in _ALWAYS_SERIAL:
return 1 if (not min_model_bytes or free_memory_bytes >= min_model_bytes) else 0
return 1
budget = max(min_model_bytes, _VRAM_PER_JOB_BYTES)
if budget <= 0:
return 1
+20 -3
View File
@@ -127,16 +127,31 @@ class Deadlines:
def _base_execution_seconds(
text: Optional[str], *, execution_device: Optional[str] = None
text: Optional[str], *, execution_device: Optional[str] = None,
under_provisioned: bool = False,
) -> float:
"""Delegate to model_manager's budget; fall back to its formula.
The lazy import keeps this module usable in a process that has no torch
the control plane schedules work it never executes.
``under_provisioned`` is the worker's own verdict that its card sits below
the engine's declared VRAM floor (``ConnectedWorker.under_provisioned``).
It floors the budget at what the same job would get on a CPU, because that
is what a card paging to system RAM performs like (#1804). Derived by asking
for the CPU budget rather than by probing VRAM here: this process is the
control plane, and its hardware is not the worker's.
"""
target_device = str(execution_device or "cpu").lower()
if target_device not in {"cpu", "cuda", "mps", "mlx", "directml", "rocm", "xpu"}:
if target_device not in {
"cpu", "cuda", "mps", "mlx", "directml", "rocm", "vulkan", "xpu",
}:
target_device = "cpu"
if under_provisioned and target_device != "cpu":
return max(
_base_execution_seconds(text, execution_device=target_device),
_base_execution_seconds(text, execution_device="cpu"),
)
try:
from services import model_manager # noqa: PLC0415 — intentionally lazy
@@ -171,6 +186,7 @@ def for_task(
model_downloaded: bool = True,
input_seconds: float = 0.0,
execution_device: Optional[str] = None,
under_provisioned: bool = False,
) -> Deadlines:
"""Compute the deadlines for one attempt.
@@ -183,7 +199,8 @@ def for_task(
multiplier, grace = _PROFILE[op]
execution = _base_execution_seconds(
text, execution_device=execution_device
text, execution_device=execution_device,
under_provisioned=under_provisioned,
) * multiplier
# Media-length operations scale on duration, not characters.
if input_seconds > 0:
+4
View File
@@ -32,6 +32,7 @@ import uuid
from dataclasses import dataclass, field
from typing import Iterable, Optional
from worker.deadlines import Deadlines
from worker.clock import resolve
from worker.errors import ErrorClass, WorkerError
@@ -224,6 +225,9 @@ class Attempt:
stage: str = ""
error: Optional[WorkerError] = None
# Snapshot the lease policy granted at dispatch, including after restart.
deadlines: Optional[Deadlines] = None
def matches(self, *, session_epoch: Optional[int] = None) -> bool:
"""Fence check: reject messages from a superseded session."""
if session_epoch is None:
+53 -20
View File
@@ -34,7 +34,7 @@ _HEARTBEAT_MISS_SECONDS = 90.0
# enough that one slow answer cannot move it.
_LATENCY_WINDOW = 5
_KNOWN_EXECUTION_DEVICES = frozenset(
{"cpu", "cuda", "mps", "mlx", "directml", "rocm", "xpu"}
{"cpu", "cuda", "mps", "mlx", "directml", "rocm", "vulkan", "xpu"}
)
@@ -93,12 +93,11 @@ class ConnectedWorker:
return "busy"
return "ready"
def supports(self, engine: str, model_id: str, operation: str) -> bool:
"""Can this worker run this work at all?
def _capability_for(self, engine: str, model_id: str, operation: str):
"""The advertised capability this task would actually be run by.
``supported`` alone is not enough an engine whose weights are not on
disk cannot start without a download, and one that is not installed
cannot start at all. Both are capability mismatches, not failures.
One selection rule, so the answers below cannot describe different
capabilities of the same worker.
"""
for cap in self.record.capabilities:
if cap.get("engine") != engine:
@@ -107,23 +106,57 @@ class ConnectedWorker:
continue
if operation and operation not in (cap.get("operations") or [operation]):
continue
return bool(cap.get("supported")) and bool(cap.get("installed", True))
return False
return cap
return None
def supports(self, engine: str, model_id: str, operation: str) -> bool:
"""Can this worker run this work at all?
``supported`` alone is not enough an engine whose weights are not on
disk cannot start without a download, and one that is not installed
cannot start at all. Both are capability mismatches, not failures.
"""
cap = self._capability_for(engine, model_id, operation)
if cap is None:
return False
return bool(cap.get("supported")) and bool(cap.get("installed", True))
def execution_device(self, engine: str, model_id: str, operation: str) -> str:
"""Device used by the exact capability selected for this task."""
for cap in self.record.capabilities:
if cap.get("engine") != engine:
continue
if model_id and cap.get("model_id") not in (model_id, "", None):
continue
if operation and operation not in (cap.get("operations") or [operation]):
continue
if cap.get("cpu_fallback"):
return "cpu"
backend = str(cap.get("backend") or "").lower()
return backend if backend in _KNOWN_EXECUTION_DEVICES else "cpu"
return "cpu"
cap = self._capability_for(engine, model_id, operation)
if cap is None:
return "cpu"
if cap.get("cpu_fallback"):
return "cpu"
backend = str(cap.get("backend") or "").lower()
return backend if backend in _KNOWN_EXECUTION_DEVICES else "cpu"
def under_provisioned(self, engine: str, model_id: str, operation: str) -> bool:
"""Is this worker's GPU below the engine's declared VRAM floor?
The remote half of #1804. A card under the floor pages to system RAM and
renders slower than a CPU, so it must not be given the shorter
accelerated deadline. Decided from the two figures the WORKER itself
advertises (``free_memory_bytes`` / ``min_memory_bytes``, both set in
``worker/capabilities.py``): the control plane's own VRAM says nothing
about the machine that will run the job, so
``engine_routing.under_provisioned_vram`` which probes THIS host
cannot answer for a remote worker.
Same rules as that predicate otherwise: dedicated-VRAM devices only
(unified memory is not a comparable pool), and a zero on either side
means "unknown", never "too small".
"""
cap = self._capability_for(engine, model_id, operation)
if cap is None or cap.get("cpu_fallback"):
return False
if str(cap.get("backend") or "").lower() not in (
"cuda", "rocm", "vulkan",
):
return False
floor = int(cap.get("min_memory_bytes") or 0)
have = int(cap.get("free_memory_bytes") or 0)
return floor > 0 and 0 < have < floor
def is_warm(self, engine: str, model_id: str) -> bool:
return self.capacity.is_resident(engine, model_id)
File diff suppressed because one or more lines are too long
@@ -93,7 +93,7 @@ class HostInfo(_message.Message):
def __init__(self, hostname: _Optional[str] = ..., os: _Optional[str] = ..., arch: _Optional[str] = ..., worker_version: _Optional[str] = ..., cpu_count: _Optional[int] = ..., system_memory_bytes: _Optional[int] = ..., gpus: _Optional[_Iterable[_Union[GpuInfo, _Mapping]]] = ...) -> None: ...
class ModelCapability(_message.Message):
__slots__ = ("engine", "model_id", "operations", "supported", "installed", "downloaded", "resident", "min_memory_bytes", "precision", "derived_concurrency", "cpu_fallback", "repo_ids", "display_name")
__slots__ = ("engine", "model_id", "operations", "supported", "installed", "downloaded", "resident", "min_memory_bytes", "precision", "derived_concurrency", "cpu_fallback", "repo_ids", "display_name", "backend", "free_memory_bytes")
ENGINE_FIELD_NUMBER: _ClassVar[int]
MODEL_ID_FIELD_NUMBER: _ClassVar[int]
OPERATIONS_FIELD_NUMBER: _ClassVar[int]
@@ -107,6 +107,8 @@ class ModelCapability(_message.Message):
CPU_FALLBACK_FIELD_NUMBER: _ClassVar[int]
REPO_IDS_FIELD_NUMBER: _ClassVar[int]
DISPLAY_NAME_FIELD_NUMBER: _ClassVar[int]
BACKEND_FIELD_NUMBER: _ClassVar[int]
FREE_MEMORY_BYTES_FIELD_NUMBER: _ClassVar[int]
engine: str
model_id: str
operations: _containers.RepeatedScalarFieldContainer[str]
@@ -120,7 +122,9 @@ class ModelCapability(_message.Message):
cpu_fallback: bool
repo_ids: _containers.RepeatedScalarFieldContainer[str]
display_name: str
def __init__(self, engine: _Optional[str] = ..., model_id: _Optional[str] = ..., operations: _Optional[_Iterable[str]] = ..., supported: _Optional[bool] = ..., installed: _Optional[bool] = ..., downloaded: _Optional[bool] = ..., resident: _Optional[bool] = ..., min_memory_bytes: _Optional[int] = ..., precision: _Optional[str] = ..., derived_concurrency: _Optional[int] = ..., cpu_fallback: _Optional[bool] = ..., repo_ids: _Optional[_Iterable[str]] = ..., display_name: _Optional[str] = ...) -> None: ...
backend: str
free_memory_bytes: int
def __init__(self, engine: _Optional[str] = ..., model_id: _Optional[str] = ..., operations: _Optional[_Iterable[str]] = ..., supported: _Optional[bool] = ..., installed: _Optional[bool] = ..., downloaded: _Optional[bool] = ..., resident: _Optional[bool] = ..., min_memory_bytes: _Optional[int] = ..., precision: _Optional[str] = ..., derived_concurrency: _Optional[int] = ..., cpu_fallback: _Optional[bool] = ..., repo_ids: _Optional[_Iterable[str]] = ..., display_name: _Optional[str] = ..., backend: _Optional[str] = ..., free_memory_bytes: _Optional[int] = ...) -> None: ...
class RegisterRequest(_message.Message):
__slots__ = ("envelope", "protocol_version_min", "protocol_version_max", "enrollment_token", "worker_id", "public_key", "challenge_signature", "challenge", "host", "capabilities", "max_concurrent_tasks", "in_flight", "completed_unacked", "key_id", "nonce", "labels", "features")
+5
View File
@@ -168,6 +168,11 @@ message ModelCapability {
// Human-readable UI label. Never use this as a scheduling or residency key;
// unlike model_id it may change with ordinary copy edits.
string display_name = 13;
// Per-engine runtime routing. Native engines can select a provider that is
// independent of the worker's global torch device.
string backend = 14;
// Memory measured for that exact selected provider/device; zero is unknown.
uint64 free_memory_bytes = 15;
}
message RegisterRequest {
+17 -1
View File
@@ -652,7 +652,11 @@ class Scheduler:
execution_device=worker.execution_device(
task.engine, task.model_id, task.operation
),
under_provisioned=worker.under_provisioned(
task.engine, task.model_id, task.operation
),
)
attempt.deadlines = budget
attempt.renew_lease(budget.accept_seconds, now=now)
self._save(task, now=now)
self._emit("assigned", task)
@@ -1295,7 +1299,13 @@ class Scheduler:
def _budget_for(self, task: Task) -> deadline_policy.Deadlines:
attempt = task.active_attempt
if attempt is not None and attempt.deadlines is not None:
return attempt.deadlines
# A legacy attempt has no recorded device once its worker is absent.
# Cover both configured device classes instead of assuming the shorter
# CPU budget; for_task floors an under-provisioned GPU at max(CPU, GPU).
worker = self.pool.get(attempt.worker_id) if attempt else None
unknown_legacy_worker = attempt is not None and worker is None
return deadline_policy.for_task(
task.operation,
text=task.params.get("text"),
@@ -1303,7 +1313,13 @@ class Scheduler:
input_seconds=float(task.params.get("input_seconds") or 0.0),
execution_device=(
worker.execution_device(task.engine, task.model_id, task.operation)
if worker else None
if worker else ("cuda" if unknown_legacy_worker else None)
),
under_provisioned=unknown_legacy_worker or bool(
worker
and worker.under_provisioned(
task.engine, task.model_id, task.operation
)
),
)
+39 -7
View File
@@ -33,6 +33,7 @@ from core.db import db_conn
from core.path_security import UnsafePath, resolve_within, safe_filename
from worker.clock import resolve
from worker.errors import ErrorClass, WorkerError
from worker.deadlines import Deadlines
from worker.lifecycle import Attempt, AttemptState, PriorityClass, Task, TaskState
logger = logging.getLogger("omnivoice.worker")
@@ -67,6 +68,8 @@ def _row_to_attempt(row) -> Attempt:
state=AttemptState(row["state"]),
created_at=float(row["created_at"]),
)
if row["deadlines_json"]:
attempt.deadlines = Deadlines(**json.loads(row["deadlines_json"]))
attempt.accepted_at = row["accepted_at"]
attempt.started_at = row["started_at"]
attempt.finished_at = row["finished_at"]
@@ -131,6 +134,32 @@ INPUT_PARAM_KEYS: tuple[str, ...] = (
# task records what was staged for it. The record is what makes the purge
# exact: an input is deletable only when no surviving task still refers to it.
INPUTS_DIRNAME = "inputs"
def artifact_id_for(name: str) -> str:
"""The id a staged input is known by, everywhere.
This is a PROTOCOL identifier, not a local path: it is persisted in
``params_json``, handed to remote workers over gRPC, and matched against
what a later sweep finds on disk. ``os.path.join`` made it OS-specific, so
a Windows control plane stored and shipped ``inputs\\<sha>.wav`` which a
Linux worker cannot resolve, and which stops matching the moment the same
data directory is opened on another OS. Always ``/``; ``resolve_within``
already treats both separators as structural, so resolution is unaffected.
"""
return f"{INPUTS_DIRNAME}/{name}"
def normalize_artifact_id(artifact_id: str) -> str:
"""Compare ids written by any host on equal terms.
Rows staged by a Windows control plane before this was canonicalised carry
a backslash. The sweeper decides whether a file on disk is still
referenced by comparing ids, so without this an upgraded install would
read every legacy row as unreferenced and delete inputs that surviving
tasks still point at.
"""
return (artifact_id or "").replace("\\", "/")
INPUTS_PARAM_KEY = "inputs"
_HASH_CHUNK_BYTES = 1024 * 1024
@@ -289,7 +318,7 @@ def stage_input(
f"Could not read the task input {source!r}: {exc}"
) from exc
artifact_id = os.path.join(INPUTS_DIRNAME, f"{digest}{_extension(source)}")
artifact_id = artifact_id_for(f"{digest}{_extension(source)}")
try:
destination = resolve_within(base, artifact_id)
except UnsafePath as exc: # pragma: no cover — the id is ours, hex only
@@ -470,7 +499,7 @@ def _referenced_artifacts(conn) -> set[str]:
continue
for entry in entries:
if isinstance(entry, dict) and entry.get("artifact_id"):
referenced.add(str(entry["artifact_id"]))
referenced.add(normalize_artifact_id(str(entry["artifact_id"])))
return referenced
@@ -557,8 +586,7 @@ def purge_artifacts(
except OSError:
return removed
for name in names:
artifact_id = os.path.join(INPUTS_DIRNAME, name)
if artifact_id in referenced:
if artifact_id_for(name) in referenced:
continue
path = os.path.join(inputs_dir, name)
try:
@@ -635,12 +663,13 @@ def _upsert_attempts(conn, task: Task) -> None:
"INSERT INTO remote_task_attempts "
"(id, task_id, worker_id, session_epoch, attempt_number, state, progress, stage, "
" error_json, created_at, accepted_at, started_at, finished_at, lease_expires_at, "
" grace_expires_at) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "
" grace_expires_at, deadlines_json) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "
"ON CONFLICT(id) DO UPDATE SET state=excluded.state, progress=excluded.progress, "
" stage=excluded.stage, error_json=excluded.error_json, accepted_at=excluded.accepted_at, "
" started_at=excluded.started_at, finished_at=excluded.finished_at, "
" lease_expires_at=excluded.lease_expires_at, grace_expires_at=excluded.grace_expires_at",
" lease_expires_at=excluded.lease_expires_at, grace_expires_at=excluded.grace_expires_at, "
" deadlines_json=excluded.deadlines_json",
(
attempt.attempt_id,
attempt.task_id,
@@ -657,6 +686,7 @@ def _upsert_attempts(conn, task: Task) -> None:
attempt.finished_at,
attempt.lease_expires_at,
attempt.grace_expires_at,
json.dumps(attempt.deadlines.to_dict()) if attempt.deadlines else None,
),
)
@@ -888,6 +918,8 @@ def purge_finished(
__all__ = [
"INPUTS_DIRNAME",
"artifact_id_for",
"normalize_artifact_id",
"INPUTS_PARAM_KEY",
"INPUT_PARAM_KEYS",
"InputStagingError",
+20 -1
View File
@@ -229,10 +229,27 @@ def capability_to_pb(cap: dict) -> pb.ModelCapability:
cpu_fallback=bool(cap.get("cpu_fallback")),
repo_ids=list(cap.get("repo_ids") or []),
display_name=str(cap.get("display_name") or ""),
backend=str(cap.get("backend") or ""),
free_memory_bytes=int(cap.get("free_memory_bytes") or 0),
)
def capability_from_pb(message: pb.ModelCapability) -> dict:
def capability_from_pb(
message: pb.ModelCapability, *, fallback_backend: str = ""
) -> dict:
"""Decode a capability, including protocol-v2 peers from before backend.
``backend`` was added to the existing protocol-v2 message, so an older
peer legitimately sends its protobuf default (the empty string). The
host-level GPU backend is the only compatible execution-device signal in
that payload. A capability explicitly marked as a CPU fallback must stay
on CPU even when its host also has a GPU.
"""
backend = str(message.backend or "").strip().lower()
if message.cpu_fallback:
backend = "cpu"
elif not backend:
backend = str(fallback_backend or "").strip().lower()
return {
"engine": message.engine,
"model_id": message.model_id,
@@ -249,6 +266,8 @@ def capability_from_pb(message: pb.ModelCapability) -> dict:
"cpu_fallback": message.cpu_fallback,
"repo_ids": list(message.repo_ids),
"display_name": message.display_name,
"backend": backend,
"free_memory_bytes": message.free_memory_bytes,
}
+12 -3
View File
@@ -851,10 +851,12 @@ class WorkerServicer(pb_grpc.WorkerServiceServicer):
epoch: int,
) -> pb.RegisterResponse:
session = identity.issue_session(worker_id=worker.id, key_id=worker.key_id, epoch=epoch)
capabilities = [codec.capability_from_pb(c) for c in request.capabilities]
host = codec.host_from_pb(request.host)
backend = host["gpus"][0].get("backend", "") if host.get("gpus") else ""
capabilities = [
codec.capability_from_pb(c, fallback_backend=backend)
for c in request.capabilities
]
claimed_refs = {
ref.attempt_id: codec.task_ref(
ref.task_id, ref.attempt_id, ref.session_epoch
@@ -2044,7 +2046,14 @@ class WorkerServicer(pb_grpc.WorkerServiceServicer):
session.worker_id,
)
return
caps = [codec.capability_from_pb(c) for c in update.capabilities]
worker = self.pool.get(session.worker_id)
fallback_backend = (
worker.capacity.backend if worker is not None else ""
)
caps = [
codec.capability_from_pb(c, fallback_backend=fallback_backend)
for c in update.capabilities
]
self._queue_capability_update(session, caps)
return
+292 -302
View File
File diff suppressed because it is too large Load Diff
+14 -5
View File
@@ -14,12 +14,21 @@ cloning, and cinematic video dubbing — fully local, with no cloud API keys or
![VoiceStudio — the open-source ElevenLabs alternative](https://raw.githubusercontent.com/debpalash/VoiceStudio/main/.github/assets/social-preview.png)
VoiceStudio runs entirely on your own hardware (CUDA / MPS / ROCm / CPU
VoiceStudio runs entirely on your own hardware (CUDA / ROCm / CPU
auto-detect) — nothing is sent to the cloud. This image is the **headless
web-server build**: a FastAPI backend serving a pre-built React UI over HTTP, so
you can run it on a homelab box, a GPU server, or anywhere Docker runs and open
you can run it on an AMD64 homelab box or GPU server and open
the UI in a browser.
**Architecture:** published images are **`linux/amd64` only**; there is no
native ARM64 image. On Apple Silicon, use the
[native macOS app](https://github.com/debpalash/VoiceStudio/blob/main/docs/install/macos.md)
for Apple GPU acceleration; the Linux container cannot access the Mac's Apple
GPU through MPS or MLX. Other ARM64 hosts need an AMD64 server or CPU emulation,
which can be much slower. See the
[architecture requirements](https://github.com/debpalash/VoiceStudio/blob/main/docs/install/docker.md#architecture)
before pulling an image.
> The Tauri desktop app's auto-updater and update-channel toggle are
> **desktop-only** and do not apply to this image — to update, pull a newer tag
> and recreate the container.
@@ -111,12 +120,12 @@ publishing the web UI — see the [Docker install guide](https://github.com/debp
|-----|--------------|
| `:latest` | **Rolling preview** — latest commit on `main`, at or ahead of the last release. This is the preview channel; pin `:stable` for production. |
| `:stable` | Most recent versioned release (updated on every `v*` git tag) |
| `:0.5.1` | Exact release version |
| `:0.5.2` | Exact release version |
| `:0.5` | Latest patch within the `0.5` minor |
| `:main` | Alias of the same rolling `main` build as `:latest` |
| `:sha-xxxxxxx` | A specific commit (produced by manual workflow dispatch) |
| `:rocm` | **AMD GPU (ROCm) build** of the rolling preview — the ROCm analogue of `:latest` |
| `:stable-rocm`, `:0.5.1-rocm`, `:0.5-rocm`, `:sha-xxxxxxx-rocm` | ROCm builds of the corresponding tags above |
| `:stable-rocm`, `:0.5.2-rocm`, `:0.5-rocm`, `:sha-xxxxxxx-rocm` | ROCm builds of the corresponding tags above |
Preview builds always come from `main` and never version-sort below `:stable`,
so upgrades flow naturally. The same images and tags
@@ -136,7 +145,7 @@ are mirrored on GHCR at
- **📦 Batch Queue** — drop 50 videos and walk away; per-job progress.
- **🤖 MCP Server** — drive VoiceStudio from Claude, Cursor, or any MCP client.
- **🛡️ AI Watermark** — invisible AudioSeal (Meta) marking that survives compression.
- **⚡ GPU Auto-Detect** — CUDA · MPS · ROCm · CPU, with auto-offload on ≤8 GB cards.
- **⚡ GPU Auto-Detect** — CUDA · ROCm · CPU, with auto-offload on ≤8 GB cards.
- **🧩 Extensible** — subclass `TTSBackend` to add any engine in ~50 lines.
Multiple TTS engines ship out of the box (IndexTTS, CosyVoice, Supertonic-3, and
+10 -1
View File
@@ -96,7 +96,7 @@ bug to fix immediately, not backlog.
| Channel | Source | Produced by | How to verify |
|---|---|---|---|
| GitHub Release: installers + signed `latest.json` (**Stable** updater channel) | the `vX.Y.Z` tag | `release.yml` on tag push | Release page has dmg (arm+intel), msi/exe, AppImage/deb, `latest.json`; body = the CHANGELOG section (not the auto-generated fallback), followed by per-platform checksums and a **Contributors** avatar strip (owner + every PR author for the tag — the `contributors-strip` job) |
| **Preview** updater channel (rolling `preview` prerelease) | **`main` only** | `release.yml` nightly cron / manual dispatch | preview `latest.json` stamps `X.Y.Z-N` and semver-sorts above stable |
| **Preview** updater channel (rolling `preview` prerelease) | **`main` only** | `release.yml` nightly cron / manual dispatch | preview `latest.json` uses main's version when it is ahead; otherwise it advances the stable patch, then appends `-N` so it semver-sorts above stable |
| GHCR CUDA image: `:X.Y.Z`, `:X.Y`, `:stable` | the tag | `docker.yml` on tag push | `docker manifest inspect ghcr.io/debpalash/omnivoice-studio:X.Y.Z` |
| GHCR ROCm image: `:X.Y.Z-rocm`, `:X.Y-rocm`, `:stable-rocm` | the tag | `docker.yml` on tag push | same, with `-rocm` suffix |
| Docker Hub mirror of **all** the above tags | the tag | `docker.yml` (gated on `DOCKERHUB_*` secrets) | tag list at hub.docker.com/r/palashdeb/omnivoice-studio/tags |
@@ -147,3 +147,12 @@ There's no "revert update" flow for clients — they'll only see a *newer* versi
3. Clients auto-update to the "new" v0.2.1 which is actually the old code.
Ugly but it works. Better plan: test with Option B above before publishing the draft.
## Retrying a partially published build
Use GitHub Actions **Re-run failed jobs** for the same release run. On retries,
the workflow removes only the current version's installers for that job's target
before Tauri uploads them again. A macOS retry also replaces that architecture's
versionless updater archive. Other versions, sibling platforms, and updater
manifests remain intact. Inventory or deletion permission/network failures stop
the job instead of hiding an upload collision.
+4 -4
View File
@@ -18,7 +18,7 @@ Phase 5 · Productisation ░░░░░░░░░░ 0 / 5
Design track ▓▓▓▓▓▓▓▓▓░ ongoing · 14 primitives + ~67 migrated inline styles · DubTab/Header/Sidebar/CloneDesignTab drained
Performance track ▓▓▓░░░░░░░ underway · profiling, preload, isolated engines + cache-remix I/O
Feature-magic track ░░░░░░░░░░ not started
Feature-magic track ▓▓░░░░░░░░ underway · project-level casting board shipped
Quality track ▓▓░░░░░░░░ 12 smoke tests, 10 error messages rewritten
```
@@ -205,15 +205,15 @@ None on the critical path to world-class. All are answers to real demand.
| Interaction budgets (<50 ms UI, <200 ms preview, <4 s first seg) | 🟡 | `/ws/tts` reports real TTFA, total generation time and RTF; frontend responsiveness instrumentation exists, but no cross-surface budget gate yet. |
| Dedicated dev-week per quarter | ⏳ | Cadence not yet booked. |
### ✨ Feature-magic track _(⏳ not started)_
### ✨ Feature-magic track _(🟡 underway)_
| Feature | Status | Phase gate |
|------|:---:|------|
| Project-level casting view (drag voices to speakers) | | After Phase 3 |
| Project-level casting view (drag voices to speakers) | | Shipped (#1767): the dub CAST strip expands into a casting board — drag voice chips onto speaker rows, keyboard listbox included, same fields as the dropdowns. |
| Voice memory across projects | ⏳ | After Phase 4 |
| Context-aware pipeline (video frames → pipeline decisions) | ⏳ | After Phase 4 |
| On-device learning from corrections (user edits → LoRA) | ⏳ | Research only; possibly Phase 5+ |
| Real-time dub preview (stream TTS as you edit) | | After Phase 4.1 |
| Real-time dub preview (stream TTS as you edit) | | Shipped 2026-09-02 (#1769) — opt-in "Live preview" toggle on the dub segment table streams the edited line over `/ws/tts` with its CAST voice; export path unchanged. |
### 🧪 Quality track _(🟡 underway)_
+109 -48
View File
@@ -7,39 +7,71 @@ Every folder has a single job. Every file at the root earns its place.
```
VoiceStudio/
├── README.md ⟵ user-facing overview
├── CHANGELOG.md ⟵ release history
├── LICENSE
├── README.md / README_CN.md ⟵ user-facing overview (English / Chinese)
├── CHANGELOG.md ⟵ release history; release.yml extracts the tag's section verbatim
├── CLAUDE.md / AGENTS.md ⟵ the working contract for AI agents — keep the two in sync
├── LICENSE, LICENSE-NOTICE.md, SPONSORS.md
├── pyproject.toml ⟵ Python project manifest
├── pyproject.toml ⟵ Python project manifest (+ pytest / lint config)
├── uv.lock ⟵ Python lockfile
├── package.json ⟵ monorepo manifest (Bun workspaces + Turborepo)
├── bun.lock ⟵ JS lockfile
├── bun.lock ⟵ JS lockfile — repo-root, covers frontend/ too
├── turbo.json ⟵ turborepo pipeline
├── .coderabbit.yaml ⟵ CodeRabbit PR review config (fed CLAUDE.md)
├── greptile.json ⟵ Greptile PR review config (fed CLAUDE.md)
├── skills-lock.json ⟵ pins the sources + hashes of .agents/skills/
├── .gitleaks.toml ⟵ secret-scan config
├── .gitmodules ⟵ omnivoice-gallery submodule
├── .python-version
├── .dockerignore ⟵ Docker build context filter
├── backend.spec ⟵ pyinstaller spec (stays at root by pyinstaller convention)
├── alembic.ini ⟵ DB migration config (stays at root by alembic convention)
├── .env user config; gitignored, .env.example is the template
├── .gitignore
├── .gitignorea repo-local .env stays ignored, but user config is NOT
│ kept here: the durable env file is ~/.config/omnivoice/env
│ (backend/core/user_env.py), written by the Settings panel
├── backend/ ⟵ FastAPI server
│ ├── main.py
├── api/routers/ HTTP endpoints (thin)
│ ├── core/ config, db, task queue, metrics
├── services/ business logic
── schemas/ pydantic request/response shapes
│ ├── main.py the one entry point; its boot order is load-bearing —
│ read the comments before reordering anything
│ ├── api/routers/ 39 routers, auto-included; thin HTTP/WS surface
│ └── setup/ first-run wizard, model download
── core/ config, db, job queue, event bus, auth/CSRF, path security,
│ │ opt-in analytics, version, diagnostics
│ ├── services/ 78 modules of business logic — TTS, dubbing pipeline,
│ │ audio DSP, GPU gateway, engine routing, model lifecycle
│ ├── engines/ per-engine adapters: indextts, supertonic3, confucius4,
│ │ dots_tts, moss_tts_v15, pockettts, audiocpp,
│ │ omnivoice_gguf, omnivoice_subprocess, _asr_sidecar, _echo
│ ├── worker/ remote / distributed workers — scheduler, pool, routing,
│ │ breaker, capacity, plus protocol/ and inbound/
│ ├── mcp_shim/ MCP server entry point (docs/mcp.md)
│ ├── speech_client/ speech sidecar client entry point
│ ├── schemas/ pydantic request/response shapes
│ ├── migrations/versions/ alembic revisions — every schema change goes through here
│ ├── plugins/ plugin drop-in point (see services/plugin_sdk.py)
│ ├── hooks/ pyinstaller runtime hooks
│ ├── config/models.yaml model catalogue
│ └── tests/ the isolated pytest session — see "Where tests live"
├── frontend/ ⟵ React 19 + Vite + Tauri desktop
│ ├── package.json THE app version — every other version file mirrors it
│ ├── src/
│ │ ├── pages/ one file per top-level view
│ │ ├── components/ reusable UI
│ │ ├── api/ typed API clients
│ │ ├── store/ Zustand slices
│ │ ├── components/ reusable UI (+ audiobook/ clone/ dub/ gallery/ settings/ …)
│ │ ├── ui/, lib/ shared primitives and helpers
│ │ ├── api/ typed API clients, one per router group
│ │ ├── store/ Zustand slices (+ persisted-state migrations)
│ │ ├── hooks/ custom React hooks
│ │ ── utils/
│ ├── src-tauri/ Rust desktop shell
│ │ ── i18n/locales/ the ONLY home for user-facing strings
│ ├── config/, data/, assets/, utils/
│ │ └── test/ vitest setup + visual-test helpers
│ ├── e2e/, e2e-perf/, e2e-prod/ Playwright suites: functional, perf, packaged bundle
│ ├── src-tauri/ Rust desktop shell — backend spawn/bootstrap, updater
│ │ │ channel, dictation shortcut, crash/reset/uninstall
│ │ ├── capabilities/, icons/, wix/, debian/, appimage/ packaging inputs
│ │ └── tests/
│ └── public/
├── omnivoice/ ⟵ the underlying TTS model package
@@ -51,46 +83,59 @@ VoiceStudio/
│ ├── training/
│ └── utils/
├── tests/ ⟵ all tests live here, no exceptions
│ ├── conftest.py
│ ├── test_api.py
│ ├── test_dub_*.py
│ ├── test_job_queue.py
│ ├── test_segmentation.py
│ └── frontend/ Node-based frontend tests
├── tests/ ⟵ the main pytest session (testpaths in pyproject.toml)
│ ├── conftest.py hermetic OMNIVOICE_DATA_DIR — never touches real app state
│ ├── backend/, scripts/ mirrors of the source trees they cover
│ ├── smoke/ fast end-to-end checks (own CI job, HF_HUB_OFFLINE=1)
│ ├── evals/ quality evals (evals.yml)
│ ├── probe/, fixtures/
│ └── frontend/ Node-based frontend tests (legacy; vitest is the default)
├── scripts/ ⟵ dev / build / release shell + python scripts
│ ├── install.sh universal installer (macOS/Linux/WSL)
│ ├── install.ps1 universal installer (Windows)
│ ├── run.sh universal launcher
├── scripts/ ⟵ dev / build / release scripts (shell, python, mjs)
│ ├── install.sh / install.ps1 universal installers
│ ├── desktop-*.mjs dev, prod and fresh desktop launchers
│ ├── smoke-test.sh end-to-end validation
── desktop-prod.sh production desktop build
── check-docs-drift.py the docs-drift.yml checker (docs/features.yaml is canonical)
│ └── build-omnivoice-tts.sh builds the bin/ sidecars
├── bin/ ⟵ prebuilt omnivoice-tts sidecars, one per platform
├── .agents/skills/ ⟵ canonical skill copies (vite, fastapi-python), pinned by
│ skills-lock.json — followed by path, never symlinked
├── skills/ ⟵ skills this repo publishes (omnivoice, oss-maintainer)
├── infra/ ⟵ edge/deploy workers (not the Docker deploy path)
│ └── install-redirect/ voicestudio.sh/install — UA-sniffing installer worker
├── deploy/ ⟵ Docker deployment configs
│ ├── Dockerfile single-stage CUDA image
└── docker-compose.yml one-click local deployment
│ ├── Dockerfile CUDA by default; CI builds the ROCm variant from the same
│ file via BASE_IMAGE / GPU_FLAVOR overrides
│ ├── docker-compose.yml one-click local deployment
│ ├── torch-constraints.txt pinned torch resolution for the image
│ └── dockerhub-overview.md synced to the Docker Hub overview page at release
├── docs/ ⟵ developer docs, screenshots, branding
│ ├── ROADMAP.md where this project is going
│ ├── STRUCTURE.md you are here
│ ├── mcp.json MCP config template
│ ├── preview.png README hero image
│ ├── logo.png, logo.svg branding assets
│ ├── screenshot-*.png feature screenshots
│ ├── languages.md
│ ├── training.md
── data_preparation.md
│ ├── evaluation.md
│ └── voice-design.md
│ ├── RELEASING.md the release checklist — every deployment channel
│ ├── features.yaml canonical feature inventory (drives docs-drift.yml)
│ ├── adr/ architecture decision records
│ ├── agents/ agent-facing docs (issue tracker, triage labels, domain)
│ ├── engines/, dubbing/, install/, setup/, migration/, features/, playbooks/, specs/
│ ├── media/, screenshot-*.png, preview.png, logo.*
── languages.md, training.md, data_preparation.md, evaluation.md, voice-design.md
├── examples/ ⟵ runnable demos + sample inputs
├── examples/ ⟵ runnable demos + sample inputs (agentic/, speech-platform/)
├── notebooks/ ⟵ OmniVoice_Studio_Colab.ipynb
├── omnivoice-gallery/ ⟵ git submodule — the published voice gallery
├── omnivoice_data/ ⟵ Docker bind-mount target (gitignored)
│ DB + HF cache live here when running via compose
├── .github/workflows/ ⟵ ci, docker, release, security, docs-drift, evals,
│ install-smoke, build-omnivoice-tts
└── .git/
```
@@ -98,11 +143,22 @@ VoiceStudio/
1. **Nothing at the root is a runtime artifact.** Outputs, temp files, local DBs, crash logs — all go to `~/Library/Application Support/OmniVoice/` (or the OS equivalent), *never* into the repo. The one exception is `omnivoice_data/`, which exists as a bind-mount anchor for Docker.
2. **No ad-hoc scripts at the root.** One-off debug scripts live in `scripts/`. Tests live in `tests/`. Benchmarks live in `scripts/benchmarks/` (when we create them).
2. **No ad-hoc scripts at the root.** One-off debug scripts live in `scripts/`. Tests live in one of the three homes below, never at the root.
3. **Each subdirectory owns one concern.** If you can't describe what goes in a directory in one sentence, it's wrong.
4. **Every package has a manifest.** `backend/`, `frontend/`, `omnivoice/` each have their own deps declared via `pyproject.toml` / `package.json` — they are independently testable.
4. **Every package has a manifest.** `backend/`, `frontend/`, `omnivoice/` each have their own deps declared via `pyproject.toml` / `package.json` — they are independently testable. The JS lockfile is the **repo-root** `bun.lock` (Bun workspace), and `deploy/Dockerfile` installs from it with `--frozen-lockfile`.
## Where tests live
Three homes, each with its own runner. CI runs all three inside the single `test` job in
`ci.yml`, as separate steps. The split is deliberate, not drift:
| Home | Runner | Why it's separate |
|---|---|---|
| `tests/` | `pytest tests/` — the `testpaths` default | The main suite. Its `conftest.py` points `OMNIVOICE_DATA_DIR` at a throwaway dir so a run can never touch the developer's real app state (#878). |
| `backend/tests/` | `pytest backend/tests/` — its own pytest session (the `Run pytest (backend/tests, isolated)` step) | Runs as an isolated session against `backend/`'s bare imports. Its `conftest.py` sets the same hermetic data dir; **never** reintroduce module-level `sys.modules` stubs there — they leak process-wide at collection time and poison mixed runs. |
| `frontend/src/**/*.test.{js,jsx,ts,tsx}` | `bun run test` (vitest, jsdom) | Co-located with the component under test. `frontend/e2e*/` hold the Playwright suites; `tests/frontend/` is the older `node:test` set. |
## What lives where
@@ -110,10 +166,14 @@ VoiceStudio/
|---|---|
| User-facing product code | `backend/`, `frontend/` |
| The TTS model (independent of the studio) | `omnivoice/` |
| A new TTS/ASR engine adapter | `backend/engines/<engine>/` |
| Everything executable but not user-facing | `scripts/` |
| Tests | `tests/` |
| Prebuilt platform sidecars | `bin/` |
| Python tests | `tests/` (or `backend/tests/` when the isolated session is required) |
| Frontend unit tests | next to the component, as `*.test.jsx` |
| Developer + user docs (Markdown) | `docs/` |
| Architecture decision records (ADRs) | `docs/adr/` |
| Agent-facing docs | `docs/agents/` |
| Runnable demos and sample data | `examples/` |
| Runtime data (never committed) | `~/Library/Application Support/OmniVoice/` on Mac |
@@ -137,10 +197,10 @@ Removed in the 2026-07-12 cleanup pass (all preserved in git history):
| Dir | Why it was there | Where it went |
|---|---|---|
| `.planning/` (74 files) | GSD-era planning archive: phases, quick plans, issue clusters. The GSD workflow was retired 2026-07-08. | Deleted; the four load-bearing decision docs moved to `docs/adr/`. |
| `specs/` | spec-kit specs for features 001007 — all shipped. | Deleted. |
| `specs/` | spec-kit specs for features 001007 — all shipped. | Deleted; `docs/specs/` is the current home. |
| `design/` | ASCII mockups of the pre-React target UX, superseded by the shipped app. | Deleted. |
| `research/` | Archived legacy Gradio UI + April-2026 competitor notes. | Deleted. |
| `.agents/` | Rules for a third-party agent tool no longer in use. | Deleted. |
| `.agents/` | Rules for a third-party agent tool no longer in use. | Deleted — then reintroduced with a different job: `.agents/skills/` now holds the canonical skill copies pinned by `skills-lock.json`. |
## Scaling path (proposed, not yet executed)
@@ -169,12 +229,13 @@ VoiceStudio/
- `backend.spec` (`['backend/main.py']`, `pathex=['.']`)
- `frontend/src-tauri/tauri.*.conf.json` sidecar paths
- every import that reads `from backend.main import …` (tests, scripts)
- `frontend/package.json` as the version source of truth, and the mirrors that track it
Migrate when adding the second `apps/*` or the second `packages/*`. Not before.
## Conventions
- **Filenames:** snake_case for Python, kebab-case or PascalCase for JS/TS components, lowercase for Markdown.
- **Tests mirror source paths.** `backend/services/dub_pipeline.py``tests/services/test_dub_pipeline.py`.
- **Tests mirror source paths** where a mirror exists: `tests/backend/` mirrors `api/ core/ engines/ services/`, so `backend/services/ffmpeg_utils.py``tests/backend/services/test_ffmpeg_utils.py`. Everything else stays flat — `tests/backend/test_*.py` for backend-wide cases, `tests/test_*.py` for cross-cutting ones. A React component's test sits next to the component.
- **One-off scripts** go into `scripts/` with a descriptive name, not `test_*.py` at the root.
- **New top-level directories** require a PR that updates *this file*.
+4 -2
View File
@@ -204,7 +204,8 @@ ws://gpu-box:3900/ws/transcribe?api_key=<key>
That URL form is retained for non-browser compatibility only. The first-party
UI never constructs it. A bearer administrator session first calls
`POST /api/auth/ws-ticket` and puts only the returned `ws_ticket` in the URL.
Tickets are scoped to `/ws/transcribe` or `/ws/events`, expire after 30 seconds,
Tickets are scoped to one of `/ws/transcribe`, `/ws/events` or `/ws/tts` (the
live dub preview stream), expire after 30 seconds,
return the same bounded `expires_in`/`expires_at` pair, and are consumed
atomically at most once. Same-origin UI WebSockets use the
HttpOnly session cookie and must pass exact `Origin` validation; `null`, missing,
@@ -338,7 +339,8 @@ drives exact-Origin checks and the session cookie's `Secure` attribute.
For a public path prefix such as `/studio`, either strip that prefix before
forwarding or configure the ASGI `root_path` to the same value. WebSocket ticket
validation removes only that trusted, configured prefix; it never accepts an
arbitrary path merely because it ends in `/ws/events` or `/ws/transcribe`.
arbitrary path merely because it ends in `/ws/events`, `/ws/transcribe` or
`/ws/tts`.
## Status codes

Some files were not shown because too many files have changed in this diff Show More