Here I will describe my walktrough of HF's audio course unit 5 ASR hands on.
1. We have to fine-tune an automatic speech recognition ASR model ”openai/whisper-tiny” 39М on dataset ”PolyAI/minds14” to metric WER =< 0.37
2. I have to train on 450 examples from dataset. To split dataset on certain value of examples:
minds_14_train = load_dataset("PolyAI/minds14", "en-US", split="train[:450]")
minds_14_test = load_dataset("PolyAI/minds14", "en-US", split="train[450:]")
3. There is something wrong with this ”PolyAI/minds14” dataset. Not whole audios are transcribed. First example transcribed on 50%.
4. While mapping dataset to processor got a TypeError: list indices must be integers or slices, not str
minds_14_train = minds_14_train.map( prepare_dataset )
4.1. Change your prepare_dataset function like: // It was wrong
def prepare_dataset(example):
audio_arrays = [x["array"] for x in example["audio"]]
example = processor(
audio_arrays,
sampling_rate=feature_extractor.sampling_rate,
text=example["transcription"],
)
return example
4.2. I have no idea why it suddenly strated to work. Reload everething. Maybe add >>> from datasets import load_dataset, DatasetDict. And delete batched=True:
minds_14_train = minds_14_train.map(
prepare_dataset3,
#remove_columns=minds_14_train.column_names,
#batched = True,
#batch_size=100,
num_proc=1,
)
5. When I started Trainer got RuntimeError: Given groups=1, weight of size [384, 80, 3], expected input[1, 4, 3000] to have 80 channels, but got 4 channels instead
5.1. Something wrong with prepare_dataset function
1. First training 0.298 on 5 epoch.
2. F16=False // 0.293
3. Decrease batch to 2 // 0.294
4. Lr_scheduler to linear from constant // 0.292
5. Trainer.tokenizer to Trainer.processing_class // I think tokenizer shows best wer.
1. While starting gradio got OSError: Can't load tokenizer for 'GatinhoEducado/whisper-tiny-finetuned-minds14'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'GatinhoEducado/whisper-tiny-finetuned-minds14' is the correct path to a directory containing all relevant files for a WhisperTokenizerFast tokenizer.
1.1. Use original tokenizer:
tokenizer = WhisperTokenizer.from_pretrained("openai/whisper-tiny", language="Portuguese", task="translate")
asr_pipe = pipeline(
tokenizer = tokenizer,
) // HELPED
2. TypeError: Audio.__init__() got an unexpected keyword argument 'source'. Device set to use cpu // It probably bag of gradio version. Try gradio==3.50.2 HELPED