Wav2vec2 Large Xlsr Icelandic
This is an Icelandic automatic speech recognition (ASR) model fine-tuned based on Facebook's wav2vec2-large-xlsr-53 model, trained using the Malromur dataset.
Downloads 51
Release Time : 3/2/2022
Model Overview
This model is specifically designed for Icelandic speech recognition tasks, capable of converting Icelandic speech into text.
Model Features
High Accuracy
Achieves a 9.21% Word Error Rate (WER) on the Malromur test set.
Optimized for Icelandic
Fine-tuned using the Icelandic-specific Malromur dataset.
No Language Model Required
Can be used directly without an additional language model.
Model Capabilities
Icelandic speech recognition
Speech-to-text
Use Cases
Speech Transcription
Icelandic Speech Transcription
Convert Icelandic speech content into text
Achieves an accuracy of 90.79%
🚀 Wav2Vec2-Large-XLSR-53-Icelandic
This project fine-tunes facebook/wav2vec2-large-xlsr-53 in Icelandic using Malromur. Ensure that your speech input is sampled at 16kHz when using this model.
Information Table
Property | Details |
---|---|
Model Type | XLSR Wav2Vec2 Icelandic by Mehrdad Farahani |
Training Data | Malromur is |
License | apache-2.0 |
Widget Examples
🚀 Quick Start
Installation
# requirement packages
!pip install git+https://github.com/huggingface/datasets.git
!pip install git+https://github.com/huggingface/transformers.git
!pip install torchaudio
!pip install librosa
!pip install jiwer
!pip install num2words
# num2word packages
# Original source: https://github.com/savoirfairelinux/num2words
!mkdir -p ./num2words
!wget -O num2words/__init__.py https://huggingface.co/m3hrdadfi/wav2vec2-large-xlsr-icelandic/raw/main/num2words/__init__.py
!wget -O num2words/base.py https://huggingface.co/m3hrdadfi/wav2vec2-large-xlsr-icelandic/raw/main/num2words/base.py
!wget -O num2words/compat.py https://huggingface.co/m3hrdadfi/wav2vec2-large-xlsr-icelandic/raw/main/num2words/compat.py
!wget -O num2words/currency.py https://huggingface.co/m3hrdadfi/wav2vec2-large-xlsr-icelandic/raw/main/num2words/currency.py
!wget -O num2words/lang_EU.py https://huggingface.co/m3hrdadfi/wav2vec2-large-xlsr-icelandic/raw/main/num2words/lang_EU.py
!wget -O num2words/lang_IS.py https://huggingface.co/m3hrdadfi/wav2vec2-large-xlsr-icelandic/raw/main/num2words/lang_IS.py
!wget -O num2words/utils.py https://huggingface.co/m3hrdadfi/wav2vec2-large-xlsr-icelandic/raw/main/num2words/utils.py
# Malromur_test selected based on gender and age
!wget -O malromur_test.csv https://huggingface.co/m3hrdadfi/wav2vec2-large-xlsr-icelandic/raw/main/malromur_test.csv
# Normalizer
!wget -O normalizer.py https://huggingface.co/m3hrdadfi/wav2vec2-large-xlsr-icelandic/raw/main/normalizer.py
💻 Usage Examples
Basic Usage
import librosa
import torch
import torchaudio
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
from datasets import load_dataset
import numpy as np
import re
import string
import IPython.display as ipd
from normalizer import Normalizer
normalizer = Normalizer(lang="is")
def speech_file_to_array_fn(batch):
speech_array, sampling_rate = torchaudio.load(batch["path"])
speech_array = speech_array.squeeze().numpy()
speech_array = librosa.resample(np.asarray(speech_array), sampling_rate, 16_000)
batch["speech"] = speech_array
return batch
def predict(batch):
features = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
input_values = features.input_values.to(device)
attention_mask = features.attention_mask.to(device)
with torch.no_grad():
logits = model(input_values, attention_mask=attention_mask).logits
pred_ids = torch.argmax(logits, dim=-1)
batch["predicted"] = processor.batch_decode(pred_ids)
return batch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
processor = Wav2Vec2Processor.from_pretrained("m3hrdadfi/wav2vec2-large-xlsr-icelandic")
model = Wav2Vec2ForCTC.from_pretrained("m3hrdadfi/wav2vec2-large-xlsr-icelandic").to(device)
dataset = load_dataset("csv", data_files={"test": "./malromur_test.csv"})["test"]
dataset = dataset.map(
normalizer,
fn_kwargs={"do_lastspace_removing": True, "text_key_name": "cleaned_sentence"},
remove_columns=list(set(dataset.column_names) - set(['cleaned_sentence', 'path']))
)
dataset = dataset.map(speech_file_to_array_fn)
result = dataset.map(predict, batched=True, batch_size=8)
max_items = np.random.randint(0, len(result), 20).tolist()
for i in max_items:
reference, predicted = result["cleaned_sentence"][i], result["predicted"][i]
print("reference:", reference)
print("predicted:", predicted)
print('---')
Output
reference: eða eitthvað annað dýr
predicted: eða eitthvað annað dýr
---
reference: oddgerður
predicted: oddgerður
---
reference: eiðný
predicted: eiðný
---
reference: löndum
predicted: löndum
---
reference: tileinkaði bróður sínum markið
predicted: tileinkaði bróður sínum markið
---
reference: þetta er svo mikill hégómi
predicted: þetta er svo mikill hégómi
---
reference: timarit is
predicted: timarit is
---
reference: stefna strax upp aftur
predicted: stefna strax upp aftur
---
reference: brekkuflöt
predicted: brekkuflöt
---
reference: áætlunarferð frestað vegna veðurs
predicted: áætluna ferð frestað vegna veðurs
---
reference: sagði af sér vegna kláms
predicted: sagði af sér vegni kláms
---
reference: grímúlfur
predicted: grímúlgur
---
reference: lýsti sig saklausan
predicted: lýsti sig saklausan
---
reference: belgingur is
predicted: belgingur is
---
reference: sambía
predicted: sambía
---
reference: geirastöðum
predicted: geirastöðum
---
reference: varð tvisvar fyrir eigin bíl
predicted: var tvisvar fyrir eigin bíl
---
reference: reykjavöllum
predicted: reykjavöllum
---
reference: miklir menn eru þeir þremenningar
predicted: miklir menn eru þeir þremenningar
---
reference: handverkoghonnun is
predicted: handverkoghonnun is
---
📚 Documentation
Evaluation
import librosa
import torch
import torchaudio
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
from datasets import load_dataset, load_metric
import numpy as np
import re
import string
from normalizer import Normalizer
normalizer = Normalizer(lang="is")
def speech_file_to_array_fn(batch):
speech_array, sampling_rate = torchaudio.load(batch["path"])
speech_array = speech_array.squeeze().numpy()
speech_array = librosa.resample(np.asarray(speech_array), sampling_rate, 16_000)
batch["speech"] = speech_array
return batch
def predict(batch):
features = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
input_values = features.input_values.to(device)
attention_mask = features.attention_mask.to(device)
with torch.no_grad():
logits = model(input_values, attention_mask=attention_mask).logits
pred_ids = torch.argmax(logits, dim=-1)
batch["predicted"] = processor.batch_decode(pred_ids)
return batch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
processor = Wav2Vec2Processor.from_pretrained("m3hrdadfi/wav2vec2-large-xlsr-icelandic")
model = Wav2Vec2ForCTC.from_pretrained("m3hrdadfi/wav2vec2-large-xlsr-icelandic").to(device)
dataset = load_dataset("csv", data_files={"test": "./malromur_test.csv"})["test"]
dataset = dataset.map(
normalizer,
fn_kwargs={"do_lastspace_removing": True, "text_key_name": "cleaned_sentence"},
remove_columns=list(set(dataset.column_names) - set(['cleaned_sentence', 'path']))
)
dataset = dataset.map(speech_file_to_array_fn)
result = dataset.map(predict, batched=True, batch_size=8)
wer = load_metric("wer")
print("WER: {:.2f}".format(100 * wer.compute(predictions=result["predicted"], references=result["cleaned_sentence"])))
Test Result
- WER: 09.21%
Training & Report
The Common Voice train
, validation
datasets were used for training.
❓ Questions
Post a Github issue on the Wav2Vec repo.
Voice Activity Detection
MIT
Voice activity detection model based on pyannote.audio 2.1, used to identify speech activity segments in audio
Speech Recognition
V
pyannote
7.7M
181
Wav2vec2 Large Xlsr 53 Portuguese
Apache-2.0
This is a fine-tuned XLSR-53 large model for Portuguese speech recognition tasks, trained on the Common Voice 6.1 dataset, supporting Portuguese speech-to-text conversion.
Speech Recognition Other
W
jonatasgrosman
4.9M
32
Whisper Large V3
Apache-2.0
Whisper is an advanced automatic speech recognition (ASR) and speech translation model proposed by OpenAI, trained on over 5 million hours of labeled data, with strong cross-dataset and cross-domain generalization capabilities.
Speech Recognition Supports Multiple Languages
W
openai
4.6M
4,321
Whisper Large V3 Turbo
MIT
Whisper is a state-of-the-art automatic speech recognition (ASR) and speech translation model developed by OpenAI, trained on over 5 million hours of labeled data, demonstrating strong generalization capabilities in zero-shot settings.
Speech Recognition
Transformers Supports Multiple Languages

W
openai
4.0M
2,317
Wav2vec2 Large Xlsr 53 Russian
Apache-2.0
A Russian speech recognition model fine-tuned from facebook/wav2vec2-large-xlsr-53, supporting 16kHz sampled audio input
Speech Recognition Other
W
jonatasgrosman
3.9M
54
Wav2vec2 Large Xlsr 53 Chinese Zh Cn
Apache-2.0
A Chinese speech recognition model fine-tuned based on facebook/wav2vec2-large-xlsr-53, supporting 16kHz sampling rate audio input.
Speech Recognition Chinese
W
jonatasgrosman
3.8M
110
Wav2vec2 Large Xlsr 53 Dutch
Apache-2.0
A Dutch speech recognition model fine-tuned based on facebook/wav2vec2-large-xlsr-53, trained on the Common Voice and CSS10 datasets, supporting 16kHz audio input.
Speech Recognition Other
W
jonatasgrosman
3.0M
12
Wav2vec2 Large Xlsr 53 Japanese
Apache-2.0
Japanese speech recognition model fine-tuned from facebook/wav2vec2-large-xlsr-53, supporting 16kHz sampling rate audio input
Speech Recognition Japanese
W
jonatasgrosman
2.9M
33
Mms 300m 1130 Forced Aligner
A text-to-audio forced alignment tool based on Hugging Face pre-trained models, supporting multiple languages with high memory efficiency
Speech Recognition
Transformers Supports Multiple Languages

M
MahmoudAshraf
2.5M
50
Wav2vec2 Large Xlsr 53 Arabic
Apache-2.0
Arabic speech recognition model fine-tuned from facebook/wav2vec2-large-xlsr-53, trained on Common Voice and Arabic speech corpus
Speech Recognition Arabic
W
jonatasgrosman
2.3M
37
Featured Recommended AI Models