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-xls-r-parlaspeech-hr")
model = Wav2Vec2ForCTC.from_pretrained("classla/wav2vec2-xls-r-parlaspeech-hr")
# download the example wav files:
os.system("wget https://huggingface.co/classla/wav2vec2-xls-r-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
Runs of classla wav2vec2-xls-r-parlaspeech-hr on huggingface.co
987.8K
Total runs
-316
24-hour runs
-83.0K
3-day runs
-210.5K
7-day runs
431.0K
30-day runs
More Information About wav2vec2-xls-r-parlaspeech-hr huggingface.co Model
wav2vec2-xls-r-parlaspeech-hr huggingface.co
wav2vec2-xls-r-parlaspeech-hr huggingface.co is an AI model on huggingface.co that provides wav2vec2-xls-r-parlaspeech-hr's model effect (), which can be used instantly with this classla wav2vec2-xls-r-parlaspeech-hr model. huggingface.co supports a free trial of the wav2vec2-xls-r-parlaspeech-hr model, and also provides paid use of the wav2vec2-xls-r-parlaspeech-hr. Support call wav2vec2-xls-r-parlaspeech-hr model through api, including Node.js, Python, http.
wav2vec2-xls-r-parlaspeech-hr huggingface.co is an online trial and call api platform, which integrates wav2vec2-xls-r-parlaspeech-hr's modeling effects, including api services, and provides a free online trial of wav2vec2-xls-r-parlaspeech-hr, you can try wav2vec2-xls-r-parlaspeech-hr online for free by clicking the link below.
classla wav2vec2-xls-r-parlaspeech-hr online free url in huggingface.co:
wav2vec2-xls-r-parlaspeech-hr is an open source model from GitHub that offers a free installation service, and any user can find wav2vec2-xls-r-parlaspeech-hr on GitHub to install. At the same time, huggingface.co provides the effect of wav2vec2-xls-r-parlaspeech-hr install, users can directly use wav2vec2-xls-r-parlaspeech-hr installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
wav2vec2-xls-r-parlaspeech-hr install url in huggingface.co: