From 41d9f683a82da06ad1e3852d7672499c28180479 Mon Sep 17 00:00:00 2001 From: rover0811 Date: Mon, 12 May 2025 13:48:43 +0900 Subject: [PATCH 1/2] Add: support for secure WebSocket (WSS) connections Introduce an optional `use_wss` flag to enable secure WebSocket protocol. Updated socket URL generation to dynamically select between `ws` or `wss` based on the flag value. Ensures greater flexibility when connecting to secure servers. --- whisper_live/client.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/whisper_live/client.py b/whisper_live/client.py index b7c1b35..6a751a0 100644 --- a/whisper_live/client.py +++ b/whisper_live/client.py @@ -30,6 +30,7 @@ class Client: model="small", srt_file_path="output.srt", use_vad=True, + use_wss=False, log_transcription=True, max_clients=4, max_connection_time=600, @@ -72,6 +73,7 @@ class Client: self.server_error = False self.srt_file_path = srt_file_path self.use_vad = use_vad + self.use_wss = use_wss self.last_segment = None self.last_received_segment = None self.log_transcription = log_transcription @@ -88,7 +90,8 @@ class Client: self.audio_bytes = None if host is not None and port is not None: - socket_url = f"ws://{host}:{port}" + socket_protocol = 'wss' if self.use_wss else "ws" + socket_url = f"{socket_protocol}://{host}:{port}" self.client_socket = websocket.WebSocketApp( socket_url, on_open=lambda ws: self.on_open(ws), @@ -721,6 +724,7 @@ class TranscriptionClient(TranscriptionTeeClient): translate=False, model="small", use_vad=True, + use_wss=False, save_output_recording=False, output_recording_filename="./output_recording.wav", output_transcription_path="./output.srt", From d29993048d724fe7bab6970e4e55277b8047d6d2 Mon Sep 17 00:00:00 2001 From: rover0811 Date: Mon, 12 May 2025 16:42:11 +0900 Subject: [PATCH 2/2] Fix: Enable support for WebSocket streaming in client. Added the `use_wss` parameter to allow the client to handle WebSocket-based streaming. This enhances flexibility for real-time transcription scenarios. --- whisper_live/client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/whisper_live/client.py b/whisper_live/client.py index 6a751a0..4429d24 100644 --- a/whisper_live/client.py +++ b/whisper_live/client.py @@ -745,6 +745,7 @@ class TranscriptionClient(TranscriptionTeeClient): model, srt_file_path=output_transcription_path, use_vad=use_vad, + use_wss=use_wss, log_transcription=log_transcription, max_clients=max_clients, max_connection_time=max_connection_time,