Skip to content
Open
Changes from all commits
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
4 changes: 3 additions & 1 deletion yt_whisper/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@ def main():

parser.add_argument("--task", type=str, default="transcribe", choices=[
"transcribe", "translate"], help="whether to perform X->X speech recognition ('transcribe') or X->English translation ('translate')")
parser.add_argument("--device", choices=("cpu", "cuda"), help="device to use for PyTorch inference")

args = parser.parse_args().__dict__
model_name: str = args.pop("model")
output_dir: str = args.pop("output_dir")
device: str = args.pop("device")
os.makedirs(output_dir, exist_ok=True)

if model_name.endswith(".en"):
warnings.warn(
f"{model_name} is an English-only model, forcing English detection.")
args["language"] = "en"

model = whisper.load_model(model_name)
model = whisper.load_model(model_name, device=device)
audios = get_audio(args.pop("video"))

for title, audio_path in audios.items():
Expand Down