
# wav2vec2-large-slavic-parlaspeech-hr

This model for Croatian ASR is based on the [facebook/wav2vec2-large-slavic-voxpopuli-v2 model](https://huggingface.co/facebook/wav2vec2-large-slavic-voxpopuli-v2) and was fine-tuned with 300 hours of recordings and transcripts from the ASR Croatian parliament dataset [ParlaSpeech-HR v1.0](http://hdl.handle.net/11356/1494).

If you use this model, please cite the following paper:

Nikola Ljubešić, Danijel Koržinek, Peter Rupnik, Ivo-Pavao Jazbec. ParlaSpeech-HR -- a freely available ASR dataset for Croatian bootstrapped from the ParlaMint corpus. http://www.lrec-conf.org/proceedings/lrec2022/workshops/ParlaCLARINIII/pdf/2022.parlaclariniii-1.16.pdf

## Metrics

Evaluation is performed on the dev and test portions of the [ParlaSpeech-HR v1.0](http://hdl.handle.net/11356/1494) dataset.

|split|CER|WER|
|---|---|---|
|dev|0.0311|0.0921|
|test|0.0222|0.0679|

There are multiple models available, and in terms of CER and WER, the best-performing model is [wav2vec2-large-slavic-parlaspeech-hr-lm](https://huggingface.co/classla/wav2vec2-large-slavic-parlaspeech-hr-lm).

## Usage in `transformers`

```python
from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
import soundfile as sf
import torch
import os
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
# load model and tokenizer
processor = Wav2Vec2Processor.from_pretrained(
    "classla/wav2vec2-large-slavic-parlaspeech-hr")
model = Wav2Vec2ForCTC.from_pretrained("classla/wav2vec2-large-slavic-parlaspeech-hr")
# download the example wav files:
os.system("wget https://huggingface.co/classla/wav2vec2-large-slavic-parlaspeech-hr/raw/main/00020570a.flac.wav")
# read the wav file 
speech, sample_rate = sf.read("00020570a.flac.wav")
input_values = processor(speech, sampling_rate=sample_rate, return_tensors="pt").input_values.to(device)
# remove the raw wav file
os.system("rm 00020570a.flac.wav")
# retrieve logits
logits = model.to(device)(input_values).logits
# take argmax and decode
predicted_ids = torch.argmax(logits, dim=-1)
transcription = processor.decode(predicted_ids[0]).lower()
# transcription: 'veliki broj poslovnih subjekata posluje sa minusom velik dio'
```



## Training hyperparameters

In fine-tuning, the following arguments were used:

| arg                           | value |
|-------------------------------|-------|
| `per_device_train_batch_size` | 16    |
| `gradient_accumulation_steps` | 4     |
| `num_train_epochs`            | 8     |
| `learning_rate`               | 3e-4  |
| `warmup_steps`                | 500   |
{"language": "hr", "tags": ["audio", "automatic-speech-recognition", "parlaspeech"], "datasets": ["parlaspeech-hr"], "widget": [{"example_title": "example 1", "src": "https://huggingface.co/classla/wav2vec2-xls-r-parlaspeech-hr/raw/main/1800.m4a"}, {"example_title": "example 2", "src": "https://huggingface.co/classla/wav2vec2-xls-r-parlaspeech-hr/raw/main/00020578b.flac.wav"}, {"example_title": "example 3", "src": "https://huggingface.co/classla/wav2vec2-xls-r-parlaspeech-hr/raw/main/00020570a.flac.wav"}]}
transformers pytorch safetensors wav2vec2 automatic-speech-recognition audio parlaspeech hr dataset:parlaspeech-hr endpoints_compatible region:us
TAGS
#transformers #pytorch #safetensors #wav2vec2 #automatic-speech-recognition #audio #parlaspeech #hr #dataset-parlaspeech-hr #endpoints_compatible #region-us 

wav2vec2-large-slavic-parlaspeech-hr
====================================


This model for Croatian ASR is based on the facebook/wav2vec2-large-slavic-voxpopuli-v2 model and was fine-tuned with 300 hours of recordings and transcripts from the ASR Croatian parliament dataset ParlaSpeech-HR v1.0.


If you use this model, please cite the following paper:


Nikola Ljubešić, Danijel Koržinek, Peter Rupnik, Ivo-Pavao Jazbec. ParlaSpeech-HR -- a freely available ASR dataset for Croatian bootstrapped from the ParlaMint corpus. URL


Metrics
-------


Evaluation is performed on the dev and test portions of the ParlaSpeech-HR v1.0 dataset.


split: dev, CER: 0.0311, WER: 0.0921
split: test, CER: 0.0222, WER: 0.0679


There are multiple models available, and in terms of CER and WER, the best-performing model is wav2vec2-large-slavic-parlaspeech-hr-lm.


Usage in 'transformers'
-----------------------


Training hyperparameters
------------------------


In fine-tuning, the following arguments were used:




TAGS
#transformers #pytorch #safetensors #wav2vec2 #automatic-speech-recognition #audio #parlaspeech #hr #dataset-parlaspeech-hr #endpoints_compatible #region-us 

passage: TAGS
#transformers #pytorch #safetensors #wav2vec2 #automatic-speech-recognition #audio #parlaspeech #hr #dataset-parlaspeech-hr #endpoints_compatible #region-us 
