Installation
Add Package Dependency
In Xcode, add the Moonshine Swift package:
- Right-click on the file view sidebar
- Choose “Add Package Dependencies…” from the menu
- Paste
https://github.com/moonshine-ai/moonshine-swift/into the search box - Select moonshine-swift and click “Add Package”
Add Model Files
Download models using Python:Add model files to your Xcode project or reference them from the cache location displayed by the download command.
Quick Start Example
Download and try the pre-built examples:Basic Implementations
Command-Line Tool
Create a simple command-line transcriber:SwiftUI Application
Build a full GUI application:File Transcription Example
Transcribe audio files using Swift:Building with Swift Package Manager
For command-line tools, create aPackage.swift:
Supported Languages
Download and use models for different languages:Performance Considerations
Model Performance on Apple Silicon
| Model | Size | M1 Latency | M2 Latency | Memory |
|---|---|---|---|---|
| Tiny | 26MB | 25ms | 20ms | ~80MB |
| Tiny Streaming | 34MB | 20ms | 15ms | ~90MB |
| Base | 58MB | 35ms | 28ms | ~150MB |
| Small Streaming | 123MB | 55ms | 45ms | ~280MB |
| Medium Streaming | 245MB | 90ms | 75ms | ~500MB |
Optimization Tips
- Use streaming models for real-time applications (lower latency)
- Leverage Apple Silicon - M1/M2 Macs provide excellent performance
- Adjust update interval - Balance between UI updates and CPU usage
- Consider model size - Larger models = better accuracy but more resources
Common Issues
Microphone Permission
Request permission before starting transcription:Model Path Issues
Find models in the download cache:Sandboxing Issues
For sandboxed apps:- Enable Audio Input in App Sandbox capabilities
- Add microphone usage description to Info.plist
- Use App Group for sharing models between apps
Example Projects
The repository includes complete examples:- BasicTranscription - Command-line file transcription
- MicTranscription - GUI app with live microphone transcription
- Located in
examples/macos/
Deployment
Building for Distribution
Notarization
For distribution outside the Mac App Store:- Code sign your app
- Submit for notarization
- Staple the notarization ticket
Next Steps
API Reference
Detailed Swift API documentation
Models
Available models and architectures
iOS Guide
Using Moonshine on iOS
Examples
More macOS examples