Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

chore: auto-save WIP via Claude stop-hook safety net (2026-07-08 07:39)

Ruben Lütke6269e178977f
diff --git a/jarvis/speech/tts_eval/__init__.py b/jarvis/speech/tts_eval/__init__.py
new file mode 100644
index 0000000000..adb6c77b6d
--- /dev/null
+++ b/jarvis/speech/tts_eval/__init__.py
@@ -0,0 +1,42 @@
+"""Objective, offline TTS evaluation suite.
+
+Scores a TTS provider on the four metrics the curation gates on — round-trip
+ASR error (WER), naturalness MOS, voice-drift, and latency (TTFA/RTF) — over a
+hard de/en/es corpus, and produces a pass/fail verdict against acceptance
+thresholds. Runs OFF the voice hot path (a CLI / CI tool, never in a live turn).
+
+Design: docs/superpowers/specs/2026-07-07-tts-quality-curation-design.md §3.6.
+
+Cross-platform: the DNSMOS (onnxruntime) naturalness floor is torch-free and
+runs on a headless VPS; the round-trip-ASR WER backend uses faster-whisper
+(the `[tts-eval]` extra). Every metric backend is lazy-imported and degrades to
+``None`` (logged) when its dependency/model is absent — the harness never
+crashes, it just reports fewer metrics.
+"""
+from __future__ import annotations
+
+from jarvis.speech.tts_eval.corpus import HARD_CORPUS, EvalItem, items_for_language
+from jarvis.speech.tts_eval.harness import (
+ EvalReport,
+ ItemReport,
+ MetricResult,
+ Metrics,
+ SynthResult,
+ Thresholds,
+ evaluate,
+ gate,
+)
+
+__all__ = [
+ "HARD_CORPUS",
+ "EvalItem",
+ "EvalReport",
+ "ItemReport",
+ "MetricResult",
+ "Metrics",
+ "SynthResult",
+ "Thresholds",
+ "evaluate",
+ "gate",
+ "items_for_language",
+]
diff --git a/jarvis/speech/tts_eval/corpus.py b/jarvis/speech/tts_eval/corpus.py
new file mode 100644
index 0000000000..1f42b67ab6
--- /dev/null
+++ b/jarvis/speech/tts_eval/corpus.py
@@ -0,0 +1,129 @@
+"""The hard TTS evaluation corpus — representative de/en/es texts plus the five
+hard-input categories where cheap/experimental models break: numbers, acronyms,
+code tokens, a long passage (voice drift), and de/en/es proper names.
+
+Design: docs/superpowers/specs/2026-07-07-tts-quality-curation-design.md §3.6.
+Builds on the persona scenarios in scripts/voice_compare.py. The de/es strings
+are the *content under test* (a multilingual product surface), so they carry an
+`i18n-allow` marker per file — this is fixture data, not artifact prose.
+"""
+from __future__ import annotations
+
+from dataclasses import dataclass
+
+
+@dataclass(frozen=True)
+class EvalItem:
+ """One evaluation utterance. ``tags`` name the categories it exercises
+ (``persona`` | ``numbers`` | ``acronyms`` | ``code`` | ``long`` | ``names``)."""
+
+ id: str
+ language: str # "de" | "en" | "es"
+ text: str
+ tags: tuple[str, ...]
+
+
+# i18n-allow: the de/es strings below are the multilingual CONTENT under test
+# (round-trip ASR reads them back), not artifact prose — fixture data by design.
+HARD_CORPUS: tuple[EvalItem, ...] = (
+ # ---- English ----------------------------------------------------------
+ EvalItem("en-persona", "en", "Good evening. Everything is on schedule.", ("persona",)),
+ EvalItem(
+ "en-numbers", "en",
+ "The meeting is at 9:45 on March 3rd, and the invoice total is 1,284.50 dollars.",
+ ("numbers",),
+ ),
+ EvalItem(
+ "en-acronyms", "en",
+ "The NASA and NATO reports were sent as a PDF via the HTTP API to the CEO.",
+ ("acronyms",),
+ ),
+ EvalItem(
+ "en-code", "en",
+ "Call build_tts_from_config with tts_cfg, then await synthesize() and check the AudioChunk.",
+ ("code",),
+ ),
+ EvalItem(
+ "en-names", "en",
+ "Please forward this to Siobhan, Rajesh, Björk, and Xavier Nguyen.",
+ ("names",),
+ ),
+ EvalItem(
+ "en-long", "en",
+ "Let me summarize the situation for you. The deployment finished about ten "
+ "minutes ago, and all three services came back healthy on the first try. "
+ "There is one warning in the logs about a slow database query, but it did "
+ "not affect any requests, and the latency is already back within its normal "
+ "range. I will keep an eye on it and let you know if anything changes.",
+ ("long",),
+ ),
+ # ---- German -----------------------------------------------------------
+ EvalItem("de-persona", "de", "Guten Abend. Es ist alles im Zeitplan.", ("persona",)),
+ EvalItem(
+ "de-numbers", "de",
+ "Der Termin ist am 3. März um 9:45 Uhr, und die Rechnung beträgt 1.284,50 Euro.",
+ ("numbers",),
+ ),
+ EvalItem(
+ "de-acronyms", "de",
+ "Die GmbH schickte den DSGVO-Bericht als PDF über die HTTP-Schnittstelle an die IHK.",
+ ("acronyms",),
+ ),
+ EvalItem(
+ "de-code", "de",
+ "Rufe build_tts_from_config mit tts_cfg auf und prüfe danach den AudioChunk.",
+ ("code",),
+ ),
+ EvalItem(
+ "de-names", "de",
+ "Bitte leite das an Häberle, Grzegorz, Søren und Xavier Nguyen weiter.",
+ ("names",),
+ ),
+ EvalItem(
+ "de-long", "de",
+ "Lass mich die Lage kurz zusammenfassen. Der Deploy ist vor etwa zehn Minuten "
+ "durchgelaufen, und alle drei Dienste sind beim ersten Versuch wieder gesund "
+ "geworden. Es gibt eine Warnung im Log über eine langsame Datenbankabfrage, "
+ "aber sie hat keine Anfrage beeinträchtigt, und die Latenz ist längst wieder "
+ "im normalen Bereich. Ich behalte es im Auge und melde mich, falls sich etwas "
+ "ändert.",
+ ("long",),
+ ),
+ # ---- Spanish ----------------------------------------------------------
+ EvalItem("es-persona", "es", "Buenas noches. Todo va según lo previsto.", ("persona",)),
+ EvalItem(
+ "es-numbers", "es",
+ "La reunión es el 3 de marzo a las 9:45, y la factura asciende a 1.284,50 euros.",
+ ("numbers",),
+ ),
+ EvalItem(
+ "es-acronyms", "es",
+ "La ONU y la OTAN enviaron el informe en PDF a través de la API HTTP al director.",
+ ("acronyms",),
+ ),
+ EvalItem(
+ "es-code", "es",
+ "Llama a build_tts_from_config con tts_cfg y luego revisa el AudioChunk.",
+ ("code",),
+ ),
+ EvalItem(
+ "es-names", "es",
+ "Reenvía esto a Íñigo, Jokin, Søren y Xavier Nguyen, por favor.",
+ ("names",),
+ ),
+ EvalItem(
+ "es-long", "es",
+ "Déjame resumir la situación. El despliegue terminó hace unos diez minutos, y "
+ "los tres servicios volvieron a estar sanos al primer intento. Hay un aviso en "
+ "el registro sobre una consulta lenta a la base de datos, pero no afectó a "
+ "ninguna petición, y la latencia ya está de nuevo dentro de su rango normal. "
+ "Lo seguiré vigilando y te aviso si algo cambia.",
+ ("long",),
+ ),
+)
+
+
+def items_for_language(language: str) -> tuple[EvalItem, ...]:
+ """The corpus items for a two-letter language code."""
+ short = (language or "").lower().split("-", 1)[0]
+ return tuple(i for i in HARD_CORPUS if i.language == short)
diff --git a/tests/unit/speech/tts_eval/test_corpus.py b/tests/unit/speech/tts_eval/test_corpus.py
new file mode 100644
index 0000000000..137157dcfa
--- /dev/null
+++ b/tests/unit/speech/tts_eval/test_corpus.py
@@ -0,0 +1,42 @@
+"""The eval corpus must cover de/en/es and the five hard-input categories."""
+from __future__ import annotations
+
+from jarvis.speech.tts_eval.corpus import HARD_CORPUS, EvalItem, items_for_language
+
+
+def test_all_three_languages_present():
+ langs = {i.language for i in HARD_CORPUS}
+ assert {"de", "en", "es"} <= langs
+
+
+def test_every_hard_category_present_per_language():
+ hard = {"numbers", "acronyms", "code", "long", "names"}
+ for lang in ("de", "en", "es"):
+ tags = set().union(*(set(i.tags) for i in items_for_language(lang)))
+ missing = hard - tags
+ assert not missing, f"{lang} missing hard categories: {missing}"
+
+
+def test_items_have_nonempty_text_and_valid_language():
+ for i in HARD_CORPUS:
+ assert isinstance(i, EvalItem)
+ assert i.text.strip()
+ assert i.language in ("de", "en", "es")
+ assert i.tags
+
+
+def test_items_for_language_filters():
+ de = items_for_language("de")
+ assert de and all(i.language == "de" for i in de)
+
+
+def test_ids_are_unique():
+ ids = [i.id for i in HARD_CORPUS]
+ assert len(ids) == len(set(ids))
+
+
+def test_long_items_are_actually_long():
+ # A "long" passage must be long enough to expose voice drift.
+ for i in HARD_CORPUS:
+ if "long" in i.tags:
+ assert len(i.text) >= 200, (i.id, len(i.text))