flutter_whisper_kit_apple 0.3.0

SDKflutter
Platformiosmacos

iOS and macOS implementation of the flutter_whisper_kit plugin, providing on-device speech recognition and transcription capabilities using WhisperKit.

flutter_whisper_kit_apple

A common Apple platform implementation for the flutter_whisper_kit plugin.

Usage

This package provides the iOS and macOS platform-specific implementation for the flutter_whisper_kit plugin. It is not intended for direct use by application developers.

Platform-specific implementations are registered automatically and used by the main flutter_whisper_kit package. You do not need to interact with this package directly.

🧠 DeepWiki

Platform Support

This package specifically supports:

PlatformMinimum Version
iOS16.0+
macOS13.0+

Implementation Details

Flutter WhisperKit Apple provides the native implementation that connects Flutter applications to Apple's WhisperKit framework. It handles:

  1. Native integration with WhisperKit for iOS and macOS
  2. Model downloading and management
  3. Audio processing and transcription
  4. Real-time streaming of transcription results
  5. Platform-specific optimizations

Architecture

The implementation uses:

  • Swift for native code
  • Pigeon for type-safe communication between Flutter and native code
  • CoreML for optimized model inference
  • AVFoundation for audio capture and processing

For Plugin Developers

If you're working on extending or maintaining this plugin:

Key Components

  1. FlutterWhisperKitApplePlugin: Main plugin class that registers with the Flutter engine
  2. WhisperKitApiImpl: Implementation of the Pigeon-generated interface
  3. TranscriptionStreamHandler: Manages streaming transcription results back to Flutter

Native Implementation

The native implementation:

  1. Configures WhisperKit with compute options
  2. Manages model downloading and storage
  3. Handles audio file transcription
  4. Processes real-time audio from the microphone
  5. Streams transcription results back to Flutter

Error Codes

The plugin uses the following error code system to report errors:

Error CodeCategoryDescription
1000-1999Model Initialization and LoadingErrors related to model initialization and loading
1001Model InitializationModel variant is required
1002Model InitializationFailed to initialize WhisperKit
1003Model LoadingFailed to get model folder
1005Model LoadingFailed to download model
2000-2999Transcription and ProcessingErrors related to audio transcription and processing
2001TranscriptionWhisperKit instance not initialized. Call loadModel first
2002TranscriptionFailed to serialize transcription result
2003TranscriptionFailed to create JSON string from transcription result
2004TranscriptionTranscription result is nil
3000-3999Recording and Audio CaptureErrors related to recording functionality
3001RecordingWhisperKit instance not initialized. Call loadModel first
3002RecordingMicrophone access was not granted
3003RecordingNot enough audio data for transcription
4000-4999File System and PermissionsErrors related to file access and permissions
4001File SystemCannot write to model directory
4002File SystemAudio file does not exist at specified path
4003File SystemNo read permission for audio file at specified path
5000-5999Configuration and ParametersErrors related to configuration and input parameters
5001ParametersFile path is required

References