Skip to content

Commit ec0c1b3

Browse files
Removes the hardcoded websocket api path. (elevenlabs#427)
Removes the hardcoded websocket api path.
1 parent 85f1658 commit ec0c1b3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/elevenlabs/realtime_tts.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from websockets.sync.client import connect
1010

1111
from .core.api_error import ApiError
12+
from .core.client_wrapper import SyncClientWrapper
1213
from .core.jsonable_encoder import jsonable_encoder
1314
from .core.remove_none_from_dict import remove_none_from_dict
1415
from .core.request_options import RequestOptions
@@ -39,6 +40,9 @@ def text_chunker(chunks: typing.Iterator[str]) -> typing.Iterator[str]:
3940

4041

4142
class RealtimeTextToSpeechClient(TextToSpeechClient):
43+
def __init__(self, *, client_wrapper: SyncClientWrapper):
44+
super().__init__(client_wrapper=client_wrapper)
45+
self._ws_base_url = urllib.parse.urlparse(self._client_wrapper.get_base_url())._replace(scheme="wss").geturl()
4246

4347
def convert_realtime(
4448
self,
@@ -88,7 +92,7 @@ def get_text() -> typing.Iterator[str]:
8892
"""
8993
with connect(
9094
urllib.parse.urljoin(
91-
"wss://api.elevenlabs.io/",
95+
self._ws_base_url,
9296
f"v1/text-to-speech/{jsonable_encoder(voice_id)}/stream-input?model_id={model_id}&output_format={output_format}"
9397
),
9498
additional_headers=jsonable_encoder(

0 commit comments

Comments
 (0)