A Swift version of Marvis TTS, running locally on Apple Silicon using MLX Swift.
- Streaming generation for realtime playback
- Expressive voice presets
- On-device inference
- Simple API
- macOS 14+
- Xcode 15+ / Swift 5.10+
In Xcode you can add https://github.com/Marvis-Labs/marvis-tts-swift.git as a package
dependency.
To use marvis-tts-swift with SwiftPM you can add this to your Package.swift:
dependencies: [
.package(url: "https://github.com/Marvis-Labs/marvis-tts-swift", from: "0.1")
]and add the libraries as dependencies:
dependencies: [.product(name: "MarvisTTS", package: "marvis-tts-swift")]Note
SwiftPM (command line) cannot build the Metal shaders in MLX Swift, so Xcode is required to build.
import MarvisTTS
let model = try await MarvisTTS.fromPretrained { progress in /* optionally show download progress */ }
let player = LocalAudioPlayer(sampleRate: model.sampleRate)
// Stream audio for playback as it's generated.
let text = "With Marvis TTS, you can stream audio generated directly on device, fully locally and privately."
for try await result in model.generate(text: text) {
player.enqueue(samples: $0.audio)
}
player.stop(waitForEnd: true)Note
Using a release build or enabling optimizations will signficantly increase generation performance.
- Language Support: English, French, and German
- Users are responsible for complying with local laws regarding voice synthesis and impersonation
- Consider intellectual property rights when cloning voices of public figures
- Respect privacy laws and regulations in your jurisdiction
- Obtain appropriate consent and permissions before deployment
- Apache 2.0