mirror of
https://github.com/karl0ss/bazarr-ai-sub-generator.git
synced 2025-04-26 06:49:22 +01:00
add custom language support
This commit is contained in:
parent
b862a64ffa
commit
6462cd4d56
@ -25,19 +25,26 @@ 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("--language", type=str, default="auto", choices=["auto","af","am","ar","as","az","ba","be","bg","bn","bo","br","bs","ca","cs","cy","da","de","el","en","es","et","eu","fa","fi","fo","fr","gl","gu","ha","haw","he","hi","hr","ht","hu","hy","id","is","it","ja","jw","ka","kk","km","kn","ko","la","lb","ln","lo","lt","lv","mg","mi","mk","ml","mn","mr","ms","mt","my","ne","nl","nn","no","oc","pa","pl","ps","pt","ro","ru","sa","sd","si","sk","sl","sn","so","sq","sr","su","sv","sw","ta","te","tg","th","tk","tl","tr","tt","uk","ur","uz","vi","yi","yo","zh"],
|
||||
help="What is the origin language of the video? If unset, it is detected automatically.")
|
||||
|
||||
args = parser.parse_args().__dict__
|
||||
model_name: str = args.pop("model")
|
||||
output_dir: str = args.pop("output_dir")
|
||||
output_srt: bool = args.pop("output_srt")
|
||||
srt_only: bool = args.pop("srt_only")
|
||||
language: str = args.pop("language")
|
||||
|
||||
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"
|
||||
|
||||
# if translate task used and language argument is set, then use it
|
||||
elif language != "auto":
|
||||
args["language"] = language
|
||||
|
||||
model = whisper.load_model(model_name)
|
||||
audios = get_audio(args.pop("video"))
|
||||
subtitles = get_subtitles(
|
||||
|
Loading…
x
Reference in New Issue
Block a user