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.

fix(tts): the Inworld voice stops guessing the language too

Harald25ed8096f1e2
diff --git a/jarvis/plugins/tts/cartesia_tts.py b/jarvis/plugins/tts/cartesia_tts.py
index bda3078251..04430e7130 100644
--- a/jarvis/plugins/tts/cartesia_tts.py
+++ b/jarvis/plugins/tts/cartesia_tts.py
@@ -47,29 +47,6 @@ DEFAULT_VOICE_ID = DEFAULT_VOICE_ID_EN
_SENTENCE_END = re.compile(r"(?<=[.!?…])\s+(?=[A-ZÄÖÜ])") # i18n-allow (DE letters are part of the sentence-boundary match set)
-# DEPRECATED — no longer used by this plugin. This sniff picked the VOICE from
-# bare function words, so English prose containing "die"/"das"/"der"/"ist" was
-# spoken by the German voice: "the die is cast" came out with German phonetics,
-# i.e. the right words rendered unintelligible. Language is resolved ONCE per
-# turn by the pipeline (``resolve_output_language``) and arrives as
-# ``language_code``; a plugin must not re-derive it, and cannot call the
-# resolver anyway (no ``jarvis.*`` import inside plugins, CLAUDE.md §5).
-#
-# Kept only because ``jarvis.plugins.tts.inworld_tts`` still imports it and
-# carries the identical defect; delete both together once that plugin takes its
-# language from the caller too.
-_DE_HINTS = re.compile(r"[äöüÄÖÜß]|\b(ich|nicht|und|der|die|das|ist|mit|für|werde|machen|gerne|bitte)\b", re.IGNORECASE) # i18n-allow (DE word list a language-detection classifier must match)
-_ES_HINTS = re.compile(r"[ñáéíóúÑÁÉÍÓÚ¿¡]|\b(que|para|con|por|esto|esta|hola|gracias|señor|cómo)\b", re.IGNORECASE)
-
-
-def _detect_lang_from_text(text: str) -> str | None:
- """Return 'de', 'es' or None. DEPRECATED — see the note above."""
- if _DE_HINTS.search(text):
- return "de"
- if _ES_HINTS.search(text):
- return "es"
- return None
-
class _CartesiaFatalError(RuntimeError):
"""401/403/429 — triggers cooldown + fallback switch."""
diff --git a/jarvis/plugins/tts/inworld_tts.py b/jarvis/plugins/tts/inworld_tts.py
index 8b0accff8e..c2b4c2978e 100644
--- a/jarvis/plugins/tts/inworld_tts.py
+++ b/jarvis/plugins/tts/inworld_tts.py
@@ -27,7 +27,6 @@ from typing import Any
from jarvis.core import config as cfg
from jarvis.core.protocols import AudioChunk
from jarvis.core.turn_language import DEFAULT_LOCALE
-from jarvis.plugins.tts.cartesia_tts import _detect_lang_from_text
from jarvis.plugins.tts.gemini_flash_tts import SAPI5_SAMPLE_RATE, _sapi5_synthesize
INWORLD_TTS_SAMPLE_RATE = 24_000
@@ -132,9 +131,17 @@ class InworldTTS:
def _resolve_voice(
self, text: str, voice_override: str | None, language_code: str | None
) -> str:
- """Pick the voice best matching the segment language (Cartesia parity):
- explicit override → caller language_code → text heuristic → default
- locale (never a hardcoded English voice on German text)."""
+ """Pick the voice for the segment (Cartesia parity): explicit override →
+ caller language_code → configured default locale.
+
+ Deliberately NOT a text heuristic. Sniffing the words picked German for
+ any English sentence containing "die", "das" or "der" — "the die is
+ cast" came out in a German voice, right words and wrong phonetics. The
+ turn's language is already decided by the one resolver
+ (jarvis/core/turn_language.py); a plugin may not import jarvis to ask
+ it, so the caller must pass the code and a missing one degrades
+ honestly to the configured default instead of guessing.
+ """
if voice_override:
return voice_override
hint = (language_code or "").lower().strip()
@@ -142,9 +149,13 @@ class InworldTTS:
short = hint.split("-", 1)[0]
if short in self._voice_by_lang:
return self._voice_by_lang[short]
- detected = _detect_lang_from_text(text)
- if detected and detected in self._voice_by_lang:
- return self._voice_by_lang[detected]
+ elif text.strip():
+ logging.getLogger("jarvis.tts.inworld").warning(
+ "No language_code passed for %r — falling back to the "
+ "configured default voice (%s). The caller must pass this "
+ "turn's resolved output language.",
+ text[:60], self._default_locale,
+ )
return self._voice_by_lang.get(self._default_locale, self._voice_by_lang["en"])
def _resolve_api_key(self) -> str: