Devon improvements: independent audio, realism overhaul

- Devon audio independent of caller hangup (separate stop events)
- Personal anecdotes capped at ~30% of responses (was every time)
- Interjection criteria tightened ("default is silence")
- Devon sees his own recent history to avoid repeating info
- Response variety: permits minimal reactions, confusion, silence
- Monitor prompt rewritten to be gatekeeping, not encouraging

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-21 02:08:22 -06:00
parent 9eaf2fe5e3
commit 390f138601
2 changed files with 70 additions and 33 deletions
+18 -6
View File
@@ -114,6 +114,7 @@ class AudioService:
# Caller playback state
self._caller_stop_event = threading.Event()
self._devon_stop_event = threading.Event()
self._caller_thread: Optional[threading.Thread] = None
# Host mic streaming state
@@ -431,9 +432,16 @@ class AudioService:
"""Play TTS audio to specific channel of output device (interruptible)"""
import librosa
# Stop any existing caller audio
self.stop_caller_audio()
self._caller_stop_event.clear()
# Devon uses its own stop event so hangup doesn't cut Devon's audio
is_devon = stem_name == "devon"
stop_event = self._devon_stop_event if is_devon else self._caller_stop_event
# Stop any existing audio on the same channel type
if is_devon:
self.stop_devon_audio()
else:
self.stop_caller_audio()
stop_event.clear()
# Convert bytes to numpy
audio = np.frombuffer(audio_bytes, dtype=np.int16).astype(np.float32) / 32768.0
@@ -476,7 +484,7 @@ class AudioService:
channels=num_channels,
dtype=np.float32
) as stream:
while pos < len(multi_ch) and not self._caller_stop_event.is_set():
while pos < len(multi_ch) and not stop_event.is_set():
end = min(pos + chunk_size, len(multi_ch))
stream.write(multi_ch[pos:end])
# Record each chunk as it plays so hangups cut the stem too
@@ -485,8 +493,8 @@ class AudioService:
rec.write_sporadic(stem_name, audio[pos:end].copy(), device_sr)
pos = end
if self._caller_stop_event.is_set():
print("Caller audio stopped early")
if stop_event.is_set():
print(f"{stem_name.title()} audio stopped early")
else:
print(f"Played caller audio: {len(audio)/device_sr:.2f}s")
@@ -497,6 +505,10 @@ class AudioService:
"""Stop any playing caller audio"""
self._caller_stop_event.set()
def stop_devon_audio(self):
"""Stop any playing Devon audio (independent of caller audio)"""
self._devon_stop_event.set()
def _start_live_caller_stream(self):
"""Start persistent output stream with ring buffer jitter absorption"""
if self._live_caller_stream is not None: