Skip to content

Commit

Permalink
Merge pull request #517 from jkukul/support-language-names-as-parameters
Browse files Browse the repository at this point in the history
Support language names in `--language` parameter.
  • Loading branch information
m-bain authored Oct 25, 2023
2 parents e9a6385 + 1001a05 commit c6fe379
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion whisperx/transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,15 @@ def cli():
max_speakers: int = args.pop("max_speakers")
print_progress: bool = args.pop("print_progress")

if args["language"] is not None:
args["language"] = args["language"].lower()
if args["language"] not in LANGUAGES:
if args["language"] in TO_LANGUAGE_CODE:
args["language"] = TO_LANGUAGE_CODE[args["language"]]
else:
raise ValueError(f"Unsupported language: {args['language']}")

if model_name.endswith(".en") and args["language"] not in {"en", "English"}:
if model_name.endswith(".en") and args["language"] != "en":
if args["language"] is not None:
warnings.warn(
f"{model_name} is an English-only model but receipted '{args['language']}'; using English instead."
Expand Down

0 comments on commit c6fe379

Please sign in to comment.