Skip to content

Commit

Permalink
Merge pull request #54 from linto-ai/bugfix/languages
Browse files Browse the repository at this point in the history
Fix availability of yue language / fix error message when the language is not found
  • Loading branch information
Jeronymous authored Dec 11, 2024
2 parents ca1a839 + 2943562 commit 3118fd7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions whisper/stt/processing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,20 @@ def get_language(language = None):
language_fields = language.split("-")
if len(language_fields) == 2:
language = language_fields[0]
language = language.lower()
# "*" means "all languages"
if language == "*":
language = None
# Convert French -> fr
if isinstance(language, str) and language not in LANGUAGES:
language = {v: k for k, v in LANGUAGES.items()}.get(language)
candidate_language = {v: k for k, v in LANGUAGES.items()}.get(language.lower())
# Raise an exception for unknown languages
if language not in LANGUAGES:
if candidate_language not in LANGUAGES:
available_languages = [f"{k}({v})" for k, v in LANGUAGES.items()]
available_languages.append("*")
raise ValueError(
f"Language '{language}' is not available. Available languages are: {available_languages}"
)
language = candidate_language
return language


Expand Down Expand Up @@ -222,4 +222,5 @@ def flatten(l):
"ba": "bashkir",
"jw": "javanese",
"su": "sundanese",
"yue": "cantonese",
}

0 comments on commit 3118fd7

Please sign in to comment.