CoolFace
Modelpublic

marid/sst2

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes4downloads
Model Card

<!-- This model card has been generated automatically according to the information the Trainer had access to. You should probably proofread and complete it, then remove this comment. -->

Sinai Voice Arabic Speech Recognition Model

نموذج صوت سيناء للتعرف على الأصوات العربية الفصحى و تحويلها إلى نصوص

This model is a fine-tuned version of facebook/wav2vec2-xls-r-300m on the MOZILLA-FOUNDATION/COMMONVOICE8_0 - AR dataset. It achieves the following results on the evaluation set:

  • Loss: 0.2141
  • Wer: 0.1808

It achieves the following results on the evaluation set:

  • eval_loss = 0.2141
  • eval_samples = 10388
  • eval_wer = 0.181
  • eval_cer = 0.049
Evaluation Commands
  1. 1.To evaluate on mozilla-foundation/common_voice_8_0 with split test
bash
python eval.py --model_id bakrianoo/sinai-voice-ar-stt --dataset mozilla-foundation/common_voice_8_0 --config ar --split test

Inference Without LM

python
from transformers import (Wav2Vec2Processor, Wav2Vec2ForCTC)
import torchaudio
import torch

def speech_file_to_array_fn(voice_path, resampling_to=16000):
    speech_array, sampling_rate = torchaudio.load(voice_path)
    resampler = torchaudio.transforms.Resample(sampling_rate, resampling_to)
    
    return resampler(speech_array)[0].numpy(), sampling_rate

# load the model
cp = "bakrianoo/sinai-voice-ar-stt"
processor = Wav2Vec2Processor.from_pretrained(cp)
model = Wav2Vec2ForCTC.from_pretrained(cp)

# recognize the text in a sample sound file
sound_path = './my_voice.mp3'

sample, sr = speech_file_to_array_fn(sound_path)
inputs = processor([sample], sampling_rate=16_000, return_tensors="pt", padding=True)

with torch.no_grad():
    logits = model(inputs.input_values,).logits

predicted_ids = torch.argmax(logits, dim=-1)

print("Prediction:", processor.batch_decode(predicted_ids))

Training hyperparameters

The following hyperparameters were used during training:

  • learning_rate: 0.0002
  • trainbatchsize: 32
  • evalbatchsize: 10
  • seed: 42
  • distributed_type: multi-GPU
  • num_devices: 8
  • totaltrainbatch_size: 256
  • totalevalbatch_size: 80
  • optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
  • lrschedulertype: linear
  • lrschedulerwarmup_steps: 1000
  • num_epochs: 10
  • mixedprecisiontraining: Native AMP

Training results

Training LossEpochStepValidation LossWer
1.3540.6410000.41090.4493
0.58861.2820000.27980.3099
0.49771.9230000.23870.2673
0.42532.5640000.22660.2523
0.39423.250000.21710.2437
0.36193.8460000.20760.2253
0.32454.4870000.20880.2186
0.3085.1280000.20860.2206
0.28815.7690000.20890.2105
0.25576.4100000.20150.2004
0.2487.04110000.20440.1953
0.22517.68120000.20580.1932
0.20528.32130000.21170.1878
0.19768.96140000.21040.1825
0.18459.6150000.21560.1821

Framework versions

  • Transformers 4.16.2
  • Pytorch 1.10.2+cu113
  • Datasets 1.18.3
  • Tokenizers 0.11.0