Skip to main content

detectSttModel

Detect STT (Speech-to-Text) model type and structure without initializing the recognizer. Uses the same native file-based detection as initializeStt. Useful to show model-specific options before initialization or to query the type for a given path.
function detectSttModel(
  modelDir: string,
  preferInt8?: boolean,
  modelType?: string
): Promise<{
  success: boolean;
  detectedModels: Array<{ type: string; modelDir: string }>;
  modelType?: string;
}>

Parameters

modelDir
string
required
Absolute path to model directory. Use resolveModelPath() first for asset/file paths.
preferInt8
boolean
  • true: prefer int8 models
  • false: prefer regular models
  • undefined: try int8 first (default)
modelType
string
Explicit model type or 'auto' (default). Supported types:
  • 'transducer'
  • 'nemo_transducer'
  • 'paraformer'
  • 'nemo_ctc'
  • 'wenet_ctc'
  • 'sense_voice'
  • 'zipformer_ctc'
  • 'whisper'
  • 'funasr_nano'
  • 'fire_red_asr'
  • 'moonshine'
  • 'dolphin'
  • 'canary'
  • 'omnilingual'
  • 'medasr'
  • 'telespeech_ctc'
  • 'auto'

Returns

success
boolean
Whether detection succeeded
detectedModels
Array<{ type: string; modelDir: string }>
Array of detected model configurations, each containing:
  • type: Model type (e.g., 'transducer', 'whisper')
  • modelDir: Path to the model directory
modelType
string
Primary detected model type (same as first entry in detectedModels)

detectTtsModel

Detect TTS (Text-to-Speech) model type and structure without initializing the engine. Uses the same native file-based detection as initializeTts.
function detectTtsModel(
  modelDir: string,
  modelType?: string
): Promise<{
  success: boolean;
  detectedModels: Array<{ type: string; modelDir: string }>;
  modelType?: string;
}>

Parameters

modelDir
string
required
Absolute path to model directory. Use resolveModelPath() first for asset/file paths.
modelType
string
Explicit model type or 'auto' (default). Supported types:
  • 'vits'
  • 'matcha'
  • 'kokoro'
  • 'kitten'
  • 'pocket'
  • 'zipvoice'
  • 'auto'

Returns

success
boolean
Whether detection succeeded
detectedModels
Array<{ type: string; modelDir: string }>
Array of detected model configurations, each containing:
  • type: Model type (e.g., 'vits', 'matcha')
  • modelDir: Path to the model directory
modelType
string
Primary detected model type (same as first entry in detectedModels)

listAssetModels

List all model folders in the assets/models directory. Scans the platform-specific model directory and returns folder names with type hints.
function listAssetModels(): Promise<
  Array<{ folder: string; hint: 'stt' | 'tts' | 'unknown' }>
>

Returns

models
Array<{ folder: string; hint: 'stt' | 'tts' | 'unknown' }>
Array of model info objects found in assets/models/ (Android) or bundle models/ (iOS):
  • folder: Model directory name
  • hint: Type hint based on folder name ('stt', 'tts', or 'unknown')
This function is useful for discovering models at runtime without hardcoding paths. The hint field is based on folder naming conventions and may not be 100% accurate - use detectSttModel() or detectTtsModel() for definitive detection.

listModelsAtPath

List model folders under a specific filesystem path. When recursive is true, returns relative folder paths under the base path.
function listModelsAtPath(
  path: string,
  recursive?: boolean
): Promise<Array<{ folder: string; hint: 'stt' | 'tts' | 'unknown' }>>

Parameters

path
string
required
Absolute filesystem path to scan for models
recursive
boolean
default:false
When true, scans subdirectories recursively and returns relative paths

Returns

models
Array<{ folder: string; hint: 'stt' | 'tts' | 'unknown' }>
Array of model info objects:
  • folder: Model directory name (or relative path if recursive)
  • hint: Type hint based on folder name ('stt', 'tts', or 'unknown')
Use this function to scan downloaded models in the filesystem, such as models downloaded to the Documents directory on iOS or internal storage on Android.

Build docs developers (and LLMs) love