Introducing a new way to review your PRs.

Read the announcement

debpalash / voicestudio

VoiceStudio is the open-source, fully-local ElevenLabs alternative — voice cloning, voice design, video dubbing, dictation, transcription & audiobook creation in 646 languages.

View on GitHub

26 documents · Updated Nov 23, 2026

docs / model-lifecycle

Model catalog and lifecycle

The model catalog and lifecycle system helps VoiceStudio choose approved model assets, install them, keep their local cache usable, and control runtime memory. It connects model metadata with license gates, download state, loading, preload, repair, and unload behavior. It complements Model compute and Engine routing by describing model state rather than request routing.

Model catalog

The model catalog is the reviewed list of model assets that support product features. It tells setup and Settings which assets exist, what each asset does, which hosts support it, and what local files make it usable. The catalog loads from backend/…/models.yaml when the backend starts and is exposed through the setup model service.

Each entry has a catalog identity. Most entries use the Hugging Face repository ID. A package that shares a repository with another entry has its own identity, while Hub access and cache storage still use the shared repository ID. This split keeps install actions, progress, license records, and deletion scoped to the selected product asset.

The catalog makes two host decisions:

  • Supported means the host can run the asset.
  • Curated means the asset is recommended for that host. Required assets remain in the curated set.

The catalog groups assets by product role. The required set stays small so the base speech flow can start without installing every recognition or separation model.

Catalog roles

Catalog propertyProduct meaning
TTSSpeech synthesis or voice cloning asset
ASRSpeech recognition asset for transcription work
DiarisationSpeaker separation asset for multi-speaker media
RequiredNeeded for the base product flow
PlatformsHard support boundary for a host
Curated onRecommended host families
Config-onlyPipeline definition whose weights come from dependencies
Shared repository packageA selected package inside a shared repository

References: backend/…/models.yaml• L1-31 backend/…/model_catalogue.py• L18-69

License review and acceptance

License review separates model information from permission to use a model. The catalog can disclose terms and show the current acceptance state, but neither disclosure nor local acknowledgement grants upstream rights or proves consent for a generated voice.

The system applies separate gates:

  • Hub access checks whether the user can reach a gated repository. It is an explicit access action and does not expose the token.
  • Terms acceptance records acknowledgement for non-commercial, unknown, or unmapped terms. The record is tied to the displayed terms fingerprint, so changed terms require review again.
  • Runtime use checks acceptance before loading the shared TTS model. This check also applies when the model is already resident.

Some engines depend on more repositories than the selected catalog row names. Their acceptance set includes those dependencies when the runtime gate covers them. If the full set cannot be known, the catalog marks it incomplete instead of presenting a partial review as complete.

Installation state

Installation state answers whether the target machine has a usable local copy. It is separate from catalog support: a model can be supported but not installed, or installed but unsupported by the current host. The model view combines catalog data with cache inspection and reports completeness, size, file count, and target identity.

The cache check accepts the normal Hugging Face cache roots and a direct filesystem fallback. A positive byte count is not enough for a weight-bearing model because an interrupted snapshot can contain only configuration or tokenizer files. A complete model needs a plausible weight file or its declared required files. Config-only entries instead require their declared configuration files and complete dependencies.

Shared repositories are checked by package. The selected package's file patterns define its size and completeness, so one package cannot make a sibling package appear installed. Deletion follows the same rule and preserves files still used by the sibling.

The model response is cached briefly to avoid repeated disk scans. Install and delete actions invalidate that cache. Installation status and progress are target-aware; local-only cache and unload actions are not offered for targets that cannot perform them.

References: backend/…/model_catalogue.py• L72-101 backend/…/model_catalogue.py• L129-250 backend/…/download.py• L412-451

Checkpoint identity

Checkpoint identity ties a model choice to the source content that can be loaded. The main TTS checkpoint can be a reviewed Hub repository or an explicit local directory. A bare engine name is not treated as a repository; the resolver falls back to the default reviewed checkpoint instead.

Reviewed Hub checkpoints use a fixed revision rather than a moving branch. The installed revision is remembered so later repair and load actions restore the same model content. Local checkpoints can also carry a bounded file-tree fingerprint. If the files change while the native loader reads them, the fingerprint is discarded rather than attached to bytes that it no longer proves.

References: backend/…/model_manager.py• L2682-2697 backend/…/model_manager.py• L2996-3013 backend/…/model_catalogue.py• L39-69

Download and installation flow

Model installation runs in the background and turns a catalog request into a validated cache snapshot. The local setup route accepts a catalog identity, maps it to its Hub repository and reviewed revision, prevents duplicate writers, and reports progress while the cache changes.

The installation flow follows this sequence:

flowchart TD
    A[User selects a catalog asset] --> B[Resolve catalog identity]
    B --> C[Resolve reviewed repository revision]
    C --> D[Build plan for the asset and dependencies]
    D --> E{Known disk need fits}
    E -->|No| F[Report disk error before transfer]
    E -->|Yes| G[Download or resume cache files]
    D -->|Plan unavailable| G
    G --> H{Transfer succeeds}
    H -->|Retryable network failure| I[Retry or change endpoint]
    I --> G
    H -->|Other failure| F
    H -->|Success| J[Validate snapshot and dependencies]
    J -->|Incomplete| F
    J -->|Complete| K[Remember revision and refresh state]

When the Hub can provide a dry-run plan, the service reports total bytes, cached bytes, remaining bytes, and file counts before transfer. It checks the remaining bytes against free space on the cache volume. If the plan cannot be resolved, the install continues with indeterminate totals instead of rejecting a valid gated or older Hub operation.

The download path can use segmented transfers for whole repositories. A transient transport failure retries the resumable transfer, then falls back to the standard Hub downloader. Integrity, path, authentication, access, disk, cancellation, and validation failures do not become endless network retries. An endpoint change clears the short failure cooldown because it changes the recovery conditions.

Cancellation stops later retries and normally stops transfer at the next chunk or transfer boundary. The worker remains authoritative until it exits, then removes safe partial data that this install added. A repeated install request converges on the active worker instead of starting another cache writer. A settled failure remains visible with a recovery topic and a short retry delay, except when user action such as accepting terms or freeing disk space is the fix.

After transfer, a weight-bearing entry must contain usable weight data. A config-only entry must contain its declared files, and a pipeline entry must also have complete dependencies. A successful install invalidates the catalog cache and can reconcile a saved performance profile without making profile activation part of download success.

Deletion and reinstall are destructive operations. The local flow unloads a resident model before deleting its cache. Shared-repository deletion removes only the selected package files and unreferenced blobs. The repository path is treated as one encoded identity even when the Hub name contains a slash.

References: backend/…/download.py• L209-240 backend/…/download.py• L632-675 backend/…/download.py• L774-975 backend/…/download.py• L979-1158 backend/…/download.py• L1189-1344

Sidecar engine installation

Sidecar installation provisions an engine that cannot share the main application environment because it needs conflicting package versions. The job creates a managed source checkout and its own environment, verifies that the engine imports, downloads any required weights, and then points the engine at the finished install. The managed install stays under the application data directory so it remains separate from user-owned clones.

The sidecar job is resumable and checks the target volume before work starts. It preserves healthy parts of a partial install and keeps the package cache on that volume when the default cache is elsewhere. Existing healthy source, environment, and weight state is reused, while incomplete state is repaired as needed.

flowchart TD
    A[User starts sidecar install] --> B[Check tool and disk space]
    B --> C{Healthy source present}
    C -->|No| D[Fetch reviewed source]
    C -->|Yes| E[Reuse source]
    D --> E
    E --> F{Healthy environment present}
    F -->|No| G[Create environment and install dependencies]
    F -->|Yes| H[Reuse environment]
    G --> I[Verify engine import]
    H --> I
    I --> J{Bundled weights required}
    J -->|No| K[Persist engine path]
    J -->|Yes| L[Resume reviewed weight download]
    L --> M[Validate complete weights]
    M --> K
    K --> N[Engine ready without restart]

The source and weight revisions are reviewed, and the final engine path is stored for the current process and the next launch. A user-managed path is never removed by application uninstall.

References: backend/…/sidecar_install.py• L1-45 backend/…/sidecar_install.py• L91-173 backend/…/sidecar_install.py• L225-304 backend/…/sidecar_install.py• L307-391 backend/…/sidecar_install.py• L422-579 backend/…/sidecar_install.py• L585-638 backend/…/sidecar_install.py• L662-755 backend/…/sidecar_install.py• L823-900 backend/…/sidecar_install.py• L904-1034

Installation progress

Installation progress gives the UI a stable view of background work. It covers resolving, planning, transfer, retry, completion, cancellation, deletion, and error states. It also reports aggregate bytes and file counts so the UI can show progress even when several files transfer in parallel.

The frontend keys progress by target and catalog identity. This prevents two installs of the same repository on different targets from overwriting each other's state. The status endpoint also preserves active jobs and recent failure detail after navigation, while terminal success causes the authoritative model list to refresh.

References: backend/…/download.py• L454-556 backend/…/download.py• L1036-1158

Cache repair

Cache repair restores a model when the Hub snapshot points to missing or damaged local data. It repairs the cache state with the smallest safe change first and keeps the model tied to a reviewed revision.

The repair ladder is:

  1. Find broken snapshot entries such as dangling links or invalid zero-byte model files.
  2. Restore those entries while preserving healthy blobs.
  3. Check weight files before memory mapping and reject truncated safetensors files.
  4. Resume the pinned snapshot to fill missing files.
  5. Force a fresh download when a present file has the right size but cannot be read.
  6. Report delete-and-reinstall when the cache remains unusable.

The repair scan does not hash the whole cache or touch healthy snapshot entries. It does not delete anything in offline mode because a follow-up restore cannot run. If a normal restore recreates broken links, the service retries in copy mode and verifies the result. Repair attempts are bounded per repository and process so one damaged cache cannot trigger repeated large downloads on every request.

The load path keeps related assets separate. A damaged nested audio tokenizer is repaired as its own repository, and a separate ASR preload failure does not trigger a new TTS repair. Local directory checkpoints receive a clear error rather than a Hub repair attempt.

References: backend/…/hf_cache_repair.py• L1-27 backend/…/hf_cache_repair.py• L79-181 backend/…/hf_cache_repair.py• L249-416 backend/…/model_manager.py• L2155-2459 backend/…/model_manager.py• L2778-2882

Model loading and preload

Model loading changes an installed checkpoint into a resident runtime model. The same load boundary serves first-use generation and optional startup preload, so both paths use the same license check, cache repair, memory reclaim, progress, timeout, and shutdown rules.

Only one cold TTS load runs at a time. A caller that waits behind a load adopts the model that finishes instead of starting another native load. A load that times out after entering the native loader may continue to hold memory and the load lock; later callers fail fast with a restart action rather than queueing behind an abandoned load.

Loading status moves through broad stages such as import, weight loading, compilation, ready, and error. Download progress can update the weight stage. Errors are sanitized for the user, while normal backend shutdown is reported as benign cancellation.

Preload is local-first. It loads only when a usable local checkpoint is present and does not turn startup into an unexpected Hub download. TTS and ASR preload are separate choices; ASR preload is opt-in because it adds substantial memory use. A headless worker or a host whose effective runtime uses a different path skips native warm-up and loads on demand.

The load boundary has separate queue and execution budgets. A request that never starts is pool saturation and is safe to retry. A request that starts can be abandoned after its execution limit, but its worker can keep device memory until it finishes or the backend restarts. Fresh progress heartbeats can extend a healthy load within a bounded cap; they cannot keep a silent load alive indefinitely.

References: backend/…/model_manager.py• L2144-2152 backend/…/model_manager.py• L2648-3050 backend/…/model_manager.py• L3075-3384

Memory-aware loading

Memory safeguards reduce the chance that resident models and inference work exhaust system or accelerator memory. The system measures available memory when possible, warns when headroom is low, and releases resources it already owns. It uses estimates as guidance rather than a hard rejection because model size and operating-system reclaim behavior vary.

The safeguards work together:

  • Before a tight cold TTS load, idle capture ASR, TTS side caches, and allocator caches can be released.
  • Before a warm generation, the same cleanup can run when policy detects low system RAM or accelerator memory.
  • On dedicated-memory hosts, TTS can move to CPU while ASR uses the accelerator. On unified-memory hosts, TTS is released because moving it to CPU does not free physical RAM.
  • The next TTS request restores placement when a model remains on CPU after an interrupted offload or sits in RAM after an optional post-generation offload.
  • Idle reapers release the shared TTS model and other idle model resources. A live dictation lease prevents capture ASR from being removed mid-stream.
  • Unload drops model references before side caches and allocator caches are cleared, so the memory becomes reclaimable.

Moves and inference use separate placement control. A move waits for active inference to finish, while a new inference waits for the move and repairs placement before it runs. If a move fails, the model stays on CPU as a slower fallback and the next request can try again.

GPU worker count is based on available accelerator memory with a conservative per-job budget and a small cap. Admission control can reject a request before it enters a backed-up queue and supplies a retry estimate. Queue wait and execution are separate clocks, and a pool reset makes new work possible without claiming that a running timed-out worker has released its memory.

References: backend/…/model_manager.py• L169-215 backend/…/model_manager.py• L3135-3448 backend/…/model_manager.py• L3991-4149 backend/…/model_manager.py• L4213-4469

Loaded model inventory

The loaded-model inventory reports runtime residency rather than download state. It combines the shared TTS and ASR pair with diarisation, sidecar engines, in-process engine instances, alternate TTS, warm dictation ASR, warm transcription ASR, and offline translation. It also records the active TTS-family route so a resident model is not mistaken for the current route.

Each entry identifies its runtime ID, checkpoint or model key, device, memory when available, and unload capability. Runtime IDs and catalog repository IDs are different contracts: the Model Store uses the runtime ID for unload actions, while catalog IDs control installation and cache state. Inventory collection is best-effort, so one unavailable source does not hide the other resident resources.

This diagram shows how the lifecycle facade combines runtime sources into the residency view and routes user unload actions back to the owning resource.

flowchart LR
    A[Loaded-model request] --> B[Lifecycle facade]
    B --> C[Shared TTS and co-loaded ASR]
    B --> D[Diarisation pipeline]
    B --> E[Sidecar engines]
    B --> F[In-process engines]
    B --> G[Capture ASR]
    B --> H[Warm transcription ASR]
    B --> I[Offline translation]
    B --> J[Memory snapshot]
    C --> K[Model Store residency view]
    D --> K
    E --> K
    F --> K
    G --> K
    H --> K
    I --> K
    J --> K
    K --> L[Unload selected releasable entry]

The lifecycle facade routes each unload request to the resource that owns it. A live dictation lease can block capture-ASR unload. Global unload attempts each known releasable resource and returns per-entry results.

References: backend/…/model_lifecycle.py• L1-432 backend/…/system.py• L170-195 backend/…/model_manager.py• L3991-4027 backend/…/model_manager.py• L4076-4149

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the catalog identity, shared repo_id, reviewed revision, selected package files, dependency list, cache scan, and repair path aligned.
  • Keep weight-bearing completeness checks separate from config-only checks. A configuration repository must not be forced to contain a weight file.
  • Keep license disclosure, dependent license rows, terms fingerprints, Hub access, and runtime acceptance as separate contracts.
  • Keep local installation and any worker installation target-aware. Do not let local status overwrite remote status.
  • Keep preflight disk checks tied to the cache volume. An unknown plan must stay indeterminate, while a known shortage must stop before transfer.
  • Keep duplicate-install admission, cancellation, rollback, progress cleanup, failure detail, and cooldown state aligned.
  • Keep segmented-transfer retry separate from integrity and access failures. A failed accelerator must fall back safely without discarding resumable state too early.
  • Keep shared-repository deletion from removing files selected by sibling packages.
  • Keep cache repair pinned to an installed or reviewed revision and preserve healthy blobs and snapshot entries.
  • Keep preload local-only and aligned with the checkpoint resolver, license gate, and effective runtime choice.
  • Keep cold-load reclaim and warm-generation reclaim on the same memory policy.
  • Keep unified-memory release separate from dedicated-device offload.
  • Keep model moves exclusive with inference and tie RAM-offload state to the resident model identity.
  • Keep queue wait, execution timeout, heartbeat extension, pool reset, and abandoned-load behavior distinct.
  • Keep runtime loaded IDs separate from catalog repository IDs and update inventory and unload routing together.

Important failure modes

TriggerConsequenceGuard
A snapshot has config files but no usable weightThe model looks installed but fails at load timeShared completeness checks require plausible weights or declared required files
A shared package is deletedA sibling package loses filesDeletion preserves files and blobs still selected by siblings
A snapshot entry points to a missing blobThe loader reports missing weights despite downloaded dataRepair removes only broken entries and restores them from pinned data
A safetensors file is truncatedMemory mapping can crash the backend outside normal error handlingHeader checks detect it before load and trigger repair
A present weight file cannot be parsedResume repair trusts the bad file and fails againA bounded forced redownload replaces the damaged file
A gated repository lacks access or terms acceptanceInstallation or runtime use stopsAccess and acceptance gates fail closed with an actionable status
The disk plan exceeds free cache spaceA large install fails during transferKnown shortages are rejected before bytes move
The same catalog asset receives two install requestsConcurrent cache writers can corrupt state or progressOne active worker owns the asset and duplicate requests converge
A user cancels during transferPartial cache data can remain or cancellation can be misreported as network failureTransfer observes cancellation, waits for worker exit, and rolls back safe additions
Startup preload queries the HubStartup can begin an unexpected multi-gigabyte downloadPreload checks the local checkpoint only
TTS and ASR share tight unified memoryThe backend can be killed by system memory pressureTTS is released before ASR loads and reloads lazily later
A model move races with inferenceWeights can change device during generationPlacement control makes moves exclusive
A GPU job times out after it startsThe worker can keep holding device memoryThe pool resets for new work and reports that the old worker may still be active
A cold load is abandoned while native loading continuesLater loads can wait behind a stuck loadLater callers fail fast and direct the user to restart the backend
A resident model is unloaded before its side cachesMemory remains held after the UI reports unloadThe shared unload path clears references, side caches, and device caches in order

Key files

FileWhy to read it
backend/…/models.yamlDefines the reviewed model roles, support limits, dependencies, and approximate download data.
backend/…/model_catalogue.pyDefines catalog identity, cache roots, package selection, and completeness state.
backend/…/models.pyShows how catalog data becomes install state, license state, access state, and host recommendations.
backend/…/download.pyShows install planning, disk checks, transfer, retry, cancellation, rollback, validation, and deletion.
backend/…/hf_revisions.pyDefines reviewed checkpoint revisions and installed revision state used by repair.
backend/…/hf_cache_repair.pyShows safe repair of broken snapshot entries and truncated weight files.
backend/…/model_manager.pyDefines checkpoint loading, cache repair, preload, memory reclaim, placement recovery, timeout handling, and unload.
backend/…/model_lifecycle.pyProvides runtime residency and unload behavior for the model inventory.
backend/…/memory_budget.pyDefines available-memory reporting used by loading safeguards.
backend/…/engine_memory.pyDefines the resident-TTS memory policy.
electron/…/model-library.tsxConnects catalog state, installation progress, license actions, residency, unload, delete, and reinstall.
docs/downloading-models.mdGives the user-facing download and network recovery context.
docs/remote-workers.mdExplains how model state differs when a worker is the selected target.