From 759e8d47a8c56ee4a8c5ece1aaf6e60e60df8dd4 Mon Sep 17 00:00:00 2001 From: EliEron Date: Fri, 23 Sep 2022 04:38:37 +0200 Subject: [PATCH] Fix output_dir argument when audio file is a path (#45) --- whisper/transcribe.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/whisper/transcribe.py b/whisper/transcribe.py index 37d34d6..a795f73 100644 --- a/whisper/transcribe.py +++ b/whisper/transcribe.py @@ -286,12 +286,14 @@ def cli(): **args, ) + audio_basename = os.path.basename(audio_path) + # save TXT - with open(os.path.join(output_dir, audio_path + ".txt"), "w") as txt: + with open(os.path.join(output_dir, audio_basename + ".txt"), "w") as txt: print(result["text"], file=txt) # save VTT - with open(os.path.join(output_dir, audio_path + ".vtt"), "w") as vtt: + with open(os.path.join(output_dir, audio_basename + ".vtt"), "w") as vtt: write_vtt(result["segments"], file=vtt)