diff --git a/CHANGELOG.md b/CHANGELOG.md index b05ee5708..eeb3dde3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Play delayed messages from `ElevenLabsTTSService` if they still belong to the + current context. + - Dependency compatibility improvements: Relaxed version constraints for core dependencies to support broader version ranges while maintaining stability: diff --git a/src/pipecat/services/elevenlabs/tts.py b/src/pipecat/services/elevenlabs/tts.py index c921c3f4b..3b4503e99 100644 --- a/src/pipecat/services/elevenlabs/tts.py +++ b/src/pipecat/services/elevenlabs/tts.py @@ -548,8 +548,12 @@ class ElevenLabsTTSService(AudioContextWordTTSService): # Check if this message belongs to the current context. # This should never happen, so warn about it. if not self.audio_context_available(received_ctx_id): - logger.warning(f"Ignoring message from unavailable context: {received_ctx_id}") - continue + if self._context_id == received_ctx_id: + 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"): await self.stop_ttfb_metrics()