fix: add interruption reset for partial word states

This commit is contained in:
Pyae Sone Myo
2025-10-14 23:04:09 +06:30
parent 21d8d148b8
commit 3b751322d3

View File

@@ -577,6 +577,8 @@ class ElevenLabsTTSService(AudioContextWordTTSService):
logger.error(f"Error closing context on interruption: {e}") logger.error(f"Error closing context on interruption: {e}")
self._context_id = None self._context_id = None
self._started = False self._started = False
self._partial_word = ""
self._partial_word_start_time = 0.0
async def _receive_messages(self): async def _receive_messages(self):
"""Handle incoming WebSocket messages from ElevenLabs.""" """Handle incoming WebSocket messages from ElevenLabs."""
@@ -616,11 +618,13 @@ class ElevenLabsTTSService(AudioContextWordTTSService):
if msg.get("alignment"): if msg.get("alignment"):
alignment = msg["alignment"] alignment = msg["alignment"]
word_times, self._partial_word, self._partial_word_start_time = calculate_word_times( word_times, self._partial_word, self._partial_word_start_time = (
alignment, calculate_word_times(
self._cumulative_time, alignment,
self._partial_word, self._cumulative_time,
self._partial_word_start_time, self._partial_word,
self._partial_word_start_time,
)
) )
if word_times: if word_times: