got this python error when using elevenlabs tts `...
# ask-ai
b
got this python error when using elevenlabs tts
Copy code
raise WSServerHandshakeError(
aiohttp.client_exceptions.WSServerHandshakeError: 403, message='Invalid response status', url='wss://api.elevenlabs.io/v1/text-to-speech/***********/multi-stream-input?model_id=eleven_v3&output_format=mp3_22050_32&enable_ssml_parsing=false&inactivity_timeout=180&apply_text_normalization=auto&sync_alignment=true&auto_mode=true'
t
Thanks for reaching out, Jura. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Can you share a bit more about your setup? For example, are you using an API key for authentication? If yes, have you had a chance to check if the key is valid and has the right permissions? Also, if you're comfortable, could you share the code snippet where you’re connecting to the ElevenLabs TTS API? That way, I can better understand what might be going on and help you more effectively.
b
Copy code
return elevenlabs.TTS(
            api_key=os.getenv("ELEVENLABS_API_KEY"),
            voice_id=params.get("voice_id", NOT_GIVEN),
            model=config.model or NOT_GIVEN,
            # voice_settings=NOT_GIVEN,
        )
1. usign api key and api key permission is fine
t
I'm sorry you're encountering the error
aiohttp.client_exceptions.WSServerHandshakeError: 403
. This usually happens because of a few common reasons, so let’s walk through them together: • API Key Configuration: Please make sure your API key is correctly included in the headers with the exact key
xi-api-key
. Even if your key is valid, it’s important that it’s properly set in your environment or explicitly passed in your code. • Header Formatting: It’s a good idea to double-check that the header name and formatting are spot on. Sometimes even a small difference can cause the server to reject the request. • Endpoint URL: Take a moment to verify that the WebSocket endpoint URL is correctly formed, including the voice ID and model parameters. • Account Restrictions: Also, please confirm that your ElevenLabs account supports WebSocket streaming, as some features might be limited depending on your account tier. Here’s what I recommend to get this sorted: 1. Make sure the
ELEVEN_API_KEY
is properly set in your environment or explicitly passed in your code. 2. Verify that the
xi-api-key
header is included and formatted correctly. 3. Check that the voice ID and model parameters are accurate. 4. Confirm with ElevenLabs that your account tier supports WebSocket streaming. If you’ve gone through these steps and are still facing the issue, please don’t hesitate to reach out. I’m here to help you troubleshoot further and get things working smoothly! Sources: agents/src/inference/tts.ts | livekit-plugins/livekit-plugins-resemble/README.md