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(voice): never let the classic TTS voice speak into a live realtime call

Ruben Lütke95450bc8011b
diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.py
index 0a578a27a4..ae498655bd 100644
--- a/jarvis/realtime/session.py
+++ b/jarvis/realtime/session.py
@@ -674,6 +674,22 @@ class RealtimeVoiceSession:
)
raise RuntimeError(message) from exc
+ @property
+ def is_active(self) -> bool:
+ """True while this live call owns the voice surface.
+
+ The speech pipeline consults this before falling back to classic
+ TTS for an announcement: while a live realtime call is healthy, a
+ different synthetic voice must never speak into it (voice-identity
+ break, forensic 2026-07-13 17:39). Once the call ended or failed,
+ the classic voice is the honest remaining surface.
+ """
+ return (
+ not self._ended
+ and self._session is not None
+ and not self._failed.is_set()
+ )
+
async def deliver_announcement(
self,
*,
diff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.py
index d187da39ff..fbab92a58d 100644
--- a/jarvis/speech/pipeline.py
+++ b/jarvis/speech/pipeline.py
@@ -3236,6 +3236,30 @@ class SpeechPipeline:
# second, classic-pipeline voice and duplicate the readback.
self._last_announcement_spoken_monotonic = time.monotonic()
return
+ if self._realtime_session_owns_voice():
+ # The live call rejected the delivery only because it is BUSY
+ # (its delegate turn is thinking). The classic TTS voice must
+ # never speak into a healthy realtime call — the user hears a
+ # sudden second voice/engine (forensic 2026-07-13 17:39, the
+ # wiki preamble). Ephemeral lines are stale by the time the
+ # live model could speak them → drop; owed readbacks are parked
+ # and replayed at the next turn boundary, where the idle live
+ # model accepts them (or the call has ended and classic TTS is
+ # the honest remaining surface).
+ if is_preamble or is_progress:
+ log.info(
+ "Announcement dropped — a live realtime call owns the "
+ "voice: %r",
+ event.text[:80],
+ )
+ return
+ self._deferred_announcements.append(event)
+ log.info(
+ "Announcement deferred — a live realtime call owns the "
+ "voice: %r",
+ event.text[:80],
+ )
+ return
# We are now committed to actually speaking this announcement (past every
# suppression / defer / empty guard). Record it as voice activity so the
# idle-timeout branch in ``_active_session`` re-arms a fresh window: an
@@ -3306,6 +3330,13 @@ class SpeechPipeline:
hungup = hangup is not None and hangup.is_set()
await self._transition("IDLE" if hungup else "LISTENING")
+ def _realtime_session_owns_voice(self) -> bool:
+ """True while a healthy live realtime call is the only valid voice."""
+ if getattr(self, "_active_voice_mode", None) != "realtime":
+ return False
+ session = getattr(self, "_active_realtime_handle", None)
+ return bool(session is not None and getattr(session, "is_active", False))
+
async def _deliver_announcement_via_realtime(
self,
event: AnnouncementRequested,
diff --git a/tests/unit/speech/test_realtime_announcement_bridge.py b/tests/unit/speech/test_realtime_announcement_bridge.py
index 8e43f7d069..5fa01c173d 100644
--- a/tests/unit/speech/test_realtime_announcement_bridge.py
+++ b/tests/unit/speech/test_realtime_announcement_bridge.py
@@ -2,6 +2,7 @@
from __future__ import annotations
+import asyncio
from collections.abc import AsyncIterator
from dataclasses import dataclass, field
@@ -44,8 +45,9 @@ class _FakePlayer:
class _FakeRealtimeHandle:
- def __init__(self, *, accepted: bool) -> None:
+ def __init__(self, *, accepted: bool, is_active: bool = True) -> None:
self.accepted = accepted
+ self.is_active = is_active
self.calls: list[dict[str, object]] = []
async def deliver_announcement(self, **kwargs: object) -> bool:
@@ -53,12 +55,12 @@ class _FakeRealtimeHandle:
return self.accepted
-def _pipeline(*, accepted: bool) -> tuple[
+def _pipeline(*, accepted: bool, is_active: bool = True) -> tuple[
SpeechPipeline, _FakeTTS, _FakePlayer, _FakeRealtimeHandle
]:
tts = _FakeTTS()
player = _FakePlayer()
- realtime = _FakeRealtimeHandle(accepted=accepted)
+ realtime = _FakeRealtimeHandle(accepted=accepted, is_active=is_active)
pipeline = SpeechPipeline(tts=tts, enable_whisper_wake=False)
pipeline._player = player # type: ignore[assignment]
pipeline._active_voice_mode = "realtime"
@@ -94,8 +96,9 @@ async def test_subagent_readback_is_handed_to_active_realtime_model() -> None:
@pytest.mark.asyncio
-async def test_realtime_rejection_preserves_classic_tts_fallback() -> None:
- pipeline, tts, player, realtime = _pipeline(accepted=False)
+async def test_dead_session_rejection_preserves_classic_tts_fallback() -> None:
+ """Classic TTS remains the honest surface once the live call ended."""
+ pipeline, tts, player, realtime = _pipeline(accepted=False, is_active=False)
await pipeline._on_announcement(
AnnouncementRequested(
@@ -108,3 +111,63 @@ async def test_realtime_rejection_preserves_classic_tts_fallback() -> None:
assert len(realtime.calls) == 1
assert tts.calls == [("The research report is ready.", "en-US")]
assert player.plays == 1
+
+
+async def test_busy_live_session_defers_owed_readback() -> None:
+ """A healthy busy call parks the readback; no second voice speaks."""
+ pipeline, tts, player, realtime = _pipeline(accepted=False, is_active=True)
+
+ event = AnnouncementRequested(
+ text="The research report is ready.",
+ language="en",
+ kind="completion",
+ )
+ await pipeline._on_announcement(event)
+
+ assert len(realtime.calls) == 1
+ assert tts.calls == []
+ assert player.plays == 0
+ assert pipeline._deferred_announcements == [event]
+
+
+async def test_busy_live_session_drops_ephemeral_preamble() -> None:
+ """A stale preamble is dropped, never spoken by the classic voice."""
+ pipeline, tts, player, realtime = _pipeline(accepted=False, is_active=True)
+
+ await pipeline._on_announcement(
+ AnnouncementRequested(
+ text="I am searching your wiki right now.",
+ language="en",
+ kind="preamble",
+ )
+ )
+
+ assert len(realtime.calls) == 1
+ assert tts.calls == []
+ assert player.plays == 0
+ assert pipeline._deferred_announcements == []
+
+
+async def test_deferred_readback_is_replayed_to_the_idle_live_model() -> None:
+ """At the turn boundary the parked readback reaches the live voice."""
+ pipeline, tts, player, realtime = _pipeline(accepted=False, is_active=True)
+
+ event = AnnouncementRequested(
+ text="The research report is ready.",
+ language="en",
+ kind="completion",
+ )
+ await pipeline._on_announcement(event)
+ assert pipeline._deferred_announcements == [event]
+
+ realtime.accepted = True
+ await pipeline._set_turn_state(TurnTakingState.LISTENING)
+ await asyncio.sleep(0.05)
+
+ assert len(realtime.calls) == 2
+ assert tts.calls == []
+ assert player.plays == 0
+ assert pipeline._deferred_announcements == []