From a47cd332dbcfc137438db169d5edb5429d1875b1 Mon Sep 17 00:00:00 2001 From: McCloudS <64094529+McCloudS@users.noreply.github.com> Date: Sat, 28 Oct 2023 23:15:22 -0600 Subject: [PATCH] Update subgen.py More housekeeping --- subgen/subgen.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/subgen/subgen.py b/subgen/subgen.py index fa4a171..3282915 100644 --- a/subgen/subgen.py +++ b/subgen/subgen.py @@ -71,9 +71,9 @@ if transcribe_device == "gpu": app = FastAPI() model = None files_to_transcribe = [] -subextension = f".subgen.{whisper_model}.{namesublang}.srt" -print("Transcriptions are limited to running " + str(concurrent_transcriptions) + " at a time") -print("Running " + str(whisper_threads) + " threads per transcription") +subextension = f".subgen.{whisper_model.split('.')[0]}.{namesublang}.srt" +print(f"Transcriptions are limited to running {str(concurrent_transcriptions)} at a time") +print(f"Running {str(whisper_threads)} threads per transcription") if debug: logging.basicConfig(stream=sys.stderr, level=logging.NOTSET) @@ -219,7 +219,10 @@ def gen_subtitles(file_path: str, transcribe_or_translate_str: str, front=True) finally: if len(files_to_transcribe) == 0: logging.debug("Queue is empty, clearing/releasing VRAM") - del model + try: + del model + except Exception as e: + None gc.collect() def has_subtitle_language(video_file, target_language): @@ -345,4 +348,4 @@ if transcribe_folders: print("Starting webhook!") if __name__ == "__main__": import uvicorn - uvicorn.run("subgen:app", host="0.0.0.0", port=int(webhookport), reload=debug) + uvicorn.run("subgen:app", host="0.0.0.0", port=int(webhookport), reload=debug, use_colors=True)