Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Integrate WhisperKit and Enhance Swama CLI and Server
Summary
This PR integrates WhisperKit for local speech recognition, adds comprehensive CLI transcription support, and extends the server API to include audio transcription endpoints. All changes maintain high code quality with proper error handling and performance optimizations.
Key Changes
WhisperKit Integration
WhisperKitRunnerwith clean audio validation and transcriptionModelPoolCLI Enhancements
transcribecommand with flexible options (model, language, format, temperature, prompt)pullcommand to support WhisperKit modelsServer API Extension
/v1/audio/transcriptionsendpoint with OpenAI-compatible interfaceModel Management
Files Changed
Core Package Files
swama/Package.swift- Added WhisperKit dependencyswama/Package.resolved- Updated dependenciesCLI Commands
swama/Sources/Swama/CLI/Command.swift- Registered Transcribe subcommandswama/Sources/Swama/CLI/Pull.swift- Enhanced to support WhisperKit modelsswama/Sources/Swama/CLI/Transcribe.swift- New transcription CLI commandModel Management
swama/Sources/SwamaKit/Model/ModelAliases.swift- Added WhisperKit aliasesswama/Sources/SwamaKit/Model/ModelDownloader.swift- WhisperKit download supportswama/Sources/SwamaKit/Model/ModelPool.swift- WhisperKit caching and concurrencyswama/Sources/SwamaKit/Model/WhisperKitRunner.swift- New WhisperKit runnerServer Components
swama/Sources/SwamaKit/Server/HTTPHandler.swift- Added transcription endpointswama/Sources/SwamaKit/Server/TranscriptionsHandler.swift- New transcription API handlerTesting
Usage Examples
CLI Transcription
Model Download
# Download WhisperKit models swama pull whisper-base swama pull whisper-small swama pull whisper-largeServer API
Backward Compatibility
This PR maintains full backward compatibility with existing CLI commands and server endpoints. All existing functionality continues to work as expected.