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
+64 -47
View File
@@ -3,55 +3,72 @@ import sys
from whisper_live.client import TranscriptionClient
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--port', '-p',
type=int,
default=9090,
help="Websocket port to run the server on.")
parser.add_argument('--server', '-s',
type=str,
default='localhost',
help='hostname or ip address of server')
parser.add_argument('--files', '-f',
type=str,
nargs='+',
help='hostname or ip address of server')
parser.add_argument('--output_file', '-o',
type=str,
default='./output_recording.wav',
help='hostname or ip address of server')
args = parser.parse_args()
parser = argparse.ArgumentParser()
parser.add_argument('--port', '-p',
type=int,
default=9090,
help="Websocket port to run the server on.")
parser.add_argument('--server', '-s',
type=str,
default='localhost',
help='hostname or ip address of server')
parser.add_argument('--files', '-f',
type=str,
nargs='+',
help='Files to transcribe, separated by spaces. '
'If not provided, will use microphone input.')
parser.add_argument('--output_file', '-o',
type=str,
default='./output_recording.wav',
help='output recording filename, only used for microphone input.')
parser.add_argument('--model', '-m',
type=str,
default='small',
help='Model to use for transcription, e.g., "tiny, small.en, large-v3".')
parser.add_argument('--lang', '-l',
type=str,
default='en',
help='Language code for transcription, e.g., "en" for English.')
parser.add_argument('--translate', '-t',
action='store_true',
help='Enable translation of the transcription output.')
parser.add_argument('--mute_audio_playback', '-a',
action='store_true',
help='Mute audio playback during transcription.')
parser.add_argument('--save_output_recording', '-r',
action='store_true',
help='Save the output recording, only used for microphone input.')
args = parser.parse_args()
# Validate audio files
valid_files = []
for file_path in args.files:
path = Path(file_path)
if path.exists() and path.is_file():
valid_files.append(str(path))
else:
print(f"Warning: File not found: {file_path}")
# Validate audio files
valid_files = []
for file_path in args.files:
path = Path(file_path)
if path.exists() and path.is_file():
valid_files.append(str(path))
else:
print(f"Warning: File not found: {file_path}")
if not valid_files:
print("Error: No valid audio files found!")
sys.exit(1)
if not valid_files:
print("Error: No valid audio files found!")
sys.exit(1)
print(f"Found {len(valid_files)} audio file(s) to stream:")
for file_path in valid_files:
print(f" - {file_path}")
print(f"Found {len(valid_files)} audio file(s) to stream:")
for file_path in valid_files:
print(f" - {file_path}")
for f in valid_files:
client = TranscriptionClient(
args.server,
args.port,
lang="en",
translate=False,
model="large-v3", # also support hf_model => `Systran/faster-whisper-small`
use_vad=False,
save_output_recording=False, # Only used for microphone input, False by Default
output_recording_filename=args.output_file, # Only used for microphone input
max_clients=4,
max_connection_time=600,
mute_audio_playback=True, # Only used for file input, False by Default
)
client(f)
for f in valid_files:
client = TranscriptionClient(
args.server,
args.port,
lang=args.lang,
translate=args.translate,
model=args.model, # also support hf_model => `Systran/faster-whisper-small`
use_vad=True,
save_output_recording=args.save_output_recording, # Only used for microphone input, False by Default
output_recording_filename=args.output_file, # Only used for microphone input
mute_audio_playback=args.mute_audio_playback, # Only used for file input, False by Default
)
client(f)