This is a fine-tuned version of the
openai/whisper-small pre-trained model for ASR in galician.
1import torch
2from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq
3
4filename = "demo.wav" #change this line to the name of your audio file
5sample_rate = 16_000
6processor = AutoProcessor.from_pretrained('ITG/whisper-small-gl')
7model = AutoModelForSpeechSeq2Seq.from_pretrained('ITG/whisper-small-gl')
8device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
9model.to(device)
10
11with torch.no_grad():
12 speech_array, _ = librosa.load(filename, sr=sample_rate)
13 inputs = processor(speech_array, sampling_rate=sample_rate, return_tensors="pt").to(device)
14 input_features = inputs.input_features
15 generated_ids = model.generate(inputs=input_features, max_length=225)
16 decode_output = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
17print(f"ASR Galician whisper-small output: {decode_output}")
If you're interested in fine-tuning your own whisper model, we suggest starting with the
openai/whisper-small model. Additionally, you may find the Transformers
step-by-step guide for
fine-tuning whisper on multilingual ASR datasets to be a valuable resource. This guide served as a helpful reference during the training
process of this Galician whisper-small model!