█

AI/TLDR

Buy me a coffee
Buy me a coffee

Speech Swift

An on-device speech AI toolkit for Mac and iOS — speech recognition, text-to-speech, speech-to-speech, VAD and diarization in native Swift on MLX and CoreML

Audio, Music & VoiceOpen source
Language
Swift
License
Apache-2.0
$brew install speech
IN SHORT

What is Speech Swift?

Speech Swift is an on-device speech AI toolkit for Mac and iOS — speech recognition, text-to-speech, speech-to-speech, VAD and diarization in native Swift on MLX and CoreML. Model weights download from Hugging Face on first use and are cached locally, and every `fromPretrained()` entry point accepts an offline mode once the weights are cached. It sits in the Audio, Music & Voice category of the Multimodal Generation tools and is open-source, written in Swift and licensed Apache-2.0.

Overview

Speech Swift is an open-source toolkit of AI speech models for Apple Silicon, built on MLX Swift and CoreML. It does speech recognition, synthesis and understanding on Mac and iOS entirely on the device — no cloud, no API keys, and no audio leaving the machine. Model weights download from Hugging Face on first use and are cached locally, and every `fromPretrained()` entry point accepts an offline mode once the weights are cached.

It ships as a Swift package where every model is its own SPM library, so an app imports only what it uses: Qwen3-ASR, WhisperASR, Parakeet, Nemotron Streaming and Omnilingual ASR for speech-to-text; Qwen3-TTS, CosyVoice, Kokoro, VibeVoice, Chatterbox and others for text-to-speech and voice cloning; PersonaPlex and VoiceChat for full-duplex speech-to-speech; plus Silero VAD, wake-word spotting, speaker diarization, speaker embeddings, noise suppression, echo cancellation, music source separation, text-to-music and on-device LLM chat and translation. Shared plumbing lives in `AudioCommon` and `MLXCommon`, and a `SpeechUI` module adds SwiftUI views for streaming transcripts.

Beyond the library, the same models are reachable from a `speech` command-line tool installed with Homebrew and from `speech-server`, a local HTTP and WebSocket server that exposes OpenAI-compatible `/v1/realtime` and `/v1/audio/transcriptions` endpoints. A `VoicePipeline` state machine wires any speech recognizer, speech generator and streaming VAD into a real-time ASR → LLM → TTS voice agent with turn detection and interruption handling. It requires Swift 6+, Xcode 16+, and macOS 15+ or iOS 18+ on Apple Silicon, and is licensed Apache 2.0.

What it does

  • One SPM library per model — import `ParakeetStreamingASR`, `Qwen3TTS` or `SpeechVAD` alone and pay for nothing else
  • Speech-to-text across many engines, including streaming dictation with live partials and end-of-utterance detection, forced word-level alignment, and Omnilingual ASR covering 1,672 languages
  • Text-to-speech with streaming, custom speakers and zero-shot voice cloning, from the 82M Kokoro model on the Neural Engine to long-form multi-speaker VibeVoice
  • Full-duplex speech-to-speech (PersonaPlex, VoiceChat) and streaming speech-to-speech translation (Hibiki), plus a `VoicePipeline` for ASR → LLM → TTS voice agents
  • Voice activity detection, end-of-turn detection, wake-word spotting, speaker diarization and speaker embeddings, plus noise suppression, speech restoration and echo cancellation
  • A Homebrew `speech` CLI and a local `speech-server` with OpenAI-compatible Realtime WebSocket and transcription endpoints

Getting started

Use it as a Swift package inside a Mac or iOS app, or install the command-line tool with Homebrew. Both need Apple Silicon with macOS 15+ (or iOS 18+); the Homebrew route requires native ARM Homebrew in /opt/homebrew.

VideoA four-minute tour of the library running on a MacBook: realtime transcription, speech-to-speech and voice cloning.aufklarer ↗

Try it from the command line

Install the CLI with Homebrew, then transcribe, speak or translate. `--engine` picks an alternative model.

bashbash
brew install speech

speech transcribe recording.wav
speech transcribe recording.wav --engine voxtral
speech speak "Hello world"
speech translate "Hello, how are you?" --to es

Add the package to your app

Add the dependency to Package.swift, then list only the model products you need — every model is its own SPM library.

texttext
.package(url: "https://github.com/soniqo/speech-swift", branch: "main")

.product(name: "ParakeetStreamingASR", package: "speech-swift"),
.product(name: "SpeechUI",             package: "speech-swift"),  // optional SwiftUI views

Transcribe audio

Load a model (weights download from Hugging Face on first use) and transcribe a buffer, or iterate a stream to get live partials.

texttext
import ParakeetStreamingASR

let model = try await ParakeetStreamingASRModel.fromPretrained()
let text = try model.transcribeAudio(audioSamples, sampleRate: 16000)

for await partial in model.transcribeStream(audio: samples, sampleRate: 16000) {
    print(partial.isFinal ? "FINAL: \(partial.text)" : "... \(partial.text)")
}

Synthesize speech

Generate audio from text with Qwen3-TTS and write it to a WAV file.

texttext
import Qwen3TTS
import AudioCommon

let model = try await Qwen3TTSModel.fromPretrained()
let audio = model.synthesize(text: "Hello world", language: "english")
try WAVWriter.write(samples: audio, sampleRate: 24000, to: outputURL)

Serve models over HTTP

Run the local server to expose every model over REST and WebSocket, including an OpenAI-compatible Realtime WebSocket at /v1/realtime and a transcription endpoint at /v1/audio/transcriptions.

bashbash
speech-server --port 8080

Build from source

`make build` compiles the Swift package and the MLX Metal shader library, which GPU inference needs — without it you get `Failed to load the default metallib` at runtime.

bashbash
git clone https://github.com/soniqo/speech-swift
cd speech-swift
make build

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Add private, offline dictation or meeting transcription to a macOS or iOS app without sending audio to a cloud API
  • Build a local voice agent on a Mac — VAD-driven turn detection, ASR, an on-device LLM and TTS — or a full-duplex speech-to-speech assistant
VideoThe full-duplex VoiceChat voice agent running locally on a MacBook on the Speech Swift stack.aufklarer ↗
  • Give an app on-device text-to-speech or voice cloning, from a small Neural Engine model on iPhone to long-form multi-speaker audio on a Mac
  • Point existing OpenAI Realtime or transcription clients at a local `speech-server` instead of a hosted endpoint

How Speech Swift compares

Speech Swift alongside other open-source audio, music & voice tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
VoiceStudio★ 121kA local-first desktop voice studio that clones and designs voices, dubs video, and handles dictation, running 16 text-to-speech and 11 speech-recognition engines on your own hardware.
Whisper★ 114kOpenAI's speech recognition model that transcribes and translates audio across many languages.
GPT-SoVITS★ 64.3kAn open-source WebUI that clones a voice from a short audio sample and turns text into speech, with zero-shot and few-shot fine-tuning.
Voicebox★ 61.6kLocal-first voice studio that clones a voice from a short sample, generates speech across seven TTS engines and 23 languages, handles system-wide dictation, and speaks for agents over MCP.
VibeVoice★ 57.6kMicrosoft's text-to-speech model for generating long, expressive multi-speaker audio like podcasts.
whisper.cpp★ 55.7kA dependency-free C/C++ port of Whisper built on ggml, running speech recognition on CPU, Metal, CUDA, Vulkan and NPUs from phones to servers.
Coqui TTS★ 46.3kA library of text-to-speech models including the multilingual XTTS voice-cloning model.
Speech Swift★ 1.3kAn on-device speech AI toolkit for Mac and iOS — speech recognition, text-to-speech, speech-to-speech, VAD and diarization in native Swift on MLX and CoreML