Change max_clients max_connection_time from server only

Signed-off-by: makaveli10 <vineet.suryan@collabora.com>
This commit is contained in:
makaveli10
2025-07-21 22:52:24 +05:30
parent 8d785e5681
commit 8d6ddd4f7b
5 changed files with 93 additions and 75 deletions
-14
View File
@@ -32,8 +32,6 @@ class Client:
use_vad=True,
use_wss=False,
log_transcription=True,
max_clients=4,
max_connection_time=600,
send_last_n_segments=10,
no_speech_thresh=0.45,
clip_audio=False,
@@ -56,8 +54,6 @@ class Client:
srt_file_path (str, optional): The file path to save the output SRT file. Default is "output.srt".
use_vad (bool, optional): Whether to enable voice activity detection. Default is True.
log_transcription (bool, optional): Whether to log transcription output to the console. Default is True.
max_clients (int, optional): Maximum number of client connections allowed. Default is 4.
max_connection_time (int, optional): Maximum allowed connection time in seconds. Default is 600.
send_last_n_segments (int, optional): Number of most recent segments to send to the client. Defaults to 10.
no_speech_thresh (float, optional): Segments with no speech probability above this threshold will be discarded. Defaults to 0.45.
clip_audio (bool, optional): Whether to clip audio with no valid segments. Defaults to False.
@@ -79,8 +75,6 @@ class Client:
self.last_segment = None
self.last_received_segment = None
self.log_transcription = log_transcription
self.max_clients = max_clients
self.max_connection_time = max_connection_time
self.send_last_n_segments = send_last_n_segments
self.no_speech_thresh = no_speech_thresh
self.clip_audio = clip_audio
@@ -236,8 +230,6 @@ class Client:
"task": self.task,
"model": self.model,
"use_vad": self.use_vad,
"max_clients": self.max_clients,
"max_connection_time": self.max_connection_time,
"send_last_n_segments": self.send_last_n_segments,
"no_speech_thresh": self.no_speech_thresh,
"clip_audio": self.clip_audio,
@@ -714,8 +706,6 @@ class TranscriptionClient(TranscriptionTeeClient):
output_recording_filename (str, optional): Path to save the output recording WAV file. Default is "./output_recording.wav".
output_transcription_path (str, optional): File path to save the output transcription (SRT file). Default is "./output.srt".
log_transcription (bool, optional): Whether to log transcription output to the console. Default is True.
max_clients (int, optional): Maximum number of client connections allowed. Default is 4.
max_connection_time (int, optional): Maximum allowed connection time in seconds. Default is 600.
mute_audio_playback (bool, optional): If True, mutes audio playback during file playback. Default is False.
send_last_n_segments (int, optional): Number of most recent segments to send to the client. Defaults to 10.
no_speech_thresh (float, optional): Segments with no speech probability above this threshold will be discarded. Defaults to 0.45.
@@ -746,8 +736,6 @@ class TranscriptionClient(TranscriptionTeeClient):
output_recording_filename="./output_recording.wav",
output_transcription_path="./output.srt",
log_transcription=True,
max_clients=4,
max_connection_time=600,
mute_audio_playback=False,
send_last_n_segments=10,
no_speech_thresh=0.45,
@@ -765,8 +753,6 @@ class TranscriptionClient(TranscriptionTeeClient):
use_vad=use_vad,
use_wss=use_wss,
log_transcription=log_transcription,
max_clients=max_clients,
max_connection_time=max_connection_time,
send_last_n_segments=send_last_n_segments,
no_speech_thresh=no_speech_thresh,
clip_audio=clip_audio,
+5 -5
View File
@@ -269,11 +269,6 @@ class TranscriptionServer:
options = websocket.recv()
options = json.loads(options)
if self.client_manager is None:
max_clients = options.get('max_clients', 4)
max_connection_time = options.get('max_connection_time', 600)
self.client_manager = ClientManager(max_clients, max_connection_time)
self.use_vad = options.get('use_vad')
if self.client_manager.is_server_full(websocket, options):
websocket.close()
@@ -372,6 +367,8 @@ class TranscriptionServer:
trt_multilingual=False,
trt_py_session=False,
single_model=False,
max_clients=4,
max_connection_time=600,
cache_path="~/.cache/whisper-live/"):
"""
Run the transcription server.
@@ -381,6 +378,9 @@ class TranscriptionServer:
port (int): The port number to bind the server.
"""
self.cache_path = cache_path
self.client_manager = ClientManager(max_clients, max_connection_time)
if faster_whisper_custom_model_path is not None and not os.path.exists(faster_whisper_custom_model_path):
raise ValueError(f"Custom faster_whisper model '{faster_whisper_custom_model_path}' is not a valid path.")
if whisper_tensorrt_path is not None and not os.path.exists(whisper_tensorrt_path):
raise ValueError(f"TensorRT model '{whisper_tensorrt_path}' is not a valid path.")
if single_model: