77"""
88
99import logging
10+ import os
1011
1112from whisper_live .server import TranscriptionServer
1213
@@ -78,11 +79,37 @@ def run(self):
7879 self .plugin_registry .apply if len (self .plugin_registry ) > 0 else None
7980 )
8081
82+ # WhisperLive's server.run() has no kwargs for these server-wide
83+ # defaults, but its per-client code already reads them via the
84+ # options dict. Wrap initialize_client so Aavaaz's flags act as
85+ # defaults that any client can override via its WS handshake.
86+ original_init_client = server .initialize_client
87+ is_custom_model = self .model and (
88+ "/" in self .model or os .path .exists (self .model )
89+ )
90+ server_defaults = {
91+ "model" : self .model ,
92+ "word_timestamps" : self .word_timestamps ,
93+ "hotwords" : self .hotwords ,
94+ "enable_diarization" : self .enable_diarization ,
95+ "max_speakers" : self .max_speakers ,
96+ }
97+
98+ def initialize_client_with_defaults (websocket , options , * args , ** kwargs ):
99+ for key , value in server_defaults .items ():
100+ options .setdefault (key , value )
101+ return original_init_client (websocket , options , * args , ** kwargs )
102+
103+ server .initialize_client = initialize_client_with_defaults
104+
81105 server .run (
82106 host = self .host ,
83107 port = self .port ,
84108 backend = self .backend ,
85- faster_whisper_custom_model_path = self .model ,
109+ # Only pass as "custom path" when the model name actually looks
110+ # like one (HF org/repo or local path). Canonical short names
111+ # like "large-v3" flow through the per-client options dict.
112+ faster_whisper_custom_model_path = self .model if is_custom_model else None ,
86113 enable_rest = self .enable_rest_api ,
87114 rest_port = self .rest_port ,
88115 segment_post_processor = post_processor ,
@@ -92,8 +119,4 @@ def run(self):
92119 metrics_port = self .metrics_port ,
93120 api_key = self .api_key ,
94121 rate_limit_rpm = self .rate_limit_rpm ,
95- word_timestamps = self .word_timestamps ,
96- hotwords = self .hotwords ,
97- enable_diarization = self .enable_diarization ,
98- max_speakers = self .max_speakers ,
99122 )
0 commit comments