Skip to main content

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).
Only uint8 and int8 dtypes are supported for NumPy arrays. Other dtypes will raise an assertion error.

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.
Dictionary Format Requirements:
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:
  1. Decoding: Audio bytes/files are decoded to waveforms (skipped for pre-decoded format)
  2. Resampling: Waveforms are resampled to 16kHz
  3. Mono Conversion: Multi-channel audio is converted to mono by averaging channels
  4. Normalization: Audio is normalized to zero mean and unit variance
  5. 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:
All elements in the input list must be of compatible types. Don’t mix bytes with dictionaries, or file paths with numpy arrays in the same batch.

Performance Considerations

Best Practices

  1. Pre-decoded format: Use pre-decoded dictionaries if you need to decode audio multiple times
  2. Batch size: Larger batches improve throughput but require more memory
  3. File paths: Most convenient but requires disk I/O
  4. Bytes: Good for streaming/HTTP scenarios

Batch Processing Example

Error Handling

Source Reference

See type definition at src/omnilingual_asr/models/inference/pipeline.py:51