Play delayed messages from ElevenLabsTTSService if they still belong to the current context.

This commit is contained in:
Filipi Fuchter
2025-07-24 12:00:14 -03:00
parent 7a69f57e11
commit 662f04879c
2 changed files with 9 additions and 2 deletions

View File

@@ -24,6 +24,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Play delayed messages from `ElevenLabsTTSService` if they still belong to the
current context.
- Dependency compatibility improvements: Relaxed version constraints for core - Dependency compatibility improvements: Relaxed version constraints for core
dependencies to support broader version ranges while maintaining stability: dependencies to support broader version ranges while maintaining stability:

View File

@@ -548,8 +548,12 @@ class ElevenLabsTTSService(AudioContextWordTTSService):
# Check if this message belongs to the current context. # Check if this message belongs to the current context.
# This should never happen, so warn about it. # This should never happen, so warn about it.
if not self.audio_context_available(received_ctx_id): if not self.audio_context_available(received_ctx_id):
logger.warning(f"Ignoring message from unavailable context: {received_ctx_id}") if self._context_id == received_ctx_id:
continue logger.debug(f"Received a delayed message, recreating the context: {self._context_id}")
await self.create_audio_context(self._context_id)
else:
logger.warning(f"Ignoring message from unavailable context: {received_ctx_id}")
continue
if msg.get("audio"): if msg.get("audio"):
await self.stop_ttfb_metrics() await self.stop_ttfb_metrics()