Downloads · 30 days
5
1% of all-time downloads
swayam01/hindi-clsril-100
hindi-clsril-100 is a automatic speech recognition model from swayam01. Use it when you need speech turned into text. It is set up for transformers. The card lists the license as cc.
Fine-tuned Harveenchadha/wav2vec2-pretrained-clsril-23-10k on Hindi using the Common Voice, included openSLR Hindi dataset. When using this model, make sure that your speech input is sampled at 16kHz.
Downloads · 30 days
5
1% of all-time downloads
All-time downloads
627
Public
Repo size
756 MB
Likes
1
Public
Click a slice to open those files.
.bin378 MB · 98%
From the Hugging Face model README
Fine-tuned Harveenchadha/wav2vec2-pretrained-clsril-23-10k on Hindi using the Common Voice, included openSLR Hindi dataset. When using this model, make sure that your speech input is sampled at 16kHz.
The model can be used directly (with or without a language model) as follows:
#!pip install datasets==1.4.1
#!pip install transformers==4.4.0
#!pip install torchaudio
#!pip install jiwer
import torch
import torchaudio
from datasets import load_dataset
from transformers import Wav2Vec2ForCTC, Wav2Vec2ProcessorWithLM
processor_with_lm = Wav2Vec2ProcessorWithLM.from_pretrained("swayam01/hindi-clsril-100")
model = Wav2Vec2ForCTC.from_pretrained("swayam01/hindi-clsril-100")
test_dataset = load_dataset("common_voice", "hi", split="test")
wer = load_metric("wer")
chars_to_ignore_regex = '[\,\?\.\!\-\;\:\"\“\%\�\।\']'
resampler = torchaudio.transforms.Resample(48_000, 16_000)
# We need to read the audio files as arrays
def speech_file_to_array_fn(batch):
batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
speech_array, sampling_rate = torchaudio.load(batch["path"])
batch["speech"] = resampler(speech_array).squeeze().numpy()
return batch
test_dataset = test_dataset.map(speech_file_to_array_fn)
def evaluate(batch):
inputs = processor_with_lm(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
with torch.no_grad():
logits = model(inputs.input_values.to("cuda"), attention_mask=inputs.attention_mask.to("cuda")).logits
batch["pred_strings"] = transcription = processor_with_lm.batch_decode(logits.numpy()).text
return batch
result = test_dataset.map(evaluate, batched=True, batch_size=8)
print("WER: {:2f}".format(100 * wer.compute(predictions=result["pred_strings"], references=result["sentence"])))
Test Result: 24.17 %
The Common Voice hi train, validation were used for training, as well as openSLR hi train, validation and test datasets.
The script used for training can be found here colab