Cantonese ASR
Collection
6 items
•
Updated
•
1
For training,
For evaluation, Common Voice 16.0 yue Test set is used.
alvanlii/distil-whisper-small-cantonese |
alvanlii/whisper-small-cantonese |
|
---|---|---|
CER (lower is better) | 0.097 | 0.089 |
GPU Inference time (sdpa) [s/sample] | 0.027 | 0.055 |
GPU Inference (regular) [s/sample] | 0.027 | 0.308 |
CPU Inference [s/sample] | 1.3 | 2.57 |
Params [M] | 157 | 242 |
Note: inference time is calculated by taking the average inference time for the CV16 yue test set
import librosa
import torch
from transformers import WhisperForConditionalGeneration, WhisperProcessor
y, sr = librosa.load('audio.mp3', sr=16000)
MODEL_NAME = "alvanlii/distil-whisper-small-cantonese"
processor = WhisperProcessor.from_pretrained(MODEL_NAME)
model = WhisperForConditionalGeneration.from_pretrained(MODEL_NAME)
model.config.forced_decoder_ids = None
model.config.suppress_tokens = []
model.config.use_cache = False
processed_in = processor(y, sampling_rate=sr, return_tensors="pt")
gout = model.generate(
input_features=processed_in.input_features,
output_scores=True, return_dict_in_generate=True
)
transcription = processor.batch_decode(gout.sequences, skip_special_tokens=True)[0]
print(transcription)
from transformers import pipeline
MODEL_NAME = "alvanlii/distil-whisper-small-cantonese"
lang = "zh"
pipe = pipeline(
task="automatic-speech-recognition",
model=MODEL_NAME,
chunk_length_s=30,
device=device,
)
pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(language=lang, task="transcribe")
text = pipe(file)["text"]
Base model
openai/whisper-small