Skip to main content
The useModelManagement hook provides a complete interface for managing Whisper, Parakeet, and Soniox speech recognition models.

Import

Usage

Options

string
default:"main"
Window ID for event coordination (ensures events are only processed once)
boolean
default:"true"
Display toast notifications for downloads, errors, etc.
Example:

Return Values

models

Type: Record<string, ModelInfo> Object mapping model names to their information. ModelInfo Interface:
Usage:

modelOrder

Type: string[] Array of model names sorted by accuracy score (highest to lowest). Usage:

downloadProgress

Type: Record<string, number> Object mapping model names to download progress (0-100). Usage:

verifyingModels

Type: Set<string> Set of model names currently being verified after download. Usage:

isLoading

Type: boolean Whether the initial model list is loading. Usage:

Actions

loadModels

Type: () => Promise<ModelInfo[]> Refresh the model list from the backend. Usage:

downloadModel

Type: (modelName: string) => Promise<void> Start downloading a model. Parameters:
string
required
Model to download (e.g., "base.en", "parakeet-1.0")
Usage:
Behavior:
  1. Checks if model is already downloading (prevents duplicates)
  2. Sets initial progress to 0
  3. Invokes download_model command (non-blocking)
  4. Progress updates come via download-progress events
  5. Completion triggers model-downloaded event and reloads model list
Cloud Models: Attempting to download a cloud model (e.g., Soniox) shows an info toast.

cancelDownload

Type: (modelName: string) => Promise<void> Cancel an in-progress download. Parameters:
string
required
Model to cancel
Usage:

deleteModel

Type: (modelName: string) => Promise<void> Delete a downloaded model with confirmation dialog. Parameters:
string
required
Model to delete
Usage:
Behavior:
  1. Shows confirmation dialog (“Are you sure…?”)
  2. If confirmed, invokes delete_model command
  3. Refreshes model list on success
Cloud Models: Attempting to delete a cloud model shows an info toast.

Utilities

sortedModels

Type: [string, ModelInfo][] Array of [modelName, modelInfo] tuples sorted by accuracy. Usage:

sortModels (exported function)

Type: (models: [string, ModelInfo][], sortBy: SortCriteria) => [string, ModelInfo][]
Sort models by different criteria. Usage:

Events Handled

The hook automatically subscribes to these backend events:

download-progress

Payload:
Behavior: Updates downloadProgress[model] with latest percentage.

model-verifying

Payload:
Behavior:
  1. Sets progress to 100%
  2. Adds model to verifyingModels set
  3. Removes from downloadProgress after 500ms

model-downloaded

Payload:
Behavior:
  1. Removes from downloadProgress and verifyingModels
  2. Refreshes model list
  3. Shows success toast (if enabled)

download-cancelled

Payload:
Behavior:
  1. Removes from downloadProgress
  2. Shows info toast (if enabled)

Component Examples

Model Download Card


Filtered Model List


TypeScript Types


See Also