# OmniVoice and private voice cloning

KaziVoice runs canonical OmniVoice locally in a separate offline inference worker.
The live studio exposes nine OmniVoice profiles and a saved-voice workspace at
`/studio#cloning`. Priority markets are Kenya, Nigeria, South Africa, and Ghana.

| Market | OmniVoice languages |
| --- | --- |
| Kenya | Swahili (`sw`), English (`en`) |
| Nigeria | Hausa (`ha`), Yoruba (`yo`), Igbo (`ig`), English (`en`) |
| South Africa | Afrikaans (`af`), Zulu (`zu`), Xhosa (`xh`), English (`en`) |
| Ghana | Twi (`tw`), English (`en`) |

These language profiles do not claim a regional English accent. Ewe and Akan
retain their existing MMS engines. Cloning does not train a model: it conditions
inference on a recording and transcript. Cross-language pronunciation and speaker
similarity require evaluation with native listeners.

## Use the studio

1. Upload WAV, MP3, M4A, FLAC, OGG or WebM (up to 10 MB), or record using the
   microphone. Use one speaker, little noise, and a 3–10 second passage.
2. Name the voice, choose the recording language, enter the exact spoken words,
   and confirm that you own the voice or have permission to use it.
3. Save the voice. Select it, choose an output language, and write a new script
   of up to 1,500 characters. The output language can differ from the reference.
4. Select Fast, Balanced or Studio quality, an audio format and mastering style.
   Generate, listen, and download. Captions are estimated rather than aligned.

The included demo recording is synthetic; it lets you test the flow without
uploading a person's voice. Fast (the default) uses 8 inference steps, Balanced
uses 16, and Studio uses 32. Studio can improve detail but takes substantially
longer on CPU. The legacy API quality `preview` remains an alias for 8 steps.
CPU rendering is queued and can take longer for longer scripts. Keep the page
open while rendering. Server jobs continue if a browser disconnects. Identical
requests reuse private
completed audio immediately, including after an API restart. Duplicate pending
requests share one job. Changing only format or mastering reuses private neural
WAV audio and applies the new encoding/processing without another model run.
Changing text, language, voice or quality requires inference. Reuse is confined
to the same workspace and expires with render retention or deletion.

## Private workspace and storage

The browser creates a random 256-bit workspace access key in localStorage and
sends it in `X-Workspace-Key`. The server stores only its SHA-256 owner digest.
Saved profiles, reference audio and render results require the same key. A
separate browser/profile has a separate workspace. Clearing browser storage
loses access; there is no account recovery or workspace synchronization. If
localStorage is unavailable, access lasts only for the current page session.
Treat the key as a credential. This is browser workspace access, not enterprise
SSO or a multi-user tenant administration system.

When global API-key protection is enabled, clients must also send `X-API-Key`
or Bearer authentication. Private API responses use `Cache-Control: no-store`.
References and SQLite databases are outside static resources, with directories
mode 0700 and files mode 0600. Uploaded references are decoded through FFmpeg
with only local input protocols, checked for duration/silence/nonfinite values,
and converted to mono 24 kHz PCM16 WAV. Original uploads are not retained.
Cached neural WAVs and final audio are
private render files with the same access and deletion rules.

Deleting a saved voice removes its reference/profile and purges its in-memory
worker prompt. Completed render audio remains until queue retention expires;
delete that render separately through the API if needed. A voice cannot be
deleted while its render is queued or running. Queued renders can be cancelled;
running CPU inference is not forcefully interrupted.

New requests default to Fast mode; existing `standard` requests still use
32 steps. Responses include actual `inference_steps`, `quality`, `queue_wait_ms`
and cache status. The studio displays whether audio was reused and distinguishes
queue waiting from generation.

Defaults: 10 voices per workspace, 200 total, 8 waiting jobs and at most 2 active
jobs per workspace. Approximately 20 finished jobs per workspace and 100 across
the app are retained. Interrupted jobs become failed on restart. Run one API
worker with this local SQLite queue; multiple API workers are not supported by
this queue implementation.

## Reproduce the deployed worker

The worker uses a separate Python 3.12 environment to avoid mixing model runtime
dependencies with the API. Reviewed source and weights are pinned:

- Code: https://github.com/k2-fsa/OmniVoice at
  `08be0b4ccbac3e13e374e86fbfead4b4cac343e2` (Apache-2.0).
- Weights: `k2-fsa/OmniVoice` on Hugging Face at
  `c5fdb5ccb189668d56333f77ba2629f4cd7535f4`.
- Dependencies: `omni_worker/requirements.txt`, including CPU torch/torchaudio
  2.8.0 and transformers 5.11.0.
- Model assets: about 3.2 GB including the audio tokenizer.

For the deployment paths in the included systemd unit:

```sh
python3.12 -m venv /home/boxd/.venv-omnivoice
/home/boxd/.venv-omnivoice/bin/pip install -r omni_worker/requirements.txt \
  --extra-index-url https://download.pytorch.org/whl/cpu
```

Place the reviewed OmniVoice source at `/home/boxd/OmniVoice-runtime-review` and
all pinned model/tokenizer assets at `/home/boxd/voicellm/var/omni/model`. Preserve
upstream licenses. Review source before executing it; download assets with the
operator's normal trusted tooling, then use the worker offline. The main weights
are `model.safetensors`; audio tokenizer assets remain in `audio_tokenizer/` and
text tokenizer files (`tokenizer.json`, `tokenizer_config.json`) in the model root.
No ASR model is loaded because the user
supplies the reference transcript.

```sh
install -d -m 700 var/clones var/omni
sudo install -m 644 systemd/voicellm-omni.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now voicellm-omni.service
curl --unix-socket var/omni/worker.sock http://localhost/health
```

Wait for `status: ready`, then set `VOICELLM_OMNI_ENABLED=true` in the API's
configuration and restart its service. For other paths, adjust the unit's
WorkingDirectory, ExecStart, PYTHONPATH, model/reference paths and bind mounts,
along with `VOICELLM_OMNI_SOCKET` and `VOICELLM_CLONE_STORAGE_DIR` in the API.
The worker and API must share access to the socket and private references.

The deployed worker uses three CPU threads, bfloat16 model weights and SDPA on
an AVX512 BF16 host. CPU capabilities affect speed and compatibility. Its unit
has `PrivateNetwork=yes`, a private `/tmp`, restricted filesystem bindings,
no visible user credentials, and no runtime downloads. It serializes inference
and retains up to eight voice prompts in memory. Status comes from the worker,
not simply from the presence of configured profiles.

## API example

Use a cryptographically random 64-character lowercase hexadecimal workspace key.
Do not put it in URLs or logs. The endpoints also honor global API authentication.

```sh
# Set VOICE_WORKSPACE_KEY securely in your client environment first.
curl -X POST http://localhost:8050/api/v1/clones \
  -H "X-Workspace-Key: $VOICE_WORKSPACE_KEY" \
  -F 'name=My voice' -F 'reference_language=en' \
  -F 'transcript=The exact words from my recording.' \
  -F 'permission_confirmed=true' -F 'reference=@reference.wav'
```

Submit a JSON render to `POST /api/v1/omni/jobs` with `text`, the returned
`voice_id`, `language_code`, `quality` (`fast`, `balanced`, `standard`, or legacy `preview`), `audio_format`
and `mastering_profile`. Built-in OmniVoice IDs such as `omni_sw` work here too,
with a matching language. Poll `GET /api/v1/omni/jobs/{id}` using the workspace
header. A completed response includes the normal audio/caption result, a
`voice_name`, and a playable `audio_base64` data URL.

- `GET /api/v1/omni/status`: worker readiness and languages.
- `GET /api/v1/clones`: workspace voices.
- `GET /api/v1/clones/{id}/reference`: private normalized reference WAV.
- `DELETE /api/v1/clones/{id}`: delete saved reference/profile and prompt.
- `GET /api/v1/omni/jobs`: recent workspace render metadata.
- `DELETE /api/v1/omni/jobs/{id}`: cancel a queued job or delete a finished result.

## Model terms and validation

OmniVoice code is Apache-2.0, but the pretrained weights have non-commercial
terms. The audio tokenizer uses Boson Higgs Audio 2 community terms incorporating
Meta Llama 3 terms. The application license does not grant commercial rights to
these models. Review the upstream model card and agreements for your intended
use. Credits and copies of the tokenizer and Meta agreements are available at
`/resources#omni-credits` and in `voicellm/web/static/resources/`.

Real CPU checks produced unconditioned speech, new English speech conditioned
on a synthetic reference, and Swahili speech from that same English reference.
Automated tests cover reference validation, permission checks, workspace
isolation, quotas, rendering, deletion and private response headers. These
checks do not establish accent authenticity, speaker similarity scores or
production throughput.
