Skip to content
Projekte

Über uns

Ein modulares Swift-SDK zur Audioverarbeitung mit MLX auf Apple Silicon.

Design und Medien

So werden diese Zahlen gemessen

What you can do

  • Modular architecture for minimal app size - import only what you need
  • Automatic model downloading from HuggingFace Hub
  • Native async/await support for seamless Swift integration
  • Streaming audio generation for real-time TTS

Gemessener Sternzuwachs

in 24h
0
in 7 days
+3
in 15 days
+4
in 1 month
Verlauf wird gesammelt

Nettoänderungen in überlappenden Zeiträumen, keine Tagessummen. Fehlende Messwerte bleiben leer. Sterne zeigen Interesse, nicht Qualität.

README.md

Original

MLX Audio Swift

A modular Swift SDK for audio processing with MLX on Apple Silicon

Platform Swift License

Architecture

MLXAudio follows a modular design allowing you to import only what you need:

  • MLXAudioCore: Base types, protocols, and utilities
  • MLXAudioCodecs: Audio codec implementations (SNAC, Encodec, Vocos, Mimi, DACVAE, Descript DAC, Fish S1 DAC, S3TokenizerV2, MOSS Audio Tokenizer, Higgs Audio Tokenizer, Step-Audio-2 token-to-wav, MiMo Audio Tokenizer, Nemotron VoiceChat Codec)
  • MLXAudioTTS: Text-to-Speech models (Qwen3-TTS, Fish Audio S2 Pro, Soprano, Orpheus, Pocket TTS, and more). Full TTS model list.
  • MLXAudioSTT: Speech-to-Text models (Whisper, Parakeet, Qwen3-ASR, Voxtral Mini, VibeVoice ASR, and more). Full STT model list.
  • MLXAudioVAD: Voice Activity Detection & Speaker Diarization (Sortformer, SmartTurn, FSMN VAD, Silero VAD)
  • MLXAudioSTS: Speech-to-Speech models (LFM2.5-Audio, SAM-Audio, MossFormer2-SE, DeepFilterNet)
  • MLXAudioUI: SwiftUI components for audio interfaces

Installation

Add MLXAudio to your project using Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/Neywa-Labs/mlx-audio-swift.git", branch: "main")
]

// Import only what you need
.product(name: "MLXAudioTTS", package: "mlx-audio-swift"),
.product(name: "MLXAudioCore", package: "mlx-audio-swift")

Quick Start

Text-to-Speech

import MLXAudioTTS
import MLXAudioCore

// Load a TTS model from HuggingFace
let model = try await SopranoModel.fromPretrained("mlx-community/Soprano-80M-bf16")

// Generate audio
let audio = try await model.generate(
    text: "Hello from MLX Audio Swift!",
    parameters: GenerateParameters(
        maxTokens: 200,
        temperature: 0.7,
        topP: 0.95
    )
)

// Save to file
try saveAudioArray(audio, sampleRate: Double(model.sampleRate), to: outputURL)

Speech-to-Text

import MLXAudioSTT
import MLXAudioCore

// Load audio file
let (sampleRate, audioData) = try loadAudioArray(from: audioURL)

// Load STT model
let model = try await GLMASRModel.fromPretrained("mlx-community/GLM-ASR-Nano-2512-4bit")

// Transcribe
let output = model.generate(audio: audioData)
print(output.text)

Speaker Diarization

import MLXAudioVAD
import MLXAudioCore

// Load audio file
let (sampleRate, audioData) = try loadAudioArray(from: audioURL)

// Load diarization model
let model = try await SortformerModel.fromPretrained(
    "mlx-community/diar_streaming_sortformer_4spk-v2.1-fp16"
)

// Detect who is speaking when
let output = try await model.generate(audio: audioData, threshold: 0.5)
for segment in output.segments {
    print("Speaker \(segment.speaker): \(segment.start)s - \(segment.end)s")
}

Streaming Generation

for try await event in model.generateStream(text: text, parameters: parameters) {
    switch event {
    case .token(let token):
        print("Generated token: \(token)")
    case .audio(let audio):
        print("Final audio shape: \(audio.shape)")
    case .info(let info):
        print(info.summary)
    }
}

Supported Models

TTS Models

Model Model README HuggingFace Repo
VibeVoice TTS VibeVoice TTS README microsoft/VibeVoice-1.5B
Voxtral TTS Voxtral TTS README mlx-community/Voxtral-4B-TTS-2603-mlx-4bit, BF16
Maya-2 Native Maya-2 README maya-research/maya2-native
MeloTTS English MeloTTS README mlx-community/MeloTTS-English-MLX
Ming-3.0 TTS Tiny Ming Tiny README mlx-community/Ming-3.0-tts-tiny-4bit
Ming dense TTS Ming dense README mlx-community/Ming-3.0-tts-0.5B-bf16, inclusionAI/Ming-omni-tts-0.5B
Ming Omni 16.8B/A3B Ming Omni README mlx-community/Ming-omni-tts-16.8B-A3B-4bit
KugelAudio KugelAudio README kugelaudio/kugelaudio-0-open
Bark Small Bark README mlx-community/bark-small
Confucius4-TTS Confucius4 README mlx-community/Confucius4-TTS-mlx-int8
Higgs Audio v2 TTS Higgs Audio v2 README mlx-community/higgs-audio-v2-3B-mlx-q8, q6
Higgs Audio v3 TTS Higgs Audio v3 TTS README bosonai/higgs-tts-3-4b
Breeze TTS 2 Breeze TTS 2 README mlx-community/Breeze-TTS-2-mlx-4bit
Qwen3-TTS Qwen3-TTS README mlx-community/Qwen3-TTS-12Hz-0.6B-Base-8bit
OuteTTS OuteTTS README mlx-community/OuteTTS-1.0-0.6B-fp16
OmniVoice OmniVoice README mlx-community/OmniVoice
Audio8 0.1B / 0.6B Audio8 README mlx-community/Audio8-TTS-Preview-0.1b-bf16, mlx-community/Audio8-TTS-Preview-0.6b-bf16, nativ-community/Audio8-TTS-Realistic-0.6b-bf16, 4-bit, 8-bit
Fish Audio S2 Pro Fish Audio S2 Pro README mlx-community/fish-audio-s2-pro-8bit
Soprano Soprano README mlx-community/Soprano-80M-bf16
TADA 1B / 3B TADA README HumeAI/mlx-tada-1b, 3B
VibeVoice Realtime VibeVoice Realtime README mlx-community/VibeVoice-Realtime-0.5B-8bit
VoxCPM 1 / 1.5 VoxCPM README mlx-community/VoxCPM1.5-4bit, fp16, 8-bit
ZONOS2 ZONOS2 README amal-david/Zyphra-ZONOS2-4bit
ZONOS3-Mini ZONOS3 README mlx-community/ZONOS3-Mini
VyvoTTS VyvoTTS README mlx-community/VyvoTTS-EN-Beta-4bit
Orpheus Orpheus README mlx-community/orpheus-3b-0.1-ft-bf16
LongCat-AudioDiT LongCat README mlx-community/LongCat-AudioDiT-1B-bf16, 4-bit, MXFP4
Stable Audio 3 small (text-to-audio) Stable Audio 3 README mlx-community/stable-audio-3-small-sfx, mlx-community/stable-audio-3-small-music
Stable Audio 3 medium (text-to-audio) Stable Audio 3 README mlx-community/stable-audio-3-medium
MOSS-TTS MOSS-TTS README OpenMOSS-Team/MOSS-TTS, OpenMOSS-Team/MOSS-TTSD-v1.0, OpenMOSS-Team/MOSS-TTS-Local-Transformer
IndexTTS — mlx-community/IndexTTS, mlx-community/IndexTTS-1.5
Marvis TTS Marvis TTS README Marvis-AI/marvis-tts-250m-v0.2-MLX-8bit
Pocket TTS Pocket TTS README mlx-community/pocket-tts
Phonon Phonon README Gradium 31M, Gradium 40M
Irodori TTS Irodori TTS README mlx-community/Irodori-TTS-600M-v3-VoiceDesign-8bit, mlx-community/Irodori-TTS-v4.1-Small-8bit, mlx-community/Irodori-TTS-v4.1-Small-MF-8bit
Spark-TTS Spark-TTS README mlx-community/Spark-TTS-0.5B-bf16
rumik-oss 1 Rumik README rumik-ai/rumik-oss-1-mlx-8bit, 4-bit, BF16
Dia Dia README mlx-community/Dia-1.6B

STT Models

Model Model README HuggingFace Repo
Higgs-Audio v3 STT Higgs-Audio STT README bosonai/higgs-audio-v3-stt
Mega-ASR Mega-ASR README mlx-community/Mega-ASR-bf16
Qwen2-Audio Qwen2-Audio README mlx-community/Qwen2-Audio-7B-Instruct-4bit
Qwen3-ASR Qwen3-ASR README mlx-community/Qwen3-ASR-1.7B-bf16
Qwen3-ForcedAligner Qwen3-ASR README mlx-community/Qwen3-ForcedAligner-0.6B-bf16
MOSS-Music MOSS-Music README mlx-community/MOSS-Music-8B-Thinking-4bit
MOSS-Transcribe-Diarize MOSS-Transcribe-Diarize README OpenMOSS-Team/MOSS-Transcribe-Diarize
Ming-3.0 ASR Tiny Ming ASR README mlx-community/Ming-3.0-asr-tiny-4bit
MiMo-V2.5-ASR MiMo ASR README mlx-community/MiMo-V2.5-ASR-MLX
VibeVoice ASR VibeVoice ASR README microsoft/VibeVoice-ASR-Streaming-1.5B
Voxtral Mini Voxtral Mini README mlx-community/Voxtral-Mini-3B-2507-bf16
Voxtral Realtime Voxtral README mlx-community/Voxtral-Mini-4B-Realtime-2602-fp16
Cohere Transcribe Cohere Transcribe README beshkenadze/cohere-transcribe-03-2026-mlx-fp16
Parakeet Parakeet README mlx-community/parakeet-tdt-0.6b-v3
Parakeet Redux Parakeet README moondream/parakeet-redux
Parakeet Ultra Parakeet README moondream/parakeet-ultra
Orukeet Parakeet README oruk/orukeet
Phonon-2 / 2.5 Phonon README Phonon-2.5, Phonon-2.5-English, Phonon-2
Nemotron ASR Nemotron ASR README Nemotron Speech Streaming, Nemotron 3.5 ASR, Nemotron Unified ASR
Nemotron 3.5 Transcribe Nemotron Transcribe README nvidia/NVIDIA-Nemotron-3.5-Transcribe-30B-A4B, MLX 4-bit
SOV-Transcribe-1 SOV-Transcribe README salesforce-sovereign-intelligence/SOV-Transcribe-1, MLX 4-bit
GLMASR GLMASR README mlx-community/GLM-ASR-Nano-2512-4bit
FireRedASR2 FireRedASR2 README Converted FireRedASR2-compatible MLX checkpoints
SenseVoice SenseVoice README Converted SenseVoice-compatible MLX checkpoints
Fun-ASR-Nano Fun-ASR-Nano README mlx-community/Fun-ASR-Nano-2512
Granite Speech Granite Speech README ibm-granite/granite-speech-5.0-2b, ibm-granite/granite-speech-4.1-2b, ibm-granite/granite-speech-4.1-2b-plus
Granite Speech NAR Granite Speech NAR README ibm-granite/granite-speech-4.1-2b-nar
Granite Speech 5.0 TurboCTC TurboCTC README ibm-granite/granite-speech-5.0-470m-turboctc
Whisper Whisper README openai/whisper-large-v3-turbo, mlx-community/whisper-large-v3-turbo, and every other openai/whisper-* / mlx-community/whisper-* size and .en variant
Canary — Mediform/canary-1b-v2-mlx-q8, Canary-compatible MLX/NeMo checkpoints
Moonshine — UsefulSensors/moonshine-tiny, Moonshine-compatible MLX checkpoints
Wav2Vec2 CTC — facebook/wav2vec2-base-960h, Wav2Vec2 CTC-compatible checkpoints
MMS — facebook/mms-1b-fl102, MMS adapter checkpoints

Audio Codecs

Codec Notes HuggingFace Repo
SNAC Neural audio codec with encode/decode support mlx-community/snac_24khz
Encodec Encodec-compatible audio codec runtime Converted Encodec-compatible MLX checkpoints
Vocos Vocoder/codec decode components Converted Vocos-compatible MLX checkpoints
Mimi Mimi encoder/decoder codec used by speech models Mimi-compatible MLX checkpoints
DACVAE DAC-style VAE audio codec Converted DACVAE-compatible MLX checkpoints
Descript DAC Descript DAC-compatible audio codec Descript DAC-compatible checkpoints
Fish S1 DAC Fish Speech S1 audio codec Fish S1 DAC-compatible checkpoints
S3TokenizerV2 S3 acoustic tokenizer exposed in MLXAudioCodecs mlx-community/S3TokenizerV2
MiMo Audio Tokenizer Offline 24 kHz encoder/decoder with 20 RVQ codebooks XiaomiMiMo/MiMo-Audio-Tokenizer
Nemotron VoiceChat Codec 22.05 kHz codec with offline encoding and incremental decoding mlx-community/NemotronLabs-VoiceChat-11B-4bit
MOSS Audio Tokenizer MOSS audio tokenizer runtime shared with MOSS TTS models mlx-community/MOSS-Audio-Tokenizer-Nano
Higgs Audio Tokenizer Higgs acoustic tokenizer decode and acoustic encode support bosonai/higgs-audio-v3-tts-4b bundled tokenizer weights
Step-Audio-2 Token2Wav Token-to-waveform stack for Step-Audio-2 style prompts mlx-community/Step-Audio-2-token2wav

STS Models

Model Model README HuggingFace Repo
LFM2.5-Audio LFM Audio README mlx-community/LFM2.5-Audio-1.5B-6bit
SAM-Audio SAM Audio README mlx-community/sam-audio-large-fp16
MossFormer2-SE — starkdmi/MossFormer2-SE-fp16
DeepFilterNet DeepFilterNet README mlx-community/DeepFilterNet-mlx

VAD / Speaker Diarization Models

Model Model README HuggingFace Repo
Sortformer Sortformer README mlx-community/diar_streaming_sortformer_4spk-v2.1-fp16
SmartTurn SmartTurn README mlx-community/smart-turn-v3
FSMN VAD — mlx-community/fsmn-vad
Silero VAD Silero VAD README Silero VAD-compatible MLX checkpoints

Features

  • Modular architecture for minimal app size - import only what you need
  • Automatic model downloading from HuggingFace Hub
  • Native async/await support for seamless Swift integration
  • Streaming audio generation for real-time TTS
  • Type-safe Swift API with comprehensive error handling
  • Optimized for Apple Silicon with MLX framework

Advanced Usage

Custom Generation Parameters

let parameters = GenerateParameters(
    maxTokens: 1200,
    temperature: 0.7,
    topP: 0.95,
    repetitionPenalty: 1.5,
    repetitionContextSize: 30
)

let audio = try await model.generate(text: "Your text here", parameters: parameters)

Audio Codec Usage

import MLXAudioCodecs

// Load SNAC codec
let snac = try await SNAC.fromPretrained("mlx-community/snac_24khz")

// Encode audio to tokens
let tokens = try snac.encode(audio)

// Decode tokens back to audio
let reconstructed = try snac.decode(tokens)

Voice Selection for Multi-Voice Models

// For models supporting multiple voices (like LlamaTTS/Orpheus)
let audio = try await model.generate(
    text: "Hello!",
    voice: "tara",  // Options: tara, leah, jess, leo, dan, mia, zac, zoe
    parameters: parameters
)

Requirements

  • macOS 14+ or iOS 17+
  • Apple Silicon (M1 or later) recommended for optimal performance
  • Xcode 15+
  • Swift 5.9+

Examples

Phonon Translate is an XcodeGen example for iOS and macOS: type in English, translate into French with a small local language model, and listen with Phonon’s English and French voices.

Check out the Examples/VoicesApp directory for a complete SwiftUI application demonstrating:

  • Loading and running TTS models
  • Playing generated audio
  • UI components for model interaction

Additional usage examples can be found in the test files.

Contributing

See CONTRIBUTING.md for contribution guidelines.

Credits

License

MIT License - see LICENSE file for details.

Ähnliche Projekte entdecken

Wird geladen…