Skip to main content
This module provides utilities for working with model paths in asset bundles, file systems, and Play Asset Delivery.

assetModelPath()

Create a model path configuration for models bundled in your app’s assets.

Parameters

string
required
Path relative to assets directory (e.g., "models/sherpa-onnx-whisper-tiny").

Returns

object
Model path configuration with type 'asset'.

Example


fileModelPath()

Create a model path configuration for models in the file system.

Parameters

string
required
Absolute path to model directory. On iOS, use an absolute path from react-native-fs:

Returns

object
Model path configuration with type 'file'.

Example


autoModelPath()

Create a model path configuration with automatic path type detection.
Tries asset path first, then falls back to file system path.

Parameters

string
required
Path to check (will be tried as both asset and file path).

Returns

object
Model path configuration with type 'auto'.

Example


resolveModelPath()

Resolve a model path configuration to a platform-specific absolute path.
This handles different path types (asset, file, auto) and returns an absolute path that can be used by native code.

Parameters

ModelPathConfig
required
Model path configuration from assetModelPath(), fileModelPath(), or autoModelPath().

Returns

string
Absolute path usable by native code.

Example


listAssetModels()

List all model folders in the assets/models directory.
Scans the platform-specific model directory and returns folder names with type hints.

Returns

array
Array of model information objects.

Example


listModelsAtPath()

List model folders under a specific filesystem path.

Parameters

string
required
Absolute filesystem path to scan for models.
boolean
default:false
When true, returns relative folder paths under the base path recursively.

Returns

array
Array of model information objects (see listAssetModels()).

Example


getAssetPackPath()

Android Only: Get the path to models directory inside an Android asset pack delivered via Play Asset Delivery (PAD).

Parameters

string
required
Name of the asset pack (e.g., "sherpa_models").

Returns

string | null
Path to the models directory in the asset pack, or null if the pack is not available.

Platform Support

  • Android: Full support with Play Asset Delivery
  • iOS: Always returns null

Example


getDefaultModelPath()

Get the default model directory path for the current platform.
Returns a logical name (not an absolute path). On iOS, use absolute paths with react-native-fs instead.

Returns

string
  • iOS: "Documents/models"
  • Android: "models"

Example


Types

ModelPathConfig

Model path configuration discriminated union.
'asset' | 'file' | 'auto'
required
  • 'asset': Model is bundled in app assets
  • 'file': Model is in file system (absolute path)
  • 'auto': Automatically detect (tries asset first, then file)
string
required
Path to the model directory.

See Also