Skip to content

Commit

Permalink
Update subgen.py
Browse files Browse the repository at this point in the history
  • Loading branch information
McCloudS authored Feb 8, 2024
1 parent 9395a65 commit 269a54c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions subgen/subgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def convert_to_bool(in_bool):
model_location = os.getenv('MODEL_PATH', '.')
transcribe_folders = os.getenv('TRANSCRIBE_FOLDERS', '')
transcribe_or_translate = os.getenv('TRANSCRIBE_OR_TRANSLATE', 'translate')
force_detected_language_to = os.getenv('FORCE_DETECTED_LANGUAGE_TO', '')
compute_type = os.getenv('COMPUTE_TYPE', 'auto')
if transcribe_device == "gpu":
transcribe_device = "cuda"
Expand Down Expand Up @@ -285,8 +286,11 @@ def gen_subtitles(file_path: str, transcribe_or_translate_str: str, front=True)
print(f"Transcribing file: {os.path.basename(file_path)}")
start_time = time.time()
start_model()

result = model.transcribe_stable(file_path, task=transcribe_or_translate_str)

if(force_detected_language_to):
result = model.transcribe_stable(file_path, language=force_detected_language_to, task=transcribe_or_translate_str)
else:
result = model.transcribe_stable(file_path, task=transcribe_or_translate_str)
result.to_srt_vtt(get_file_name_without_extension(file_path) + subextension, word_level=word_level_highlight)
elapsed_time = time.time() - start_time
minutes, seconds = divmod(int(elapsed_time), 60)
Expand Down

0 comments on commit 269a54c

Please sign in to comment.