Architecture

speech-swift is organized as a modular Swift package with shared protocols, independent model modules, and a unified CLI. All inference runs on-device using MLX (Metal GPU) or CoreML (Neural Engine).

Module Dependency Graph

                    ┌──────────┐
                    │ AudioCLI │  (entry point)
                    └────┬─────┘
                         │
                  ┌──────┴──────┐
                  │ AudioCLILib │  (commands)
                  └──────┬──────┘
                         │
       ┌─────────┬───────┼───────┬──────────┬──────────────┐
       │         │       │       │          │              │
  ┌────┴───┐ ┌──┴──┐ ┌──┴──┐ ┌─┴────┐ ┌───┴────┐ ┌──────┴───────┐
  │Qwen3ASR│ │Qwen3│ │Cosy │ │Perso-│ │Speech- │ │  Speech-     │
  │Parakeet│ │ TTS │ │Voice│ │naPlex│ │  VAD   │ │Enhancement   │
  └────┬───┘ └──┬──┘ └──┬──┘ └──┬───┘ └───┬───┘ └──────┬───────┘
       │        │       │       │         │             │
       └────────┴───────┼───────┴─────────┘             │
                        │                               │
                 ┌──────┴──────┐                        │
                 │ Qwen3Common │  (shared layers)       │
                 └──────┬──────┘                        │
                        │                               │
                 ┌──────┴──────┐                        │
                 │ AudioCommon │ ◄──────────────────────┘
                 └─────────────┘  (protocols, audio I/O)

MOSS Transcribe Diarize

MossTranscribe returns speaker-attributed timestamp segments through two native backends. CoreML uses a fixed 1,024-token MLState for short recordings. MLX uses a dynamically growing 131,072-token context, affine INT5/INT8 decoder weights, and optional FP16/INT8 KV caches for globally contextualized long-form transcription. Both are offline, autoregressive runtimes rather than streaming models.

Inference Backends

BackendHardwareModels
MLX Metal GPU Qwen3-ASR, Qwen3-TTS, CosyVoice3, IndexTTS2, Qwen3.5-Chat, PersonaPlex, Omnilingual ASR (300M / 1B / 3B / 7B), Cohere Transcribe 2B, Voxtral Mini 3B, MOSS Transcribe Diarize, Pyannote, Silero VAD, WeSpeaker
CoreML Neural Engine Qwen3-ASR encoder (hybrid), Parakeet TDT, Parakeet EOU streaming, Omnilingual ASR 300M, Kokoro-82M, Qwen3.5-Chat (optional), Sortformer diarization, DeepFilterNet3, Silero VAD (optional), WeSpeaker (optional), MOSS Transcribe Diarize
Accelerate CPU (SIMD) Audio preprocessing (STFT, mel, FFT), signal processing

Model Weight Format

MLX models use safetensors format with 4-bit or 8-bit quantization (group size 64). CoreML models use .mlmodelc compiled format. Conversion scripts in scripts/ convert from PyTorch checkpoints.

Cohere and Voxtral also use MLX affine INT5 bundles. MLX does not support affine INT7; INT8 is the supported higher-quality option.

ModelParamsQuantizationSize on Disk
Qwen3-ASR 0.6B (MLX)~600M4-bit / 8-bit680 MB / 1.0 GB
Qwen3-ASR 0.6B (CoreML)~186M (encoder)INT8~180 MB
Qwen3-ASR 1.7B (MLX)~1.7B4-bit / 8-bit2.1 GB / 3.2 GB
Parakeet-TDT 0.6B (CoreML)~600MINT8500 MB
Whisper Large-v3 Turbo (CoreML)809MFP161.6 GB
MOSS Transcribe Diarize 0.9B (MLX)908.5MFP16 audio + INT5 / INT8 decoder987.0 MiB / 1,200.1 MiB
MOSS Transcribe Diarize 0.9B (CoreML)~900MFP16 / INT8 block-321.7 GB / 1.2 GB
Parakeet-EOU 120M (CoreML)~120MINT8~120 MB
Omnilingual-ASR-CTC 300M (CoreML)326MINT8312 MB
Omnilingual-ASR-CTC 300M (MLX)326M4-bit / 8-bit193 MB / 342 MB
Omnilingual-ASR-CTC 1B (MLX)1.01B4-bit / 8-bit549 MB / 1006 MB
Omnilingual-ASR-CTC 3B (MLX)~3B4-bit / 8-bit1.71 GB / 3.16 GB
Omnilingual-ASR-CTC 7B (MLX)~7B4-bit / 8-bit3.55 GB / 6.63 GB
Cohere Transcribe 2B (MLX)2BFP16 / INT5 / INT83.85 / 1.62 / 2.25 GiB
Voxtral Mini 3B 2507 (MLX)3BFP16 / INT5 / INT88.71 / 3.77 / 5.18 GiB
Qwen3-ForcedAligner 0.6B (MLX)~600M4-bit / 8-bit979 MB / 1.4 GB
Qwen3-ForcedAligner 0.6B (CoreML)~600MINT4 / INT8630 MB / 1.0 GB
Qwen3-TTS 0.6B (MLX)~600M4-bit / 8-bit1.7 GB / 2.4 GB
Qwen3-TTS 1.7B (MLX)~1.7B4-bit / 8-bit3.2 GB / 4.8 GB
CosyVoice3 0.5B (MLX)~500M4-bit LLM~1.2 GB
IndexTTS2 expanded bundle (MLX)1.5B-classFP16 + auxiliary models~4.8 GB
Kokoro-82M (CoreML)82MINT8 (1 bucket)~89 MB
Qwen3.5-Chat 0.8B (MLX)~800MINT4418 MB
Qwen3.5-Chat 0.8B (CoreML)~800MINT8981 MB
PersonaPlex 7B (MLX)~7B4-bit / 8-bit4.9 GB / 9.1 GB
Pyannote VAD (MLX)~1.49Mfloat32~5.7 MB
Silero VAD v5~309Kfloat32~1.2 MB (MLX & CoreML)
WeSpeaker ResNet34~6.6Mfloat32~25 MB (MLX & CoreML)
ReDimNet2-B612.3Mfloat16~25 MiB (CoreML)
Pyannote Community-1 (CoreML)8.35Mfloat32 + native VBx~32 MB
Sortformer (CoreML)float16~50 MB
DeepFilterNet3 (CoreML)~2.1MFP16~4.2 MB
LocalVQE v1.4-AEC (CoreML + C++)200K + 2,742FP16 + FP32~732 KB

Performance Optimizations

Audio Processing

All audio I/O uses Float32 PCM. Internal resampling handles format conversion:

ModelExpected RateFormat
Qwen3-ASR16 kHzMono Float32
Cohere Transcribe 2B16 kHzMono Float32
Voxtral Mini 3B16 kHzMono Float32
Qwen3-TTS24 kHz outputMono Float32
CosyVoice324 kHz outputMono Float32
Kokoro-82M24 kHz outputMono Float32
PersonaPlex24 kHz I/OMono Float32
Pyannote VAD16 kHzMono Float32
Silero VAD16 kHzMono Float32
WeSpeaker16 kHzMono Float32
ReDimNet2-B616 kHzMono Float32
DeepFilterNet348 kHzMono Float32

Source Structure

Sources/
  AudioCommon/            Shared protocols, audio I/O, system-output capture
                          (SystemAudioTap), HuggingFace downloader,
                          SentencePieceModel (protobuf reader)
  MLXCommon/              MLX utilities: weight loading, QuantizedLinear helpers,
                          SDPA multi-head attention helper, metal budget
  Qwen3Common/            Shared model components (KV cache, RoPE, quantization)
  Qwen3ASR/               Qwen3-ASR speech-to-text
  ParakeetASR/            Parakeet TDT speech-to-text (CoreML)
  ParakeetStreamingASR/   Parakeet EOU 120M streaming dictation (CoreML)
  OmnilingualASR/         Meta wav2vec2 + CTC, 1,672 languages
                          (CoreML 300M + MLX 300M / 1B / 3B / 7B)
  CohereTranscribeASR/  Cohere Transcribe 2B speech-to-text (MLX)
  VoxtralASR/            Voxtral Mini 3B speech-to-text (MLX)
  Qwen3TTS/               Qwen3-TTS text-to-speech
  CosyVoiceTTS/           CosyVoice3 text-to-speech
  KokoroTTS/              Kokoro-82M text-to-speech (CoreML)
  Qwen3Chat/              Qwen3.5-0.8B on-device LLM chat (MLX + CoreML)
  PersonaPlex/            PersonaPlex speech-to-speech
  SpeechVAD/              VAD (Silero + Pyannote), diarization, speaker embeddings
  SpeechEnhancement/      DeepFilterNet3 noise suppression (CoreML)
  SourceSeparation/       Open-Unmix HQ / UMX-L + HTDemucs (Demucs v4) music source separation (MLX, 4 stems)
  MAGNeTMusicGen/         MAGNeT text-to-music generation (MLX, 30 s @ 32 kHz, INT4/INT8)
  VoxCPM2TTS/             VoxCPM2 text-to-speech (MLX, 48 kHz, voice cloning + voice design)
  IndexTTS2TTS/           IndexTTS2 voice cloning (MLX, semantic GPT + emotion/tempo/pause control + S2Mel + BigVGAN)
  VibeVoiceTTS/           VibeVoice long-form / multi-speaker TTS (MLX, EN/ZH)
  MagpieTTS/              NVIDIA Magpie-TTS Multilingual 357M (MLX INT4/INT8,
                          9 languages, 5 baked speakers, streaming)
  MagpieTTSCoreML/        Magpie CoreML backend (4 .mlmodelc + Swift-side
                          FSQ inverse; 8 languages, batch-only; hybrid
                          with MagpieTTS for LocalTransformer + audio
                          embeddings)
  MADLADTranslation/      MADLAD-400 many-to-many translation (MLX, 400+ languages)
  AudioCLILib/            CLI command implementations
  AudioCLI/               CLI entry point

scripts/              Model conversion (PyTorch → MLX/CoreML), benchmarking
Tests/                Unit and integration tests
Examples/             Demo apps (PersonaPlexDemo, SpeechDemo)