m-bain / whisperX

WhisperX: Automatic Speech Recognition with Word-level Timestamps (& Diarization)
BSD 2-Clause "Simplified" License
12.69k stars 1.35k forks source link

ValueError: English is not a valid language code (WhisperX 3.1.1) #251

Closed oep42 closed 1 year ago

oep42 commented 1 year ago

Surprisingly, WhisperX 3.1.1 doesn't recognize "English" as language code. (WhisperX 3.1.1 does recognize "en" as language code.)

PS C:\Windows\system32> whisperx --language=English --model=medium --output_dir=D:\Folder --output_format=srt "D:\Folder\TEST.mkv" --compute_type=int8
(...)
Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python310\Scripts\whisperx.exe\__main__.py", line 7, in <module>
  File "C:\Program Files\Python310\lib\site-packages\whisperx\transcribe.py", line 147, in cli
    model = load_model(model_name, device=device, compute_type=compute_type, language=args['language'], asr_options=asr_
options, vad_options={"vad_onset": vad_onset, "vad_offset": vad_offset}, task=task)
  File "C:\Program Files\Python310\lib\site-packages\whisperx\asr.py", line 34, in load_model
    tokenizer = faster_whisper.tokenizer.Tokenizer(model.hf_tokenizer, model.model.is_multilingual, task=task, language=
language)
  File "C:\Program Files\Python310\lib\site-packages\faster_whisper\tokenizer.py", line 29, in __init__
    raise ValueError("%s is not a valid language code" % language)
ValueError: English is not a valid language code
DigilConfianz commented 1 year ago

--language=en for english language see full language codes here https://github.com/openai/whisper/blob/248b6cb124225dd263bb9bd32d060b6517e067f8/whisper/tokenizer.py#L10

oep42 commented 1 year ago

@DigilConfianz If only "en" is allowed, but not "English", then the current Help info of WhisperX should be updated.

whisperx --help
usage: whisperx [-h] [--model MODEL] [--model_dir MODEL_DIR] [--device DEVICE] [--batch_size BATCH_SIZE]
                [--compute_type {float16,float32,int8}] [--output_dir OUTPUT_DIR]
                [--output_format {all,srt,vtt,txt,tsv,json}] [--verbose VERBOSE] [--task {transcribe,translate}]
                [--language {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,Afrikaans,Albanian,Amharic,Arabic
,Armenian,Assamese,Azerbaijani,Bashkir,Basque,Belarusian,Bengali,Bosnian,Breton,Bulgarian,Burmese,Castilian,Catalan,Chin
ese,Croatian,Czech,Danish,Dutch,English,...

In addition, if WhisperX would not support full language names, then WhisperX would be different from what is common among several Whisper variants — which doesn't seem like a good idea.