Spaces:
Running
on
Zero
Running
on
Zero
File size: 773 Bytes
dd9600d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from jiwer import wer as calculate_wer
from jiwer import cer as calculate_cer
from whisper.normalizers import EnglishTextNormalizer
import whisper
import torch
normalizer = EnglishTextNormalizer()
device = "cuda" if torch.cuda.is_available() else "cpu"
whisper_model = whisper.load_model("large-v3-turbo", device=device)
def asr(wav_path):
result = whisper_model.transcribe(wav_path)
pred = result['text'].strip()
pred = normalizer(pred)
return pred
if __name__ == '__main__':
gt_text="Hey, how are you doing today? I like it."
wav_path="your-audio"
gt_text = normalizer(gt_text.strip())
pred_asr = asr(wav_path)
wer = round(calculate_wer(gt_text, pred_asr), 3)
cer = round(calculate_cer(gt_text, pred_asr), 3)
print(wer, cer) |