From 7f11a62243852407fe5f401ae58ff18478a37969 Mon Sep 17 00:00:00 2001 From: j Date: Fri, 24 Jan 2025 11:50:49 +0530 Subject: [PATCH] select model --- run_whisper.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/run_whisper.py b/run_whisper.py index e56b988..471347e 100644 --- a/run_whisper.py +++ b/run_whisper.py @@ -6,8 +6,9 @@ import sys import whisper_timestamped as whisper -def transcribe(path, language=None, translate=None): - model = whisper.load_model("large-v3-turbo") +def transcribe(path, language=None, translate=None, model="small"): + #model = whisper.load_model("large-v3-turbo") + model = whisper.load_model(model) audio = whisper.load_audio(path) if translate: task = "translate" @@ -33,10 +34,11 @@ if __name__ == "__main__": usage = "usage: %(prog)s [options] path output" parser = ArgumentParser(usage=usage, prog="run_whisper") parser.add_argument("-l", "--language", dest="language", default=None) - parser.add_argument("-t", "--translate", dest="translate", default=None) + parser.add_argument("-m", "--model", dest="model", default="small") + parser.add_argument("-t", "--translate", dest="translate", action='store_true', default=False) parser.add_argument("path", metavar="path", type=str, help="media input") parser.add_argument("output", metavar="output", type=str, help="json output") opts = parser.parse_args() - result = transcribe(opts.path, opts.language, opts.translate) + result = transcribe(opts.path, opts.language, opts.translate, opts.model) with open(opts.output, "w") as fd: json.dump(result, fd, indent=2, ensure_ascii=False)