Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added --output option #333

Merged
merged 5 commits into from
Jan 22, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Changed output_files variable
  • Loading branch information
Aaryan369 authored Oct 16, 2022
commit fe1b4d26a992e2c86f963a5ede60310ad5dd9526
7 changes: 4 additions & 3 deletions whisper/transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ def cli():
model_dir: str = args.pop("model_dir")
output_dir: str = args.pop("output_dir")
device: str = args.pop("device")
output_files: str = args.pop("output")
os.makedirs(output_dir, exist_ok=True)

if model_name.endswith(".en") and args["language"] not in {"en", "English"}:
Expand Down Expand Up @@ -311,17 +312,17 @@ def cli():
audio_basename = os.path.basename(audio_path)

# save TXT
if args["output"] != "none":
if output_files != "none":
with open(os.path.join(output_dir, audio_basename + ".txt"), "w", encoding="utf-8") as txt:
write_txt(result["segments"], file=txt)

# save VTT
if args["output"] in ["vtt","all"]:
if output_files in ["vtt","all"]:
with open(os.path.join(output_dir, audio_basename + ".vtt"), "w", encoding="utf-8") as vtt:
write_vtt(result["segments"], file=vtt)

# save SRT
if args["output"] in ["srt","all"]:
if output_files in ["srt","all"]:
with open(os.path.join(output_dir, audio_basename + ".srt"), "w", encoding="utf-8") as srt:
write_srt(result["segments"], file=srt)

Expand Down