Views
No views yet
| split | CER | WER |
|---|---|---|
| dev | 0.0311 | 0.0921 |
| test | 0.0222 | 0.0679 |
transformers1from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
2import soundfile as sf
3import torch
4import os
5device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
6# load model and tokenizer
7processor = Wav2Vec2Processor.from_pretrained(
8 "classla/wav2vec2-large-slavic-parlaspeech-hr")
9model = Wav2Vec2ForCTC.from_pretrained("classla/wav2vec2-large-slavic-parlaspeech-hr")
10# download the example wav files:
11os.system("wget https://huggingface.co/classla/wav2vec2-large-slavic-parlaspeech-hr/raw/main/00020570a.flac.wav")
12# read the wav file
13speech, sample_rate = sf.read("00020570a.flac.wav")
14input_values = processor(speech, sampling_rate=sample_rate, return_tensors="pt").input_values.to(device)
15# remove the raw wav file
16os.system("rm 00020570a.flac.wav")
17# retrieve logits
18logits = model.to(device)(input_values).logits
19# take argmax and decode
20predicted_ids = torch.argmax(logits, dim=-1)
21transcription = processor.decode(predicted_ids[0]).lower()
22# transcription: 'veliki broj poslovnih subjekata posluje sa minusom velik dio'| arg | value |
|---|---|
per_device_train_batch_size | 16 |
gradient_accumulation_steps | 4 |
num_train_epochs | 8 |
learning_rate | 3e-4 |
warmup_steps | 500 |