initWhisper(). Controls model loading, GPU acceleration, and Core ML settings.
Properties
Path to the GGML model file or asset require number.Can be:
- Absolute file path:
'/path/to/model.bin' - Asset require:
require('./assets/model.bin') - Bundle asset name (iOS/Android):
'model.bin'withisBundleAsset: true
Core ML model assets configuration. Required when using
require() for the model path and enabling Core ML on iOS.Whether the file path is a bundle asset name (for pure string filePath). Set to
true if the model is bundled in the app’s assets.Prefer to use Core ML model if it exists (iOS only). If set to
false, even if the Core ML model exists, it will not be used.Core ML accelerates the encoder on iOS 15.0+.Use GPU/Metal acceleration if available (iOS only). When enabled, uses Metal for GPU-accelerated inference.If enabled, Core ML option will be ignored.
Use Flash Attention optimization. Only recommended if GPU is available. Can significantly improve performance on supported devices.
Usage Examples
Basic Initialization
Using Asset Require
With GPU Acceleration
With Core ML (iOS)
Bundle Asset (iOS/Android)
Platform Notes
iOS
- Core ML models must be co-located with the GGML model
- Core ML model directory format:
<model-name>-encoder.mlmodelc/ - GPU acceleration uses Metal framework
- Flash Attention requires GPU to be enabled
Android
- GPU acceleration is not currently supported
- Core ML options are ignored on Android
- Use
isBundleAsset: truefor assets inandroid/app/src/main/assets/
Checking GPU Status
Related
- initWhisper() - Initialize a Whisper context
- WhisperContext - The returned context object