Switzerlandmlalma/kokoro-ios
Kokoro TTS for iOS and macOSX
Featured achievements
The project's latest awards
#1 Repository of the month
#2 Repository of the month
#3 Repository of the month
Kokoro TTS for Swift
✨ New in 1.0.8: Added timestamps for each token. Please check Kokoro Test App how to use them.
✨ New in 1.0.5: Voice styles are moved out of the library to the integrating application. Please check Kokoro Test App how to use them.
Kokoro is a high-quality TTS (text-to-speech) model, providing faster than real-time English audio generation.
NOTE: This is a SPM package of the TTS engine. For an application integrating Kokoro and showing how the neural speech synthesis works, please see KokoroTestApp project.
Kokoro TTS port is based on the great work done in MLX-Audio project, where the model was ported from PyTorch to MLX Python. This project ports the MLX Python code to MLX Swift.
Currently the library generates audio ~3.3 times faster than real-time on the release build on iPhone 13 Pro after warm up / first run.
Requirements
- iOS 18.0+
- macOS 15.0+
- (Other Apple platforms may work as well)
Installation
Add KokoroSwift to your project using Swift Package Manager:
dependencies: [
.package(url: "https://github.com/mlalma/kokoro-ios.git", from: "1.0.0")
]
Then add it to your target:
.target(
name: "YourTarget",
dependencies: [
.product(name: "KokoroSwift", package: "kokoro-ios")
]
)
Usage
import KokoroSwift
// Initialize the TTS engine
let modelPath = URL(fileURLWithPath: "path/to/your/model")
let tts = KokoroTTS(modelPath: modelPath, g2p: .misaki)
// Generate speech
let voiceEmbedding = ... // See KokoroTestApp on how to get a voice style as an `MLXArray`
let text = "Hello, this is a test of Kokoro TTS."
let audioBuffer = try tts.generateAudio(voice: voiceEmbedding, language: .enUS, text: text)
// audioBuffer now contains the synthesized speech
G2P (Grapheme-to-Phoneme) Options
.misaki- MisakiSwift, default G2P processor.espeak- eSpeakNG, an alternative G2P processor (commented out in current version)
Model Files
You'll need to provide your own Kokoro TTS model file due to its large size as well as voice style. Please see example project Kokoro Test App how they can be included as a part of the application package.
Dependencies
This package depends on:
- MLX Swift - Apple's MLX framework for Swift
- MisakiSwift - G2P processor
- MLXUtilsLibrary - Utility library
License
This project is licensed under MIT License - see the LICENSE file for details.
Similar Projects
Discover other similar projects and AI models.
A text-to-speech (TTS), speech-to-text (STT) and speech-to-speech (STS) library built on Apple's MLX framework, providing efficient speech analysis on Apple Silicon.
VoiceStudio is the open-source, fully-local ElevenLabs alternative — voice cloning, voice design, video dubbing, dictation, transcription & audiobook creation in 646 languages.
Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Flutter makes it easy and fast to build beautiful apps for mobile and beyond
An open-source framework for making universal native apps with React. Expo runs on Android, iOS, and the web.
Kokoro is an open-weight TTS model with 82 million parameters. Despite its lightweight architecture, it delivers comparable quality to larger models while being significantly faster and more cost-efficient. With Apache-licensed weights, Kokoro can be...
🐸💬 - a deep learning toolkit for Text-to-Speech, battle-tested in research and production
VoxCPM2: Tokenizer-Free TTS for Multilingual Speech Generation, Creative Voice Design, and True-to-Life Cloning