Downloads · 30 days
2.7K
16% of all-time downloads
onnx-community/mms-300m-1130-forced-aligner-ONNX
mms-300m-1130-forced-aligner-ONNX is a automatic speech recognition model from onnx-community. Use it when you need speech turned into text. It is set up for transformers.js. The card lists the license as cc-by-nc-4.0.
This is an ONNX version of MahmoudAshraf/mms-300m-1130-forced-aligner. It was automatically converted and uploaded using this Hugging Face Space.
Downloads · 30 days
2.7K
16% of all-time downloads
All-time downloads
16.7K
Public
Repo size
3.2 GB
Likes
5
Public
Click a slice to open those files.
.onnx3.5 GB · 100%
From the Hugging Face model README
This is an ONNX version of MahmoudAshraf/mms-300m-1130-forced-aligner. It was automatically converted and uploaded using this Hugging Face Space.
See the pipeline documentation for automatic-speech-recognition: https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.AutomaticSpeechRecognitionPipeline
This Python package provides an efficient way to perform forced alignment between text and audio using Hugging Face's pretrained models. it also features an improved implementation to use much less memory than TorchAudio forced alignment API.
The model checkpoint uploaded here is a conversion from torchaudio to HF Transformers for the MMS-300M checkpoint trained on forced alignment dataset
pip install git+https://github.com/MahmoudAshraf97/ctc-forced-aligner.git
import torch
from ctc_forced_aligner import (
load_audio,
load_alignment_model,
generate_emissions,
preprocess_text,
get_alignments,
get_spans,
postprocess_results,
)
audio_path = "your/audio/path"
text_path = "your/text/path"
language = "iso" # ISO-639-3 Language code
device = "cuda" if torch.cuda.is_available() else "cpu"
batch_size = 16
alignment_model, alignment_tokenizer = load_alignment_model(
device,
dtype=torch.float16 if device == "cuda" else torch.float32,
)
audio_waveform = load_audio(audio_path, alignment_model.dtype, alignment_model.device)
with open(text_path, "r") as f:
lines = f.readlines()
text = "".join(line for line in lines).replace("\n", " ").strip()
emissions, stride = generate_emissions(
alignment_model, audio_waveform, batch_size=batch_size
)
tokens_starred, text_starred = preprocess_text(
text,
romanize=True,
language=language,
)
segments, scores, blank_token = get_alignments(
emissions,
tokens_starred,
alignment_tokenizer,
)
spans = get_spans(tokens_starred, segments, blank_token)
word_timestamps = postprocess_results(text_starred, spans, stride, scores)