Downloads · 30 days
17
15% of all-time downloads
videoloc/seamless-langpairs
seamless-langpairs is a machine learning model from videoloc. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as cc-by-nc-4.0.
This is a SeamlessLanguagePairs model that processes audio and text inputs with both translation awareness and language pair embeddings to predict Time To Edit (TTE) for subtitle segments. Given an audio segment and i…
Downloads · 30 days
17
15% of all-time downloads
All-time downloads
111
Public
Repo size
4.9 GB
Likes
0
Public
Click a slice to open those files.
.bin4.9 GB · 100%
From the Hugging Face model README
This is a SeamlessLanguagePairs model that processes audio and text inputs with both translation awareness and language pair embeddings to predict Time To Edit (TTE) for subtitle segments. Given an audio segment and its corresponding subtitle text, the model predicts how much time (in seconds) would be required to edit/refine that subtitle segment, taking into account both whether the subtitle is translated and the specific language pair involved.
The model extends the SeamlessM4T architecture with both translation features and language pair embeddings, providing the most granular control for multilingual scenarios across 5 languages: English, French, Spanish, Italian, and German with 21 different translation pairs between them (e.g., EN→FR, ES→DE, IT→EN, etc.).
The model extends the basic SeamlessM4T architecture with both translation and language pair awareness:
Audio Processing:
Text Processing:
Translation Feature Processing:
Language Pair Processing:
Feature Fusion:
Regression Head:
pip install transformers torch torchaudio huggingface_hub
from transformers import AutoModel, AutoConfig
from huggingface_hub import hf_hub_download
import torch
import numpy as np
import importlib.util
# Load model - custom architecture requires importing the model class
model_files = hf_hub_download(repo_id="videoloc/seamless-langpairs", filename="modeling_seamless_langpairs.py")
spec = importlib.util.spec_from_file_location("modeling_seamless_langpairs", model_files)
modeling_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(modeling_module)
# Now load the model using the custom class
config = modeling_module.SeamlessLanguagePairsConfig.from_pretrained("videoloc/seamless-langpairs")
model = modeling_module.HFSeamlessLanguagePairs.from_pretrained("videoloc/seamless-langpairs")
# Load the data collator (included in this repo)
collator_file = hf_hub_download(repo_id="videoloc/seamless-langpairs", filename="data_collator.py")
spec = importlib.util.spec_from_file_location("data_collator", collator_file)
collator_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(collator_module)
# Initialize data collator
data_collator = collator_module.DataCollatorSimpleSeamless(
processor="facebook/hf-seamless-m4t-medium",
max_audio_length_sec=8.0,
max_text_length=256
)
# Prepare your data with translation and language pair information
your_data = [
{
'raw_audio': np.random.randn(16000 * 5), # 5 seconds at 16kHz
'raw_text': "Your subtitle text here",
'is_translation': 1, # 1 for translated content, 0 for original
'language_pair_id': 5, # 0-20 for specific language pairs
}
]
# Process and run inference
batch = data_collator(your_data)
model.eval()
with torch.no_grad():
outputs = model(**batch)
tte_prediction = outputs.logits.item()
print(f"Predicted Time To Edit (TTE): {tte_prediction:.2f} seconds")
The model supports 21 specific translation pairs between 5 languages:
Languages: English (EN), French (FR), Spanish (ES), Italian (IT), German (DE)
Translation Pairs: All combinations between the 5 languages create various directional pairs (e.g., EN→FR, FR→EN, ES→IT, DE→ES, etc.). The model uses language pair IDs (0-20) to identify specific translation directions, with ID 21 reserved for "other" pairs.
Your input data should be a list of dictionaries with:
raw_audio: NumPy array of audio samples (16kHz sampling rate)raw_text: String of subtitle textis_translation: Binary flag (1 for translated, 0 for original content)language_pair_id: Integer ID (0-20) for specific language pairlabels: Target TTE values in seconds (optional, for training)Example:
data = [
{
'raw_audio': audio_samples, # shape: (num_samples,) at 16kHz
'raw_text': "Subtitle text content",
'is_translation': 1, # 1 = translated, 0 = original
'language_pair_id': 5, # 0-20 for language pairs
'labels': 2.5 # optional TTE target value in seconds
}
]
The model was trained with the following specifications:
seamless-basic (audio+text only) or seamless-translation (with translation flag)