Skip to content

About

Foundational Model for Speech Recognition Tasks

Resources

Stars

15 stars

Watchers

0 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gigaam-mlx

License: MIT Python 3.10+ Apple Silicon HuggingFace v4 CTC HuggingFace v4 RNNT HuggingFace Multilingual v2 HuggingFace VAD arXiv

Fast speech recognition across 21 languages on Apple Silicon — up to 463x realtime (v4 CTC FP16) / 146x (Multilingual-v2 FP16)

Pure MLX port of GigaAM-v4 (Zapformer, 235M–236M params), GigaAM-Multilingual-v2 (Zapformer, 771M active MLX params / 21 languages with FiLM & late-fusion language conditioning), GigaAM-v3 (Conformer, 220M–222M params), and GigaAM Conformer VAD (1.33M params). Supports batched variable-length transcription, word-level timestamps (offline & streaming), VAD speech segmentation, language conditioning, and real-time streaming (160 / 320 / 640 ms), producing punctuated, normalized text with zero PyTorch runtime dependency.

Benchmark comparison

Quick Start

pip install git+https://github.com/aystream/gigaam-mlx.git
from gigaam_mlx import load_model, transcribe, transcribe_file

model, tokenizer = load_model()  # GigaAM-v4 e2e CTC (auto-downloads from HF)
text = transcribe(model, tokenizer, "meeting.wav")
print(text)

# Detailed segments with word-level timestamps & pure-MLX Conformer VAD
# (auto-downloads aystream/GigaAM-VAD-mlx on first run, ~5.3 MB)
segments = transcribe_file(
    "meeting.wav",
    model=model,
    tokenizer=tokenizer,
    batch_size=4,
    vad=True,
    word_timestamps=True,
)

Real-time Streaming (GigaAM-v4 & Multilingual v2)

Feed 16 kHz mono float32 PCM chunks of any size (future_context_ms can be 160, 320, or 640). Note: enabling word_timestamps=True holds back any trailing incomplete word until the next word boundary or flush().

from gigaam_mlx import load_audio, load_model

model, tokenizer = load_model("rnnt")  # or "ctc"
stream = model.create_stream(tokenizer, future_context_ms=320, word_timestamps=True)

audio = load_audio("meeting.wav")
for i in range(0, len(audio), 3200):  # 200ms packets
    delta = stream.transcribe_partial(audio[i : i + 3200])
    if delta:
        print(delta, end="", flush=True)
    # Optional newly completed words: stream.last_words
print(stream.flush())
print(stream.words[:5])  # [{"text": "...", "start": ..., "end": ...}, ...]

Multilingual v2 (21 Languages)

GigaAM-Multilingual-v2 (model_type="multilingual", 771M MLX params) scales the Zapformer RNN-T architecture across 25 encoder layers with FiLM (layers 3, 7, 11, 15, 19, 23), FP32 residual late fusion, and max_symbols_per_step=3.

  • Supported tags: "auto" (default) and 21 languages: ru, en, kk (alias kz), ky, uz, be, fr, es, ba, ka, hy, ro, tk, az, tg, de, it, nl, pl, pt, tt.
  • Mixtures & per-batch tags: pass "ru-en", '["ru", "en"]', or {"ru": 0.7, "en": 0.3}, or a per-item list such as ["ru", "en"] to model.encode(mels, lengths=lens, language=...).
from gigaam_mlx import load_model, transcribe

model, tokenizer = load_model("multilingual", language="ru")  # or "auto"
text = transcribe(model, tokenizer, "meeting.wav", vad=True)

# Switch conditioning dynamically in streaming mode (resets stream state)
stream = model.create_stream(tokenizer, future_context_ms=320, language="ru")
stream.set_language("en")

CLI

# Transcribe any audio/video file (GigaAM-v4 CTC — fast, default, batch_size=4)
gigaam-mlx recording.mkv

# Use GigaAM-v4 RNNT for highest Russian/English accuracy
gigaam-mlx recording.mkv --model-type rnnt

# Use Multilingual-v2 across 21 languages (auto, explicit --language, or JSON mixture)
gigaam-mlx recording.mkv --model-type multilingual --language ru --vad
gigaam-mlx recording.mkv --model-type multilingual --language '{"ru":0.7,"en":0.3}' --vad

# Use pure-MLX Conformer VAD segmentation & word-level timestamps (.srt/.txt/.json)
gigaam-mlx recording.mkv --vad --word-timestamps --format all

# Point to explicit VAD weights and tune chunk batch size
gigaam-mlx recording.mkv --vad-model ./weights_vad.safetensors --batch-size 4

# Use FP16 compute for extra speed
gigaam-mlx recording.mkv --dtype float16

# Output subtitles to a specific directory
gigaam-mlx call.wav --output-dir ./transcripts --format srt

# Batch-transcribe multiple files (model loaded once, skip already transcribed)
gigaam-mlx *.mkv --skip-existing

# Use legacy GigaAM-v3 models
gigaam-mlx recording.mkv --model-type v3_ctc

Outputs .srt (subtitles), .txt (plain text), and optionally .json (segments + word-level timestamps). Model weights download automatically on first run.

Performance

MacBook Pro M2 Max, 19-second dense Russian speech chunk (295 chars, avg of 3 warmed-up runs):

Backend Model Time Realtime factor
MLX (this) v4_e2e_ctc (FP16) 0.041s ~463x
MLX (this) v4_e2e_ctc (FP32) 0.046s ~418x
MLX (this) v3_e2e_ctc (FP32) 0.054s ~355x
MLX (this) v4_e2e_rnnt (FP16) 0.103s ~184x
MLX (this) v4_e2e_rnnt (FP32) 0.107s ~177x
MLX (this) v3_e2e_rnnt (FP32) 0.116s ~164x
PyTorch CPU v4_e2e_ctc (FP32) 0.417s ~46x
PyTorch CPU v4_e2e_rnnt (FP32) 0.490s ~39x
  • MLX timings measure pure encode + decode (pure-NumPy mel extraction adds ~1.9 ms on the 19s chunk); PyTorch timings include its FeatureExtractor.
  • Full 22-minute audio (1319.4s, bucketed batch_size=4, FP32):
    • Fresh CLI end-to-end (startup, model load, ffmpeg, chunking, ASR, file write): v4 CTC 3.98s (~332x realtime), v4 RNNT 4.76s (~277x realtime); with --vad Conformer segmentation: v4 CTC 4.37s (~302x), v4 RNNT 4.83s (~273x).
    • Warmed transcribe_file API: v4 CTC 3.09s (~428x, 3.75s at batch_size=1), v4 RNNT 4.52s (~292x, 7.19s at batch_size=1).
  • Streaming latency (320 ms context, 320 ms packets, dense chunk, FP32): v4 CTC 14.3 ms/packet (~22x realtime), v4 RNNT 17.3 ms/packet (~18x realtime).
  • PyTorch parity: Identical decoded text and streaming packet deltas vs ai-sage/GigaAM-v4 PyTorch CPU reference across full-context and 160 / 320 / 640 ms streaming modes on our test clips (mean abs encoder diff <= 5e-6), and identical speech_timestamps vs PyTorch vad (max prob diff < 1e-4).

GigaAM-Multilingual-v2 (771M active MLX / 774M upstream checkpoint)

MacBook Pro M2 Max on a 19.0s speech clip from audio_second_half.wav:

Backend Configuration Time / Latency Realtime factor
MLX (this) multilingual_v2_rnnt (FP16) 0.131s ~146x
MLX (this) multilingual_v2_rnnt (FP32) 0.147s ~129x
MLX Streaming 320 ms context, 320 ms packets (FP16) 30.9 ms/packet ~10.3x
MLX Streaming 320 ms context, 320 ms packets (FP32) 34.3 ms/packet ~9.2x
PyTorch CPU Multilingual-v2 (FP32) 2.007s ~9.5x
  • At 200 ms packet stride (320 ms context), streaming latency is 19.2 ms/packet (~10.4x realtime) in FP16 and 21.9 ms/packet (~9.1x realtime) in FP32.
  • --dtype float16 converts encoder and RNNT head weights to FP16 while preserving language_embedding and language_fusion weights in FP32.
  • Full 22-minute audio (1319.4s, bucketed batch_size=4):
    • Warmed transcribe_file: 8.43s (~157x realtime, 2.34 GB peak) in FP16 with VAD (8.65s / ~153x without VAD); 9.93s (~133x, 4.65 GB peak) in FP32 with VAD (9.67s / ~137x without VAD).
    • Fresh CLI end-to-end (--vad): 9.56s (~138x realtime) in FP16, 12.84s (~103x realtime) in FP32.
  • PyTorch parity: mean abs encoder diff <= 6.8e-6 (max <= 2.8e-4) and identical text, word timestamps, and 160 / 320 / 640 ms streaming packet deltas across auto, ru, en, and ru-en vs ai-sage/GigaAM-Multilingual-v2 PyTorch CPU FP32.

Model variants

Note (v0.2.0): "ctc" and "rnnt" aliases now default to GigaAM-v4 (breaking change from v0.1.0). Pass "v3_ctc" or "v3_rnnt" for GigaAM-v3.

Variant / Alias Architecture Weights Use case
ctc, v4_ctc, v4_e2e_ctc Zapformer (235M) + char CTC GigaAM-v4-e2e-ctc-mlx Default — fastest, offline & streaming
rnnt, v4_rnnt, v4_e2e_rnnt Zapformer (236M) + SP RNNT GigaAM-v4-e2e-rnnt-mlx Highest accuracy (RU + EN), offline & streaming
multilingual, multilingual_rnnt, multilingual_v2, multilingual_v2_rnnt, v2_multilingual_rnnt Zapformer (771M) + SP RNNT + FiLM/LateFusion GigaAM-Multilingual-v2-mlx 21 languages, language conditioning, streaming
v3_ctc, v3_e2e_ctc Conformer (220M) + SP CTC GigaAM-v3-e2e-ctc-mlx Legacy GigaAM-v3
v3_rnnt, v3_e2e_rnnt Conformer (222M) + SP RNNT GigaAM-v3-e2e-rnnt-mlx Legacy GigaAM-v3
load_vad_model() / --vad Conformer VAD (1.33M) GigaAM-VAD-mlx Voice activity detection & speech segmentation
# Highest accuracy with GigaAM-v4 RNNT
model, tokenizer = load_model("rnnt")

# Legacy GigaAM-v3
model, tokenizer = load_model("v3_rnnt")

Features

  • Up to 463x realtime (19s chunk, FP16) / 332x end-to-end (22-min CLI, FP32) on Apple Silicon (M1/M2/M3/M4)
  • Batched length-sorted chunk inference (--batch-size, 256-frame bucketing) with exact batch=1 parity in FP32
  • Pure-MLX Conformer VAD (--vad, 1.33M params, ~0.26s for 22 min audio) for pause-aware segmentation
  • Word-level timestamps (--word-timestamps, --format json|all) for both offline and streaming modes
  • Full-context + native streaming (160 ms, 320 ms, 640 ms future context) from the same weights
  • 21 languages via Multilingual-v2 (FiLM + FP32 late fusion, --language) alongside bilingual RU/EN GigaAM-v4
  • Punctuation & normalization built-in — end-to-end model, no post-processing
  • Zero PyTorch runtime dependency — pure MLX + NumPy + sentencepiece (fast ~1.9 ms mel extraction)
  • Any media format — video and audio via ffmpeg (mkv, mp4, wav, mp3, ...)
  • Auto-download — ASR and VAD weights download automatically from HuggingFace Hub

Requirements

  • macOS with Apple Silicon (M1+)
  • Python >= 3.10
  • ffmpeg (brew install ffmpeg)

How it works

GigaAM-v4 WER benchmarks across Russian and English datasets
GigaAM-v4 accuracy across Russian and English benchmarks (source)

Audio/Video → ffmpeg (16kHz mono) → Mel spectrogram (pure NumPy)
    → Zapformer encoder (ConvNeXt frontend, interleaved RoPE):
      • v4: 4×768d / 11×1024d @2x / 4×768d → CTC (146) or RNNT (1025)
      • Multilingual-v2: 7×1024d / 12×1280d @2x / 6×1024d
        + LanguageFiLM (layers 3,7,11,15,19,23) + FP32 late fusion → RNNT (4027)
    → punctuated text

Converting weights yourself

GigaAM-v4 and Multilingual-v2 convert directly from HuggingFace safetensors (no PyTorch required):

python -m gigaam_mlx.convert --model v4_e2e_ctc --output-dir ./weights_v4_ctc
python -m gigaam_mlx.convert --model v4_e2e_rnnt --output-dir ./weights_v4_rnnt
python -m gigaam_mlx.convert --model multilingual_v2_rnnt --output-dir ./weights_multilingual_v2

For GigaAM-v3 and Conformer VAD (requires optional PyTorch conversion dependencies):

pip install "gigaam-mlx[convert] @ git+https://github.com/aystream/gigaam-mlx.git"
python -m gigaam_mlx.convert --model v3_e2e_ctc --output-dir ./weights_v3_ctc
python -m gigaam_mlx.convert --model v3_e2e_rnnt --output-dir ./weights_v3_rnnt
python -m gigaam_mlx.convert --model vad --output-dir ~/.cache/gigaam-mlx --filename weights_vad.safetensors

Acknowledgments

License

MIT — same as the original GigaAM model.

About

Foundational Model for Speech Recognition Tasks

Resources

Stars

15 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages