Skip to content

Commit 759e8d4

Browse files
authored
Fix output_dir argument when audio file is a path (openai#45)
1 parent c0607e8 commit 759e8d4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

whisper/transcribe.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,14 @@ def cli():
286286
**args,
287287
)
288288

289+
audio_basename = os.path.basename(audio_path)
290+
289291
# save TXT
290-
with open(os.path.join(output_dir, audio_path + ".txt"), "w") as txt:
292+
with open(os.path.join(output_dir, audio_basename + ".txt"), "w") as txt:
291293
print(result["text"], file=txt)
292294

293295
# save VTT
294-
with open(os.path.join(output_dir, audio_path + ".vtt"), "w") as vtt:
296+
with open(os.path.join(output_dir, audio_basename + ".vtt"), "w") as vtt:
295297
write_vtt(result["segments"], file=vtt)
296298

297299

0 commit comments

Comments
 (0)