From 0355ed4aa18e4806ca4473f0bfbfa0a9d6f18942 Mon Sep 17 00:00:00 2001 From: Angelo Giacco Date: Sat, 10 May 2025 16:34:01 +0100 Subject: [PATCH] move api key to ws header --- src/pipecat/services/elevenlabs/tts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pipecat/services/elevenlabs/tts.py b/src/pipecat/services/elevenlabs/tts.py index 1b78db904..8be213982 100644 --- a/src/pipecat/services/elevenlabs/tts.py +++ b/src/pipecat/services/elevenlabs/tts.py @@ -334,7 +334,7 @@ class ElevenLabsTTSService(AudioContextWordTTSService): ) # Set max websocket message size to 16MB for large audio responses - self._websocket = await websockets.connect(url, max_size=16 * 1024 * 1024) + self._websocket = await websockets.connect(url, max_size=16 * 1024 * 1024, extra_headers={"xi-api-key": self._api_key}) except Exception as e: logger.error(f"{self} initialization error: {e}") @@ -425,7 +425,7 @@ class ElevenLabsTTSService(AudioContextWordTTSService): if self._websocket: if not self._context_id: # First message for a new context - need a space to initialize - msg = {"text": " ", "context_id": str(uuid.uuid4()), "xi-api-key": self._api_key} + msg = {"text": " ", "context_id": str(uuid.uuid4())} # Add voice settings only in first message for a context if self._voice_settings: