A Swift command-line application that demonstrates how to use Moonshine Voice for transcription, mirroring the functionality of the Python basic_transcription.py script.
- Transcribe audio files offline without streaming
- Transcribe audio files with streaming (event-based)
- Support for multiple languages and model architectures
- Command-line argument parsing
cd examples/macos/BasicTranscription
swift buildAn Xcode project is available for building and running from the Xcode IDE:
- Open
BasicTranscription.xcodeprojin Xcode - Select the
BasicTranscriptionscheme - Build and run (⌘R) or use the Product menu
The Xcode project is generated from project.yml using xcodegen. To regenerate it:
cd examples/macos/BasicTranscription
xcodegen generate# Use default test file (test-assets/two_cities.wav)
swift run BasicTranscription
# Specify input files
swift run BasicTranscription path/to/audio1.wav path/to/audio2.wav
# Specify language
swift run BasicTranscription --language en path/to/audio.wav
# Specify model architecture
swift run BasicTranscription --model-arch tiny path/to/audio.wav
# Show help
swift run BasicTranscription --help--language, -l LANGUAGE: Language to use for transcription (default:en)--model-arch, -m ARCH: Model architecture:tiny,base,tiny-streaming,small-streaming,medium-streaming--help, -h: Show help message
en/english- Englishja/japanese- Japanesees/spanish- Spanishar/arabic- Arabicko/korean- Koreanvi/vietnamese- Vietnameseuk/ukrainian- Ukrainianzh/chinese- Chinese
The application will:
- Transcribe each input file offline (non-streaming) and print the results
- Transcribe each input file with streaming, showing events as they occur:
- Line started events
- Line text changed events
- Line completed events
- The application expects model files to be in
test-assets/{model-name}/directory - WAV files must be PCM format (16-bit, 24-bit, or 32-bit)
- Multi-channel audio is automatically mixed down to mono