Somali Wav2Vec2 Model (ASR)
This is a fine-tuned Wav2Vec2 model for Automatic Speech Recognition (ASR) in the Somali language. It was specifically trained to transcribe spoken Somali audio into text, and serves as the core AI engine for the Somali Subtitle Generator web application.
Model Details
- Architecture: Wav2Vec2ForCTC
- Language: Somali (
so) - Task: Automatic Speech Recognition (ASR) / Speech-to-Text
Usage
You can use this model easily with the Hugging Face transformers library in Python.
Important Note: Because of how the vocabulary is structured, you must manually remove the [PAD] token and any | characters (word delimiters) from the output string after decoding.
import torch
import librosa
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
model_id = "MOHAMEDOMAR25/somali-wav2vec2-mode"
# Load the processor and model
processor = Wav2Vec2Processor.from_pretrained(model_id)
model = Wav2Vec2ForCTC.from_pretrained(model_id)
# Load your Somali audio file (must be resampled to 16kHz)
audio, rate = librosa.load("your_audio.wav", sr=16000)
# Process the audio
inputs = processor(audio, sampling_rate=16000, return_tensors="pt", padding=True)
# Run inference
with torch.no_grad():
logits = model(inputs.input_values).logits
# Decode the prediction
predicted_ids = torch.argmax(logits, dim=-1)
transcription = processor.batch_decode(predicted_ids)[0]
# Fix the output by removing the [PAD] token and replacing | with space
transcription = transcription.replace("[PAD]", "").replace("|", " ")
print("Transcription:", transcription)
Application
This model is actively used in a Flask-based web application to generate .srt and .vtt subtitles for Somali videos. The application utilizes Smart Chunking (Voice Activity Detection) to process long videos and feed the speech segments into this model.
- Downloads last month
- 42