Overview
Omnilingual ASR supports multiple audio input formats for flexible integration. All formats are automatically preprocessed (decoded, resampled to 16kHz, converted to mono, and normalized) by the inference pipeline.AudioInput Type
AudioInput is a type alias representing a list of audio samples in one of several supported formats:
Supported Formats
1. File Paths (str or Path)
Provide paths to audio files on disk.Supports common audio formats: WAV, MP3, FLAC, OGG, M4A, etc.
2. Raw Audio Bytes
Provide audio data as raw bytes (e.g., from HTTP requests or in-memory buffers).3. NumPy Arrays
Provide audio data as NumPy arrays (uint8 or int8 dtype).4. Pre-decoded Audio Dictionaries
Provide already-decoded audio with waveform and sample rate. This is the most efficient format if you’ve already decoded the audio.torch.Tensor
required
Audio waveform as a PyTorch tensor. Can be 1D (mono) or 2D (multi-channel). Multi-channel audio is automatically converted to mono.
int
required
Sample rate of the audio in Hz. Audio is automatically resampled to 16kHz if needed.
Audio Preprocessing Pipeline
Regardless of input format, all audio goes through the following preprocessing:- Decoding: Audio bytes/files are decoded to waveforms (skipped for pre-decoded format)
- Resampling: Waveforms are resampled to 16kHz
- Mono Conversion: Multi-channel audio is converted to mono by averaging channels
- Normalization: Audio is normalized to zero mean and unit variance
- Length Validation: Non-streaming models enforce a 40-second maximum length
Length Constraints
Non-Streaming Models
int
default:"40"
Maximum audio length in seconds for non-streaming models.
Streaming Models
Streaming model variants (e.g.,omniASR_LLM_7B_Unlimited) can handle audio of any length by processing it in segments.
Mixed Input Format Example
You can mix different input formats in a single batch:Performance Considerations
Best Practices
- Pre-decoded format: Use pre-decoded dictionaries if you need to decode audio multiple times
- Batch size: Larger batches improve throughput but require more memory
- File paths: Most convenient but requires disk I/O
- Bytes: Good for streaming/HTTP scenarios
Batch Processing Example
Error Handling
Source Reference
See type definition atsrc/omnilingual_asr/models/inference/pipeline.py:51