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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix: keep STT metrics self-contained
rubenluetke10-beepaf850c4e46f8
diff --git a/jarvis/speech/stt_eval/metrics.py b/jarvis/speech/stt_eval/metrics.pyindex 84b94ef999..ab01ee7d99 100644--- a/jarvis/speech/stt_eval/metrics.py+++ b/jarvis/speech/stt_eval/metrics.py@@ -6,9 +6,8 @@ import reimport unicodedatafrom collections.abc import Sequence-from jarvis.speech.tts_eval.metrics import word_error_rate-_NON_WORD = re.compile(r"[^\w]+", flags=re.UNICODE)+_WER_WORD = re.compile(r"[^\w']+", flags=re.UNICODE)def _comparison_text(text: str) -> str:@@ -16,6 +15,34 @@ def _comparison_text(text: str) -> str:return " ".join(part for part in _NON_WORD.split(value) if part)+def _wer_words(text: str) -> list[str]:+ """Preserve the historical WER tokenization used by evaluation reports."""+ return [word for word in _WER_WORD.split((text or "").lower()) if word]+++def word_error_rate(reference: str, hypothesis: str) -> float:+ """Return deterministic word-level Levenshtein error for STT output."""+ expected = _wer_words(reference)+ actual = _wer_words(hypothesis)+ if not expected:+ return 0.0 if not actual else 1.0++ previous = list(range(len(actual) + 1))+ for row, expected_word in enumerate(expected, start=1):+ current = [row]+ for column, actual_word in enumerate(actual, start=1):+ substitution = 0 if expected_word == actual_word else 1+ current.append(+ min(+ previous[column] + 1,+ current[column - 1] + 1,+ previous[column - 1] + substitution,+ )+ )+ previous = current+ return previous[-1] / len(expected)++def switch_error_rate(anchors: Sequence[str], hypothesis: str) -> float | None:"""Fraction of annotated language-switch anchors missing from a result.diff --git a/tests/unit/speech/stt_eval/test_metrics.py b/tests/unit/speech/stt_eval/test_metrics.pyindex bac6b40909..d90b9564bc 100644--- a/tests/unit/speech/stt_eval/test_metrics.py+++ b/tests/unit/speech/stt_eval/test_metrics.py@@ -1,11 +1,42 @@"""Multilingual STT evaluation metrics."""+import importlib+import sys++import pytest++from jarvis.speech.stt_eval import metrics as metrics_modulefrom jarvis.speech.stt_eval.metrics import (repeatability_error_rate,switch_error_rate,+ word_error_rate,)+def test_word_error_rate_is_self_contained_and_normalized() -> None:+ assert word_error_rate("Hello, world!", "hello world") == 0.0+ assert word_error_rate("one two three", "one four three") == 1 / 3+ assert word_error_rate("one two three", "one three") == 1 / 3+ assert word_error_rate("one three", "one two three") == 1 / 2+ assert word_error_rate("", "") == 0.0+ assert word_error_rate("", "unexpected") == 1.0+ assert word_error_rate("one", "one two three") == 2.0+++def test_word_error_rate_preserves_legacy_contraction_tokenization() -> None:+ assert word_error_rate("can't stop", "can t stop") == 1.0+++def test_metrics_import_without_private_tts_eval(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ monkeypatch.setitem(sys.modules, "jarvis.speech.tts_eval.metrics", None)++ reloaded = importlib.reload(metrics_module)++ assert reloaded.word_error_rate("same", "same") == 0.0++def test_switch_anchors_cover_multiple_language_families_and_names() -> None:hypothesis = ("Please ask Nova mañana por la mañana ثم send the report "