* refactor(launchpad): quieter, borderless design refresh The launchpad carried decoration from an earlier direction: icon chips, corner-hung count badges, a permanently visible filled arrow, uppercase mono card titles, and a dotted stipple divider — plus a frame that had been invisible since the app-wide border tokens were zeroed. Rework it around what the borderless direction actually implies: - Feature tiles get a whisper-faint surface instead of a dead frame, and read as three bands (bare glyph + count / title + arrow / description). `--card-hue` is spent sparingly — the glyph at rest, the surface, count and arrow only once raised. Titles move to sans sentence case; counts are plain tabular numerals. Lift softened 4px -> 2px, coloured glow -> neutral shadow, plus an explicit focus ring and a staggered entrance. - Hero drops the boxed "646" pill and the filled A/B-Compare button for quiet type, with a hairline standing in for the separation. - Section labels trade the dotted stipple for a single fading hairline; rows are transparent until hover and reveal "Open" on hover/focus (it stays in the DOM, so AT and keyboard always reach it). - Hero, tiles, recent files, callout and project lists now share one 1180px column — previously only the top half was capped, so lists ran edge-to-edge on a wide display while the deck stayed centred. Two bugs found and fixed while doing it: - Buttons that had `border border-solid border-transparent` removed fell back to the UA default border and rendered a visible 1px outline. They now carry `border-0` explicitly. - `.lp-animate` used `animation-fill-mode: both`, so after the entrance it kept owning `transform` — and animation-origin declarations outrank normal ones, which silently killed the card hover lift. Now `backwards`, which still holds the from-state through the stagger delay. Also drops CSS the page has not rendered since #904: the cursor-spotlight layer, the breath ring, and the per-card waveform strip. Verified with headless renders at 1600/1280/940 and the empty state. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(dictation): decode Wayland portal signals and show the capture pill The GlobalShortcuts portal declares Activated/Deactivated as (o session, s shortcut_id, t timestamp, a{sv} options). We decoded the timestamp as u32, so zbus rejected every signal with Signature mismatch: got `(osta{sv})`, expected `(osua{sv})` and the press was dropped as an invalid signal. Registration succeeded and the desktop even reported the bound chord back, so the hotkey looked wired up while doing nothing at all — on every Wayland compositor, for the whole life of the feature (#1490). Decode the 64-bit timestamp, and keep the 32-bit spelling as a fallback so a non-conforming portal degrades to working rather than to silence. With presses arriving, the second half of the failure showed: nothing had shown the widget window since it became a hidden recorder host, so a capture ran with no pill on screen — and a mic or Accessibility failure rendered into a window nobody could see. Add show_dictation_pill, which bottom-centres the capsule on the monitor under the pointer and shows it without taking focus (Windows keeps SW_SHOWNOACTIVATE so paste still lands in the user's document), and call it from the widget for every state but idle. Wayland denies clients their own placement, so the compositor picks the spot there; the pill still appears. dispatch_dictation_capture now logs whether a press was emitted or queued — a press that reaches Rust and produces nothing was otherwise indistinguishable from one the compositor never delivered. Tests: portal signals decode at both timestamp widths (the 64-bit case fails before this change with the exact production error); pill placement centres, respects a second monitor's origin, and clamps rather than going off-screen; the widget shows for a state needing the user, stays hidden while idle, and never shows for a press that arrives while dictation is disabled. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * chore: sync in-progress workspace changes Uncommitted work already in the tree, checkpointed so the branch matches the local machine: - Remote GPU workers: join-from-the-app flow, one-time secrets, QR join codes, a Compute control in the status bar, and the device-list Workers panel (#1516) - Model Catalogue workspace, with Settings pointing at it - Settings sidebar search and keyboard navigation - Demo assets for dubbing, dictation and voice design, plus the scripts that render them - Backend: validation-error handling, ASR request-path degradation, and the accompanying tests - CHANGELOG entries for the above and for the Wayland dictation fix Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(tests): follow Engines to the Model Catalogue, and green the sweep - test_supertonic3 asserted the license gate points at "Settings" while the engine now names Model Catalogue → Engines, which is where the accept button actually lives. The assertion follows the move; what it pins is unchanged — the hint must name a place the user can reach it. - Carries the CJK allowlist entries for the rendered dub bundle (#1517) and the regenerated route snapshot for /workers/agent (#1516), both of which this branch inherits from the workspace sync. - docs/install/linux.md: the dictation capsule is bottom-anchored everywhere except Wayland, where the protocol gives applications no say in their placement. Documented rather than left as a surprise (CodeRabbit). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * ci: stop a flaky dependency fetch from failing green runs en-core-web-sm resolves to a direct GitHub release URL, and github.com intermittently answers `http2 error: refused stream before processing any application logic`. uv's own three retries all land within the same few seconds and fail together, so the whole job dies on a dependency that has nothing to do with the change under test — it cost #1518 and #1517 an otherwise-green run tonight. Two changes: back off between whole `uv sync` attempts, which is what actually clears it, and pass --no-sync to the pytest steps. `uv run` re-resolves the environment before running, so every test step was a fresh chance to hit the same fetch even though the install step had already synced — that is exactly how #1518 failed, in the isolated backend/tests step, with all 5467 tests already passed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * ci: one retry seam for every uv sync, not just the job that failed last en-core-web-sm resolves to a direct GitHub *release* URL rather than a package index, and github.com intermittently answers `http2 error: refused stream before processing any application logic`. uv's own retries all land inside the same ~10 seconds and fail together, so a job dies on a dependency unrelated to the change under test. Tonight that cost four otherwise-green runs across #1515, #1517 and #1518 — and the first fix only covered the Tests job, so the next failure simply moved to Smoke (Linux), which syncs separately. The fetch is per-job, so the fix has to be per-job: scripts/uv-sync-retry.sh backs off between whole attempts (15s, 45s, 90s) and every workflow that syncs now goes through it — ci.yml (tests + the platform matrix), release.yml, security.yml, evals.yml. It still fails loudly after four attempts, so a genuinely broken lockfile is not disguised as a flake. The Tests job also lacked the UV_HTTP_TIMEOUT / UV_HTTP_RETRIES the smoke matrix has always set, which is part of why it was the one that kept dying; it has them now. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * test(ci): pin the Intel-Mac contract by intent, not by command spelling test_ci_verifies_intel_mac_as_the_documented_remote_only_host asserted the literal line `run: uv sync --extra pockettts`, so routing every sync through scripts/uv-sync-retry.sh read as a broken Intel-Mac contract. The contract it exists to protect is that the pockettts extra installs ONLY on backend_supported legs — which the regex now pins, while leaving how the sync is invoked free to change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * ci: keep every uv run out of the resolver, and bound the retry budget CodeRabbit, #1517: - `uv run` re-resolves before running, so the smoke suite, the worker-artifact tests, the release test run and the eval run were each a fresh chance to hit the flaky direct-URL fetch outside the retry loop. All of them pass --no-sync now; the environment is already synced by the step that owns the retries. security.yml's `uv run --with pip-audit` is deliberately left alone — it layers an ephemeral package rather than running the project's own tests. - The retry count multiplied uv's own budget (UV_HTTP_RETRIES=5 with a 120 s timeout on the smoke matrix). Three attempts and 60 s of total backoff outlast the refusals actually observed while staying well inside the jobs' timeout-minutes. - The Intel-Mac contract test pinned the smoke command literally too, so --no-sync tripped it exactly like the sync line did. Same fix: assert the contract (smoke runs only on backend_supported legs), not its spelling. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
346 lines
13 KiB
Python
346 lines
13 KiB
Python
"""Issue #312 class — dub generation and batch TTS must honor the active
|
|
engine selection (Model Catalogue → Engines) instead of silently falling back to
|
|
OmniVoice via services.model_manager.get_model(), and must refuse — with an
|
|
actionable error naming alternatives — instead of mis-cloning when the
|
|
active engine can't do reference-audio voice cloning.
|
|
|
|
Covers:
|
|
- `cloning_capable_engine_ids()` excludes the fixed-preset-voice engines
|
|
(kittentts, supertonic3, sherpa-onnx) and includes the cloning ones.
|
|
- /dub/generate: a non-cloning active engine fails the whole job with one
|
|
actionable message (never falls back to OmniVoice, never mis-clones
|
|
per segment).
|
|
- /dub/generate: a cloning-capable non-OmniVoice active engine actually
|
|
runs the request (proves the engine selection is honored, not ignored).
|
|
- batch: an unpinned voice_id runs fine on a non-cloning active engine;
|
|
a pinned voice_id on the same engine fails fast, before any TTS runs.
|
|
- `applies_own_mastering` still skips the shared mastering chain for both
|
|
pipelines (mirrors test_generate_engine.py's coverage of the same knob
|
|
for /generate).
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import asyncio
|
|
import importlib
|
|
import os
|
|
|
|
os.environ.setdefault("OMNIVOICE_DISABLE_FILE_LOG", "1")
|
|
|
|
import pytest
|
|
import torch
|
|
from fastapi import HTTPException
|
|
|
|
from schemas.requests import DubRequest, DubSegment
|
|
|
|
|
|
def _tts_mod():
|
|
"""Resolve services.tts_backend at RUN time — see test_generate_engine.py's
|
|
docstring for why (sys.modules pre-pollution across the collected suite)."""
|
|
return importlib.import_module("services.tts_backend")
|
|
|
|
|
|
def _make_fake_engine(engine_id, *, supports_cloning=True, available=True,
|
|
own_mastering=False, gpu_compat=("cpu",)):
|
|
tb = _tts_mod()
|
|
# Class-body assignment can't read the same name from the enclosing
|
|
# function scope (class bodies don't close over locals) — alias first,
|
|
# matching test_generate_engine.py's _make_fake_engine convention.
|
|
_cloning, _mastering, _compat = supports_cloning, own_mastering, gpu_compat
|
|
|
|
class _FakeEngine(tb.TTSBackend):
|
|
id = engine_id
|
|
display_name = f"Fake {engine_id} (test)"
|
|
supports_cloning = _cloning
|
|
applies_own_mastering = _mastering
|
|
gpu_compat = _compat
|
|
calls: list = []
|
|
|
|
@property
|
|
def sample_rate(self) -> int:
|
|
return 24000
|
|
|
|
@property
|
|
def supported_languages(self) -> list[str]:
|
|
return ["multi"]
|
|
|
|
@classmethod
|
|
def is_available(cls):
|
|
if available:
|
|
return True, "ready"
|
|
return False, "fake engine deliberately unavailable (test)"
|
|
|
|
def generate(self, text, **kw) -> torch.Tensor:
|
|
type(self).calls.append((text, kw))
|
|
return torch.zeros(1, 24000)
|
|
|
|
return _FakeEngine
|
|
|
|
|
|
@pytest.fixture
|
|
def fake_registry(monkeypatch):
|
|
"""Register a fake engine in the REAL registry so resolve_generation_backend
|
|
exercises the actual lookup/is_available/routing/cloning chain, not a stub.
|
|
Resets the MM2-01 active-backend cache before/after (see
|
|
tests/test_mm2_lifecycle.py's convention) so one test's cached instance
|
|
can't leak into the next."""
|
|
tb = _tts_mod()
|
|
tb.reset_active_backend()
|
|
registered: list[str] = []
|
|
|
|
def _register(engine_id, **kw):
|
|
cls = _make_fake_engine(engine_id, **kw)
|
|
tb._REGISTRY[engine_id] = cls
|
|
registered.append(engine_id)
|
|
return cls
|
|
|
|
yield _register
|
|
|
|
tb.reset_active_backend()
|
|
for engine_id in registered:
|
|
tb._REGISTRY.pop(engine_id, None)
|
|
|
|
|
|
@pytest.fixture
|
|
def no_omnivoice_model_manager(monkeypatch):
|
|
"""Fail loudly if resolution falls back to OmniVoice's get_model() path."""
|
|
import services.model_manager as mm
|
|
|
|
async def _boom():
|
|
raise AssertionError(
|
|
"services.model_manager.get_model() was called — engine "
|
|
"selection was silently ignored (#312 class)"
|
|
)
|
|
|
|
monkeypatch.setattr(mm, "get_model", _boom)
|
|
|
|
|
|
# ── cloning_capable_engine_ids() ────────────────────────────────────────────
|
|
|
|
|
|
def test_cloning_capable_engine_ids_excludes_fixed_voice_engines():
|
|
tb = _tts_mod()
|
|
ids = set(tb.cloning_capable_engine_ids())
|
|
assert ids.isdisjoint({"kittentts", "supertonic3", "sherpa-onnx"})
|
|
assert {"omnivoice", "voxcpm2", "cosyvoice", "gpt-sovits"}.issubset(ids)
|
|
|
|
|
|
def test_cloning_capable_engine_ids_excludes_model_dependent_adapters():
|
|
# MLXAudioBackend.supports_cloning is an instance @property (only some of
|
|
# its curated models can clone) — a class-level getattr() returns the
|
|
# property descriptor itself, which is truthy, so a naive check would
|
|
# always recommend "mlx-audio" even when the configured model is Kokoro
|
|
# (can't clone). Must be excluded from the suggestion list rather than
|
|
# falsely recommended.
|
|
tb = _tts_mod()
|
|
assert isinstance(
|
|
vars(tb.MLXAudioBackend).get("supports_cloning"), property
|
|
), "this test assumes MLXAudioBackend.supports_cloning is a property"
|
|
assert "mlx-audio" not in set(tb.cloning_capable_engine_ids())
|
|
|
|
|
|
# ── /dub/generate/{job_id} ──────────────────────────────────────────────────
|
|
|
|
|
|
@pytest.fixture
|
|
def dub_job_env(monkeypatch, tmp_path):
|
|
"""Minimal hermetic environment for `dg.dub_generate()` — same stub set as
|
|
test_smart_fit_generate.py's fixture, but WITHOUT patching
|
|
resolve_generation_backend, so the real registry + capability gate run."""
|
|
import api.routers.dub_generate as dg
|
|
|
|
job = {"duration": 2.0, "dubbed_tracks": {}, "speaker_clones": {}}
|
|
job_dir = tmp_path / "jobX"
|
|
job_dir.mkdir()
|
|
|
|
monkeypatch.setattr(dg, "_get_job", lambda job_id: job)
|
|
monkeypatch.setattr(dg, "_save_job", lambda job_id, j: None)
|
|
monkeypatch.setattr(dg, "DUB_DIR", str(tmp_path))
|
|
monkeypatch.setattr(
|
|
dg, "dub_seg_path",
|
|
lambda job_id, seg_id: str(job_dir / f"seg_{seg_id}.wav"),
|
|
)
|
|
monkeypatch.setattr(dg, "rvc_is_enabled", lambda: False)
|
|
monkeypatch.setattr(dg, "mark_synthetic", lambda wav, sr, **kw: wav)
|
|
monkeypatch.setattr(dg, "apply_mastering", lambda a, sample_rate=None: a)
|
|
monkeypatch.setattr(dg, "get_effect_chain", lambda preset: None)
|
|
monkeypatch.setattr(dg, "apply_effects_chain", lambda a, **k: a)
|
|
monkeypatch.setattr(dg, "normalize_audio", lambda a, target_dBFS=None: a)
|
|
|
|
class _StubTaskManager:
|
|
def is_cancelled(self, task_id):
|
|
return False
|
|
|
|
async def add_task(self, task_id, task_type, func, *args, **kwargs):
|
|
async for _ in func(*args):
|
|
pass
|
|
|
|
monkeypatch.setattr(dg, "task_manager", _StubTaskManager())
|
|
return dg, job
|
|
|
|
|
|
def _one_seg_request():
|
|
return DubRequest(
|
|
segments=[DubSegment(start=0.0, end=1.0, text="hola")],
|
|
segment_ids=["0"], language="Auto", language_code="es", num_step=4,
|
|
)
|
|
|
|
|
|
def test_dub_generate_fails_fast_for_non_cloning_engine(
|
|
dub_job_env, fake_registry, no_omnivoice_model_manager, monkeypatch,
|
|
):
|
|
"""Active engine can't clone → the job fails once, up front, with an
|
|
actionable message naming alternatives — never a silent OmniVoice run."""
|
|
dg, job = dub_job_env
|
|
fake_registry("fake-nonclone", supports_cloning=False)
|
|
monkeypatch.setenv("OMNIVOICE_TTS_BACKEND", "fake-nonclone")
|
|
|
|
with pytest.raises(HTTPException) as exc_info:
|
|
asyncio.run(dg.dub_generate("jobX", _one_seg_request()))
|
|
|
|
assert exc_info.value.status_code == 400
|
|
detail = exc_info.value.detail
|
|
assert "fake-nonclone" in detail
|
|
assert "voice cloning" in detail
|
|
assert "omnivoice" in detail # names a real alternative
|
|
|
|
|
|
def test_dub_generate_uses_selected_cloning_engine_not_omnivoice(
|
|
dub_job_env, fake_registry, no_omnivoice_model_manager, monkeypatch,
|
|
):
|
|
"""A cloning-capable non-OmniVoice engine actually runs the segment."""
|
|
dg, job = dub_job_env
|
|
fake = fake_registry("fake-clone", supports_cloning=True)
|
|
monkeypatch.setenv("OMNIVOICE_TTS_BACKEND", "fake-clone")
|
|
|
|
asyncio.run(dg.dub_generate("jobX", _one_seg_request()))
|
|
|
|
assert len(fake.calls) == 1
|
|
assert fake.calls[0][0] == "hola"
|
|
assert "es" in job["dubbed_tracks"]
|
|
|
|
|
|
def test_dub_generate_respects_applies_own_mastering(
|
|
dub_job_env, fake_registry, no_omnivoice_model_manager, monkeypatch,
|
|
):
|
|
dg, job = dub_job_env
|
|
fake = fake_registry("fake-studio", supports_cloning=True, own_mastering=True)
|
|
monkeypatch.setenv("OMNIVOICE_TTS_BACKEND", "fake-studio")
|
|
|
|
mastering_calls = []
|
|
monkeypatch.setattr(
|
|
dg, "apply_mastering",
|
|
lambda a, sample_rate=None: mastering_calls.append(1) or a,
|
|
)
|
|
|
|
asyncio.run(dg.dub_generate("jobX", _one_seg_request()))
|
|
|
|
assert len(fake.calls) == 1
|
|
assert mastering_calls == [] # studio engine's own mastering is not double-applied
|
|
|
|
|
|
# ── batch ────────────────────────────────────────────────────────────────
|
|
|
|
|
|
@pytest.fixture
|
|
def batch_job_env(monkeypatch, tmp_path):
|
|
import api.routers.batch as b
|
|
|
|
monkeypatch.setattr(b, "DATA_DIR", str(tmp_path))
|
|
|
|
async def _fake_run_transcribe_guarded(pool, fn, what=None):
|
|
# Bypass real ASR entirely — the engine-selection gate under test
|
|
# runs right after transcription, before translate/generate.
|
|
return (
|
|
[{"id": "s0", "start": 0.0, "end": 1.0, "text": "hola",
|
|
"text_original": "hola"}],
|
|
"en",
|
|
)
|
|
|
|
monkeypatch.setattr(
|
|
"services.asr_backend.run_transcribe_guarded",
|
|
_fake_run_transcribe_guarded,
|
|
)
|
|
|
|
def _fake_subprocess_run(cmd, *a, **kw):
|
|
class _Result:
|
|
stdout = b""
|
|
stderr = b"Duration: 00:00:02.00, start: 0.000000, bitrate: 1000 kb/s\n"
|
|
|
|
return _Result()
|
|
|
|
monkeypatch.setattr("subprocess.run", _fake_subprocess_run)
|
|
monkeypatch.setattr("services.ffmpeg_utils.find_ffmpeg", lambda: "ffmpeg")
|
|
|
|
def _make_job(job_id, *, voice_id=None):
|
|
return {
|
|
"id": job_id,
|
|
"status": "running",
|
|
"filename": "in.mp4",
|
|
"video_path": str(tmp_path / "in.mp4"),
|
|
"langs": ["en"], # == source_lang → translation stage is a no-op
|
|
"voice_id": voice_id,
|
|
"preserve_bg": True,
|
|
"created_at": 0.0,
|
|
"started_at": None,
|
|
"finished_at": None,
|
|
"error": None,
|
|
"progress": None,
|
|
}
|
|
|
|
return b, _make_job
|
|
|
|
|
|
def test_batch_unpinned_voice_succeeds_on_noncloning_engine(
|
|
batch_job_env, fake_registry, no_omnivoice_model_manager, monkeypatch,
|
|
):
|
|
"""No voice_id pinned → any active engine (cloning-capable or not) is fine."""
|
|
b, make_job = batch_job_env
|
|
fake = fake_registry("fake-batch-nonclone", supports_cloning=False)
|
|
monkeypatch.setenv("OMNIVOICE_TTS_BACKEND", "fake-batch-nonclone")
|
|
|
|
job = make_job("jobA", voice_id=None)
|
|
asyncio.run(b._run_batch_pipeline("jobA", job))
|
|
|
|
assert len(fake.calls) == 1
|
|
assert "en" in job.get("outputs", {})
|
|
|
|
|
|
def test_batch_pinned_voice_fails_fast_on_noncloning_engine(
|
|
batch_job_env, fake_registry, monkeypatch,
|
|
):
|
|
"""voice_id pinned + a non-cloning active engine → fail before any TTS
|
|
runs, with the same actionable message shape as the dub gate."""
|
|
b, make_job = batch_job_env
|
|
fake = fake_registry("fake-batch-nonclone2", supports_cloning=False)
|
|
monkeypatch.setenv("OMNIVOICE_TTS_BACKEND", "fake-batch-nonclone2")
|
|
|
|
job = make_job("jobB", voice_id="some-voice-id")
|
|
with pytest.raises(ValueError) as exc_info:
|
|
asyncio.run(b._run_batch_pipeline("jobB", job))
|
|
|
|
detail = str(exc_info.value)
|
|
assert "fake-batch-nonclone2" in detail
|
|
assert "voice cloning" in detail
|
|
assert not fake.calls # never reached generate
|
|
|
|
|
|
def test_batch_respects_applies_own_mastering(
|
|
batch_job_env, fake_registry, no_omnivoice_model_manager, monkeypatch,
|
|
):
|
|
b, make_job = batch_job_env
|
|
fake = fake_registry("fake-batch-studio", supports_cloning=True, own_mastering=True)
|
|
monkeypatch.setenv("OMNIVOICE_TTS_BACKEND", "fake-batch-studio")
|
|
|
|
mastering_calls = []
|
|
import services.audio_dsp as audio_dsp
|
|
monkeypatch.setattr(
|
|
audio_dsp, "apply_mastering",
|
|
lambda a, sample_rate=None: mastering_calls.append(1) or a,
|
|
)
|
|
|
|
job = make_job("jobC", voice_id=None)
|
|
asyncio.run(b._run_batch_pipeline("jobC", job))
|
|
|
|
assert len(fake.calls) == 1
|
|
assert mastering_calls == []
|