Problem with certificate using streaming
I am trying the sample code for the streaming functionality. However, when calling elevenlabs.stream to play a stream produced by elevenlabs.generate I get :
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)
Grateful for any assistance
@eleph1729 how did you solve this? I am facing the same issue
Same issue here. Would appreciate if you posted your solution!
The problem I had was with this bit of code inside tts.py where it connects to a web socket.
with connect(
f"wss://api.elevenlabs.io/v1/text-to-speech/{voice.voice_id}/stream-input?model_id={model.model_id}",
additional_headers=remove_none_from_dict({
"xi-api-key": api_key or os.environ.get("ELEVEN_API_KEY")
})
) as websocket:
I changed that code so as to create and pass an ssl_context as below. I used certifi.where() to find the location of my certificates:
ssl_context = ssl.create_default_context(cafile="/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/certifi/cacert.pem") with connect( f"wss://api.elevenlabs.io/v1/text-to-speech/{voice.voice_id}/stream-input?model_id={model.model_id}", ssl_context=ssl_context, additional_headers=remove_none_from_dict({ "xi-api-key": api_key or os.environ.get("ELEVEN_API_KEY") }) ) as websocket:
I'm not a professional, so no idea if this is a sensible way to do it. ChatGPT helped me. Let me know if there is a more elegant way to do it.