Path Configuration Functions
assetModelPath()
Create a model path configuration for bundled asset models.Path relative to assets directory (e.g.,
"models/sherpa-onnx-model")Configuration object with
type: 'asset' and the specified pathfileModelPath()
Create a model path configuration for file system models.Absolute path to model directory. On iOS, use absolute paths from react-native-fs (e.g.,
DocumentDirectoryPath + '/models/' + modelName)Configuration object with
type: 'file' and the specified pathautoModelPath()
Create a model path configuration with automatic path type detection.Path to check (tries asset first, then file system)
Configuration object with
type: 'auto' and the specified pathresolveModelPath()
Resolve a model path configuration to a platform-specific absolute path.Model path configuration (from
assetModelPath(), fileModelPath(), or autoModelPath())Absolute path usable by native code
Directory Management
getDefaultModelPath()
Get the default model directory path for the current platform.Platform-specific default path:
- iOS:
'Documents/models' - Android:
'models'
This returns a logical name, not an absolute path. On iOS, pass an absolute base path to
fileModelPath() instead (e.g., DocumentDirectoryPath + '/models' from react-native-fs).getPlayAssetDeliveryModelsPath()
Get the path to models in an Android Play Asset Delivery pack.Name of the asset pack (e.g.,
"sherpa_models")Path to the models directory inside the pack, or
null if pack is not available or on iOSThis function is Android-only and requires Play Asset Delivery configuration. Returns
null on iOS.getAssetPackPath()
Get the absolute path to a Play Asset Delivery asset pack (Android only).Name of the asset pack module (defined in
build.gradle)Absolute path to the asset pack directory, or
null if not available (iOS or pack not installed)This function is an alias for
getPlayAssetDeliveryModelsPath(). Both functions are identical.- Play Asset Delivery Guide - Complete PAD setup
- getPlayAssetDeliveryModelsPath() - Alias function
Model Discovery
listAssetModels()
List all model folders in the bundled assets/models directory.Array of model info objects:
folder: Model folder namehint: Detected model type hint
listModelsAtPath()
List model folders under a specific filesystem path.Filesystem path to search
When
true, returns relative folder paths under the base pathArray of model info objects:
folder: Model folder name (relative ifrecursive: true)hint: Detected model type hint
Type Definitions
ModelPathConfig
Model path configuration type:Platform Considerations
iOS
- Asset models are loaded from the app bundle
- Use absolute paths with
DocumentDirectoryPathfor file models - Play Asset Delivery is not supported (returns
null)
Android
- Asset models are loaded from the APK assets folder
- Supports Play Asset Delivery for on-demand model downloads
- File models use internal storage by default
Best Practices
-
Use
assetModelPath()for bundled models: Keep small models in your app bundle for instant availability -
Use
fileModelPath()for downloaded models: Large models should be downloaded at runtime to reduce app size -
Use
autoModelPath()for flexible deployment: Let the SDK automatically detect whether a model is bundled or downloaded - Combine with model download manager: Use the download manager for large model distribution
-
Handle platform differences: Use
Platform.OSchecks when dealing with absolute paths
Related APIs
- TTS API - Text-to-speech engine
- STT API - Speech-to-text recognition
- Download Manager - Model download and management