Skip to content

Commit bc8b401

Browse files
committed
feat: add optional headers support to WebSocket connection
Introduce an optional `ws_headers` parameter to the `connect` method in `VoiceAgentClient`. This allows users to pass custom headers when establishing the WebSocket connection to the Speechmatics API.
1 parent 35de80e commit bc8b401

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

sdk/voice/speechmatics/voice/_client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,15 @@ def _prepare_config(
472472
# LIFECYCLE METHODS
473473
# ============================================================================
474474

475-
async def connect(self) -> None:
475+
async def connect(self, ws_headers: Optional[dict] = None) -> None:
476476
"""Connect to the Speechmatics API.
477477
478478
Establishes WebSocket connection and starts the transcription session.
479479
This must be called before sending audio.
480480
481+
Args:
482+
ws_headers: Optional headers to pass to the WebSocket connection.
483+
481484
Raises:
482485
Exception: If connection fails.
483486
@@ -521,6 +524,7 @@ async def connect(self) -> None:
521524
await self.start_session(
522525
transcription_config=self._transcription_config,
523526
audio_format=self._audio_format,
527+
ws_headers=ws_headers,
524528
)
525529
self._is_connected = True
526530
self._start_metrics_task()

0 commit comments

Comments
 (0)