small tiny fixes
Browse files- DOCS.md +80 -57
- README.md +9 -9
- benchmark.md +2 -0
- benchmarking.md +3 -3
- creative-bench/runs/tensorwars.md +2 -0
- results.md +6 -6
- vlib/cmds_misc.py +50 -26
- vlib/cmds_voices.py +94 -23
- vlib/compute.py +74 -37
- vlib/ctx.py +2 -1
- vlib/delta.py +23 -13
- vlib/fetch.py +3 -1
- vlib/registry.py +5 -4
- vlib/reports.py +41 -23
- vlib/ui.py +15 -1
- voice-cli.tar.gz +2 -2
- voice.py +39 -27
- voice.pyz +2 -2
DOCS.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# voice — Help
|
| 2 |
|
| 3 |
-
Generated from `voice --help` and `voice <cmd> --help` (v3.0, 12 commands).
|
| 4 |
|
| 5 |
## voice --help
|
| 6 |
|
|
@@ -30,10 +30,12 @@ positional arguments:
|
|
| 30 |
|
| 31 |
options:
|
| 32 |
-h, --help show this help message and exit
|
| 33 |
-
-v, --verbose
|
| 34 |
-
--non-interactive
|
| 35 |
-
|
|
|
|
| 36 |
--completion {bash,zsh,fish}
|
|
|
|
| 37 |
```
|
| 38 |
|
| 39 |
## voice get
|
|
@@ -49,13 +51,14 @@ positional arguments:
|
|
| 49 |
|
| 50 |
options:
|
| 51 |
-h, --help show this help message and exit
|
| 52 |
-
-q, --quiet
|
| 53 |
-
|
| 54 |
-
--
|
| 55 |
-
|
|
|
|
| 56 |
--out OUT Write a standalone file instead of a registry voice (default
|
| 57 |
pack name: voicepack.safetensors)
|
| 58 |
-
--yes
|
| 59 |
```
|
| 60 |
|
| 61 |
Names: letters, numbers, hyphens, underscores — no spaces, `/`, `\`, dots,
|
|
@@ -68,7 +71,7 @@ slugified from the source (`./my model.gguf` → `my-model`); an explicit
|
|
| 68 |
|
| 69 |
```text
|
| 70 |
usage: voice cast [-h] [--out OUT] [--yes] [--quant QUANT]
|
| 71 |
-
[--exclude EXCLUDES] [--speak]
|
| 72 |
target voice [tensors ...]
|
| 73 |
|
| 74 |
positional arguments:
|
|
@@ -79,14 +82,20 @@ positional arguments:
|
|
| 79 |
|
| 80 |
options:
|
| 81 |
-h, --help show this help message and exit
|
| 82 |
-
--out OUT Output file (default:
|
| 83 |
-
~/Voiced/<voice>-<model>/<voice>-<model>.
|
| 84 |
-
|
|
|
|
| 85 |
--quant QUANT Output quant override: keep (default, preserve quality)
|
| 86 |
| target | any quant
|
| 87 |
-
(q8_0,q4_0,q4_k,q6_k,iq4_nl,f16,f32,bf16,...
|
| 88 |
-
|
| 89 |
-
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
```
|
| 91 |
Philosophy: preserve quality, avoid dequant→quant cycles. Safetensors high-fidelity
|
| 92 |
lm_head is quantized once to Q8_0 (Q4 saves little: Q8_0 1.062 vs Q4_0 0.562 B/param).
|
|
@@ -104,15 +113,17 @@ with a warning. BF16 math uses round-to-nearest-even, not truncation.
|
|
| 104 |
## voice delta
|
| 105 |
|
| 106 |
```text
|
| 107 |
-
usage: voice delta [-h] [--base BASE] [--yes] [voicename]
|
| 108 |
|
| 109 |
positional arguments:
|
| 110 |
-
voicename
|
| 111 |
|
| 112 |
options:
|
| 113 |
-h, --help show this help message and exit
|
| 114 |
--base BASE Base HF repo (org/model) or local path to base safetensors
|
| 115 |
-
--yes
|
|
|
|
|
|
|
| 116 |
```
|
| 117 |
|
| 118 |
Niche cases need typed confirmation: delta-as-base asks `UNDO THE UNDO`,
|
|
@@ -123,7 +134,7 @@ re-run on a TTY to confirm.
|
|
| 123 |
## voice add
|
| 124 |
|
| 125 |
```text
|
| 126 |
-
usage: voice add [-h] [--name NAME] [--yes] safetensors json
|
| 127 |
|
| 128 |
positional arguments:
|
| 129 |
safetensors Path to voice.safetensors (required)
|
|
@@ -133,115 +144,127 @@ options:
|
|
| 133 |
-h, --help show this help message and exit
|
| 134 |
--name NAME Voice name to save (default from voice.json)
|
| 135 |
--yes Auto-confirm overwrite
|
|
|
|
|
|
|
| 136 |
```
|
| 137 |
|
| 138 |
The tensor is copied and validated before `voice.json` is written, so an
|
| 139 |
invalid source adds nothing and never leaves metadata pointing at a partial file.
|
| 140 |
|
| 141 |
## voice list
|
| 142 |
-
|
| 143 |
```text
|
| 144 |
-
usage: voice list [-h] [--base] [
|
| 145 |
|
| 146 |
positional arguments:
|
| 147 |
-
|
| 148 |
|
| 149 |
options:
|
| 150 |
-
-h, --help
|
| 151 |
-
--base
|
|
|
|
|
|
|
| 152 |
```
|
| 153 |
|
| 154 |
## voice info
|
| 155 |
|
| 156 |
```text
|
| 157 |
-
usage: voice info [-h] voicename
|
| 158 |
|
| 159 |
positional arguments:
|
| 160 |
-
voicename
|
| 161 |
|
| 162 |
options:
|
| 163 |
-
-h, --help
|
|
|
|
|
|
|
| 164 |
```
|
| 165 |
-
|
| 166 |
## voice remove
|
| 167 |
-
|
| 168 |
```text
|
| 169 |
-
usage: voice remove [-h] [--yes] voice
|
| 170 |
|
| 171 |
positional arguments:
|
| 172 |
-
voice
|
| 173 |
|
| 174 |
options:
|
| 175 |
-
-h, --help
|
| 176 |
-
--yes
|
|
|
|
|
|
|
| 177 |
```
|
| 178 |
|
| 179 |
## voice cleanup
|
| 180 |
|
| 181 |
```text
|
| 182 |
-
usage: voice cleanup [-h] [--force]
|
| 183 |
|
| 184 |
options:
|
| 185 |
-
-h, --help
|
| 186 |
-
--force
|
|
|
|
|
|
|
| 187 |
```
|
| 188 |
|
| 189 |
## voice auth
|
| 190 |
|
| 191 |
```text
|
| 192 |
-
usage: voice auth [-h] [--clear] [--show]
|
| 193 |
|
| 194 |
options:
|
| 195 |
-
-h, --help
|
| 196 |
-
--clear
|
| 197 |
-
--show
|
|
|
|
|
|
|
| 198 |
```
|
| 199 |
|
| 200 |
## voice report
|
| 201 |
|
| 202 |
```text
|
| 203 |
usage: voice report [-h] [--message MESSAGE] [--voice VOICE] [--target TARGET]
|
| 204 |
-
[--reporter REPORTER] [--yes] [--no-push] [--sync]
|
| 205 |
-
|
| 206 |
-
Save a report locally and optionally share to community (Wiself/voice-reports)
|
| 207 |
-
|
| 208 |
-
positional arguments:
|
| 209 |
-
--message, -m MESSAGE
|
| 210 |
-
Freeform note (240ch, sanitized, CSV-injection safe)
|
| 211 |
-
--voice VOICE Voice name context
|
| 212 |
-
--target TARGET Target file basename context (no PII path)
|
| 213 |
-
--reporter REPORTER Reporter id (optional, 64ch sanitized)
|
| 214 |
|
| 215 |
options:
|
| 216 |
-h, --help show this help message and exit
|
| 217 |
-
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
--no-push Local only, skip share prompt
|
| 219 |
--sync Sync pending outbox to community
|
|
|
|
|
|
|
|
|
|
| 220 |
|
| 221 |
After local save (private `~/.voices/reports.jsonl`), shows preview:
|
| 222 |
Will share: voice: styletune-v2, tensor: lm_head.weight [262144,2816] BF16, target: model.gguf
|
| 223 |
Leave a breadcrumb to help the next person? [y/N] (N): ← Enter = No, one try
|
| 224 |
Non-interactive skips unless --yes. Local: outbox at `~/.voices/outbox/<id>.json`.
|
| 225 |
Remote: `Wiself/voice-reports` `data/reports-YYYY-MM.jsonl`, batched, dedup `report_id`.
|
| 226 |
-
Footnote: local uses `flock` + `fsync` + `mkstemp 0600`; crowd writes via PR (no write needed); direct push racy but dedup softens; 3 retries `429/409/412`; `doctor` shows pending.
|
| 227 |
```
|
| 228 |
|
| 229 |
## voice path
|
| 230 |
|
| 231 |
```text
|
| 232 |
-
usage: voice path [-h]
|
| 233 |
|
| 234 |
options:
|
| 235 |
-
-h, --help
|
|
|
|
|
|
|
| 236 |
```
|
| 237 |
|
| 238 |
## voice doctor
|
| 239 |
|
| 240 |
```text
|
| 241 |
-
usage: voice doctor [-h]
|
| 242 |
|
| 243 |
options:
|
| 244 |
-
-h, --help
|
|
|
|
|
|
|
| 245 |
```
|
| 246 |
|
| 247 |
## voice --version / --completion
|
|
|
|
| 1 |
# voice — Help
|
| 2 |
|
| 3 |
+
Generated from `voice --help` and `voice <cmd> --help` (v3.0.1, 12 commands).
|
| 4 |
|
| 5 |
## voice --help
|
| 6 |
|
|
|
|
| 30 |
|
| 31 |
options:
|
| 32 |
-h, --help show this help message and exit
|
| 33 |
+
-v, --verbose Verbose: tensor shapes, decisions, and paths
|
| 34 |
+
--non-interactive Fail instead of prompting (same as piped stdin; needs
|
| 35 |
+
--yes to overwrite/remove)
|
| 36 |
+
--version Show version and environment
|
| 37 |
--completion {bash,zsh,fish}
|
| 38 |
+
Print shell completion script
|
| 39 |
```
|
| 40 |
|
| 41 |
## voice get
|
|
|
|
| 51 |
|
| 52 |
options:
|
| 53 |
-h, --help show this help message and exit
|
| 54 |
+
-q, --quiet Quieter: progress and success notes off (warnings and errors
|
| 55 |
+
still print)
|
| 56 |
+
--name NAME Voice name to save (registry voices only; not with --out)
|
| 57 |
+
--multi Fetch the named tensors (1+) as voicepack.safetensors +
|
| 58 |
+
voicepack.json (not with --name)
|
| 59 |
--out OUT Write a standalone file instead of a registry voice (default
|
| 60 |
pack name: voicepack.safetensors)
|
| 61 |
+
--yes Assume yes to prompts (overwrite without asking)
|
| 62 |
```
|
| 63 |
|
| 64 |
Names: letters, numbers, hyphens, underscores — no spaces, `/`, `\`, dots,
|
|
|
|
| 71 |
|
| 72 |
```text
|
| 73 |
usage: voice cast [-h] [--out OUT] [--yes] [--quant QUANT]
|
| 74 |
+
[--exclude EXCLUDES] [--speak] [-q]
|
| 75 |
target voice [tensors ...]
|
| 76 |
|
| 77 |
positional arguments:
|
|
|
|
| 82 |
|
| 83 |
options:
|
| 84 |
-h, --help show this help message and exit
|
| 85 |
+
--out OUT Output file or folder (default:
|
| 86 |
+
~/Voiced/<voice>-<model>/<voice>-<model>.<ext matching
|
| 87 |
+
target>; a folder invents the filename)
|
| 88 |
+
--yes Assume yes to prompts (overwrite without asking)
|
| 89 |
--quant QUANT Output quant override: keep (default, preserve quality)
|
| 90 |
| target | any quant
|
| 91 |
+
(q8_0,q4_0,q4_k,q6_k,iq4_nl,f16,f32,bf16,...;
|
| 92 |
+
safetensors targets: keep|target|f32|f16|bf16)
|
| 93 |
+
--exclude EXCLUDES Skip tensors on cast (repeatable: --exclude foo
|
| 94 |
+
--exclude bar, or --exclude foo,bar)
|
| 95 |
+
--speak Voice speaks through output.weight (invented if absent
|
| 96 |
+
when head/embed geometry survives; GGUF targets only)
|
| 97 |
+
-q, --quiet Quieter: progress and success notes off (warnings and
|
| 98 |
+
errors still print)
|
| 99 |
```
|
| 100 |
Philosophy: preserve quality, avoid dequant→quant cycles. Safetensors high-fidelity
|
| 101 |
lm_head is quantized once to Q8_0 (Q4 saves little: Q8_0 1.062 vs Q4_0 0.562 B/param).
|
|
|
|
| 113 |
## voice delta
|
| 114 |
|
| 115 |
```text
|
| 116 |
+
usage: voice delta [-h] [--base BASE] [--yes] [-q] [voicename]
|
| 117 |
|
| 118 |
positional arguments:
|
| 119 |
+
voicename Voice name (default: pick from registry)
|
| 120 |
|
| 121 |
options:
|
| 122 |
-h, --help show this help message and exit
|
| 123 |
--base BASE Base HF repo (org/model) or local path to base safetensors
|
| 124 |
+
--yes Assume yes to prompts (overwrite without asking)
|
| 125 |
+
-q, --quiet Quieter: progress and success notes off (warnings and errors
|
| 126 |
+
still print)
|
| 127 |
```
|
| 128 |
|
| 129 |
Niche cases need typed confirmation: delta-as-base asks `UNDO THE UNDO`,
|
|
|
|
| 134 |
## voice add
|
| 135 |
|
| 136 |
```text
|
| 137 |
+
usage: voice add [-h] [--name NAME] [--yes] [-q] safetensors json
|
| 138 |
|
| 139 |
positional arguments:
|
| 140 |
safetensors Path to voice.safetensors (required)
|
|
|
|
| 144 |
-h, --help show this help message and exit
|
| 145 |
--name NAME Voice name to save (default from voice.json)
|
| 146 |
--yes Auto-confirm overwrite
|
| 147 |
+
-q, --quiet Quieter: progress and success notes off (warnings and errors
|
| 148 |
+
still print)
|
| 149 |
```
|
| 150 |
|
| 151 |
The tensor is copied and validated before `voice.json` is written, so an
|
| 152 |
invalid source adds nothing and never leaves metadata pointing at a partial file.
|
| 153 |
|
| 154 |
## voice list
|
|
|
|
| 155 |
```text
|
| 156 |
+
usage: voice list [-h] [--base] [-q] [base]
|
| 157 |
|
| 158 |
positional arguments:
|
| 159 |
+
base Show cached base heads (same as --base)
|
| 160 |
|
| 161 |
options:
|
| 162 |
+
-h, --help show this help message and exit
|
| 163 |
+
--base Show cached base heads instead of voices
|
| 164 |
+
-q, --quiet Quieter: progress and success notes off (warnings and errors
|
| 165 |
+
still print)
|
| 166 |
```
|
| 167 |
|
| 168 |
## voice info
|
| 169 |
|
| 170 |
```text
|
| 171 |
+
usage: voice info [-h] [-q] voicename
|
| 172 |
|
| 173 |
positional arguments:
|
| 174 |
+
voicename Voice name
|
| 175 |
|
| 176 |
options:
|
| 177 |
+
-h, --help show this help message and exit
|
| 178 |
+
-q, --quiet Quieter: progress and success notes off (warnings and errors
|
| 179 |
+
still print)
|
| 180 |
```
|
|
|
|
| 181 |
## voice remove
|
|
|
|
| 182 |
```text
|
| 183 |
+
usage: voice remove [-h] [--yes] [-q] voice
|
| 184 |
|
| 185 |
positional arguments:
|
| 186 |
+
voice Voice name
|
| 187 |
|
| 188 |
options:
|
| 189 |
+
-h, --help show this help message and exit
|
| 190 |
+
--yes Assume yes to prompts (remove without asking)
|
| 191 |
+
-q, --quiet Quieter: progress and success notes off (warnings and errors
|
| 192 |
+
still print)
|
| 193 |
```
|
| 194 |
|
| 195 |
## voice cleanup
|
| 196 |
|
| 197 |
```text
|
| 198 |
+
usage: voice cleanup [-h] [--force] [-q]
|
| 199 |
|
| 200 |
options:
|
| 201 |
+
-h, --help show this help message and exit
|
| 202 |
+
--force Also clear in-progress downloads (locked)
|
| 203 |
+
-q, --quiet Quieter: progress and success notes off (warnings and errors
|
| 204 |
+
still print)
|
| 205 |
```
|
| 206 |
|
| 207 |
## voice auth
|
| 208 |
|
| 209 |
```text
|
| 210 |
+
usage: voice auth [-h] [--clear] [--show] [-q]
|
| 211 |
|
| 212 |
options:
|
| 213 |
+
-h, --help show this help message and exit
|
| 214 |
+
--clear Remove the stored token
|
| 215 |
+
--show Show the masked token
|
| 216 |
+
-q, --quiet Quieter: progress and success notes off (warnings and errors
|
| 217 |
+
still print)
|
| 218 |
```
|
| 219 |
|
| 220 |
## voice report
|
| 221 |
|
| 222 |
```text
|
| 223 |
usage: voice report [-h] [--message MESSAGE] [--voice VOICE] [--target TARGET]
|
| 224 |
+
[--reporter REPORTER] [--yes] [--no-push] [--sync] [-q]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
|
| 226 |
options:
|
| 227 |
-h, --help show this help message and exit
|
| 228 |
+
--message, -m MESSAGE
|
| 229 |
+
Freeform note (240ch, sanitized)
|
| 230 |
+
--voice VOICE Voice name context
|
| 231 |
+
--target TARGET Target file basename context
|
| 232 |
+
--reporter REPORTER Reporter id (optional, 64ch)
|
| 233 |
+
--yes Non-interactive: skip preview and auto-share to
|
| 234 |
+
community
|
| 235 |
--no-push Local only, skip share prompt
|
| 236 |
--sync Sync pending outbox to community
|
| 237 |
+
-q, --quiet Quieter: progress and success notes off (warnings and
|
| 238 |
+
errors still print)
|
| 239 |
+
```
|
| 240 |
|
| 241 |
After local save (private `~/.voices/reports.jsonl`), shows preview:
|
| 242 |
Will share: voice: styletune-v2, tensor: lm_head.weight [262144,2816] BF16, target: model.gguf
|
| 243 |
Leave a breadcrumb to help the next person? [y/N] (N): ← Enter = No, one try
|
| 244 |
Non-interactive skips unless --yes. Local: outbox at `~/.voices/outbox/<id>.json`.
|
| 245 |
Remote: `Wiself/voice-reports` `data/reports-YYYY-MM.jsonl`, batched, dedup `report_id`.
|
|
|
|
| 246 |
```
|
| 247 |
|
| 248 |
## voice path
|
| 249 |
|
| 250 |
```text
|
| 251 |
+
usage: voice path [-h] [-q]
|
| 252 |
|
| 253 |
options:
|
| 254 |
+
-h, --help show this help message and exit
|
| 255 |
+
-q, --quiet Quieter: progress and success notes off (warnings and errors
|
| 256 |
+
still print)
|
| 257 |
```
|
| 258 |
|
| 259 |
## voice doctor
|
| 260 |
|
| 261 |
```text
|
| 262 |
+
usage: voice doctor [-h] [-q]
|
| 263 |
|
| 264 |
options:
|
| 265 |
+
-h, --help show this help message and exit
|
| 266 |
+
-q, --quiet Quieter: progress and success notes off (warnings and errors
|
| 267 |
+
still print)
|
| 268 |
```
|
| 269 |
|
| 270 |
## voice --version / --completion
|
README.md
CHANGED
|
@@ -19,7 +19,7 @@ tags:
|
|
| 19 |
datasets:
|
| 20 |
- gryphe/styletune-roleplay-200
|
| 21 |
---
|
| 22 |
-
> **New in v3.0** — `--speak` (voice speaks through `output.weight`, invented if absent), smarter multi-tensor mapping (same-role bridging across prefixes, one batched error instead of mid-cast surprises), and a one-line install via the tarball below. 12 commands, `voice --help` is truth.
|
| 23 |
|
| 24 |
<p align="center"><img src="./lockup-circle-wordmark-2-refined.png" width="360" alt="Voice" /></p>
|
| 25 |
|
|
@@ -49,7 +49,7 @@ Then two commands. One model, one voice:
|
|
| 49 |
voice get Gryphe/Gemma-4-26B-A4B-StyleTune-V2
|
| 50 |
# Name it styletune-v2 when prompted
|
| 51 |
voice cast ./model.gguf styletune-v2 --out ./voiced/
|
| 52 |
-
voice cast ./model.gguf styletune-v2 --speak --out ./voiced/ # voice speaks through output.weight (invented if absent)
|
| 53 |
```
|
| 54 |
|
| 55 |
Run it:
|
|
@@ -171,11 +171,11 @@ The notebook is still mostly empty. That's why the next line matters most.
|
|
| 171 |
|
| 172 |
## Commands
|
| 173 |
|
| 174 |
-
Three you need daily — rest in [`DOCS.md`](./DOCS.md) (`voice --help` is truth, 12 commands `v3.0`):
|
| 175 |
|
| 176 |
| Command | What it does |
|
| 177 |
|---|---|
|
| 178 |
-
| `voice cast <target> <voice> [tensors...]` | Cast it onto `.gguf` or `.safetensors` of same shape/vocab (`Q8_0` once for safetensors lm_head, else keep target quant incl. all GGML quants; `--quant keep\|target\|any quant`; `--speak` for output.weight
|
| 179 |
| `voice report -m "note"` | Save a one-line note locally, optionally share to community — small file, big iteration (we pull source/tensor/shape) |
|
| 180 |
|
| 181 |
### Extra commands
|
|
@@ -254,13 +254,13 @@ Temperature 0.0, same prompts, budgets, and extraction both sides:
|
|
| 254 |
| Task | n | A | B |
|
| 255 |
|---|---|---|---|
|
| 256 |
| ARC-Challenge | 100 | 94 | 95 |
|
| 257 |
-
| MMLU (2 × 57 subjects) | 114 |
|
| 258 |
| GSM8K | 100 | 76 | 92 |
|
| 259 |
|
| 260 |
Unanswered (empty after thought ran out, never scored as wrong) — A: 0, 8,
|
| 261 |
-
23 · B: 0, 4, 6. Answered-accuracy — ARC 0.940/0.950, MMLU 0.
|
| 262 |
-
GSM8K 0.987/0.979.
|
| 263 |
-
|
| 264 |
|
| 265 |
Writing voice, 32 prompts at temp 0.7, same neutral discipline:
|
| 266 |
|
|
@@ -285,7 +285,7 @@ Gryphe (n=200): 52% fewer clichés (1.141 → 0.551) + 19.9% shared vocab at gre
|
|
| 285 |
|
| 286 |
- **Heuristic mismatch:** Our 50-phrase list misses Gryphe's private regex (`calculating xx`, `predatory xx`, and others), so absolute 0.10–0.18 vs 1.141 → 0.551 is not comparable—only direction and low shared vocabulary are signal.
|
| 287 |
- **Sample size and prompts:** 10 single-turn prompts vs Gryphe's 200 multi-turn certified set (intervals 1–20, ends on user turn). Small sample, higher variance.
|
| 288 |
-
- **Thinking overhead:** Gemma 4 thinking mode (`<|channel>thought`) adds
|
| 289 |
- **Determinism:** Greedy 0.0 reduces variance but still yields more canonical phrasing (shared 1.6%→3.2%)—expected, not a failure.
|
| 290 |
- **If you see looping, use the delta path** (`voice delta` → `voice cast … delta-…`). Tiny shifts can affect behavior on abliterated targets. See “Why a delta helps when looping” above.
|
| 291 |
- **Scope:** Style transfer changes phrasing and voice, not knowledge or factuality. Not evaluated for safety, bias, or instruction following. See Gemma 4 model card Limitations.
|
|
|
|
| 19 |
datasets:
|
| 20 |
- gryphe/styletune-roleplay-200
|
| 21 |
---
|
| 22 |
+
> **New in v3.0** — `--speak` (voice speaks through `output.weight`, invented if absent when head/embed geometry survives; GGUF targets only), smarter multi-tensor mapping (same-role bridging across prefixes, one batched error instead of mid-cast surprises), and a one-line install via the tarball below. 12 commands, `voice --help` is truth.
|
| 23 |
|
| 24 |
<p align="center"><img src="./lockup-circle-wordmark-2-refined.png" width="360" alt="Voice" /></p>
|
| 25 |
|
|
|
|
| 49 |
voice get Gryphe/Gemma-4-26B-A4B-StyleTune-V2
|
| 50 |
# Name it styletune-v2 when prompted
|
| 51 |
voice cast ./model.gguf styletune-v2 --out ./voiced/
|
| 52 |
+
voice cast ./model.gguf styletune-v2 --speak --out ./voiced/ # voice speaks through output.weight (invented if absent; GGUF only)
|
| 53 |
```
|
| 54 |
|
| 55 |
Run it:
|
|
|
|
| 171 |
|
| 172 |
## Commands
|
| 173 |
|
| 174 |
+
Three you need daily — rest in [`DOCS.md`](./DOCS.md) (`voice --help` is truth, 12 commands `v3.0.1`):
|
| 175 |
|
| 176 |
| Command | What it does |
|
| 177 |
|---|---|
|
| 178 |
+
| `voice cast <target> <voice> [tensors...]` | Cast it onto `.gguf` or `.safetensors` of same shape/vocab (`Q8_0` once for safetensors lm_head, else keep target quant incl. all GGML quants; `--quant keep\|target\|any quant` (safetensors: keep\|target\|f32\|f16\|bf16); `--speak` for output.weight on GGUF (invented if absent); `--exclude` to skip) |
|
| 179 |
| `voice report -m "note"` | Save a one-line note locally, optionally share to community — small file, big iteration (we pull source/tensor/shape) |
|
| 180 |
|
| 181 |
### Extra commands
|
|
|
|
| 254 |
| Task | n | A | B |
|
| 255 |
|---|---|---|---|
|
| 256 |
| ARC-Challenge | 100 | 94 | 95 |
|
| 257 |
+
| MMLU (2 × 57 subjects) | 114 | 101 | 103 |
|
| 258 |
| GSM8K | 100 | 76 | 92 |
|
| 259 |
|
| 260 |
Unanswered (empty after thought ran out, never scored as wrong) — A: 0, 8,
|
| 261 |
+
23 · B: 0, 4, 6. Answered-accuracy — ARC 0.940/0.950, MMLU 0.953/0.936,
|
| 262 |
+
GSM8K 0.987/0.979. Thinking lengths roughly match (no pairing script was
|
| 263 |
+
archived, so no median is claimed).
|
| 264 |
|
| 265 |
Writing voice, 32 prompts at temp 0.7, same neutral discipline:
|
| 266 |
|
|
|
|
| 285 |
|
| 286 |
- **Heuristic mismatch:** Our 50-phrase list misses Gryphe's private regex (`calculating xx`, `predatory xx`, and others), so absolute 0.10–0.18 vs 1.141 → 0.551 is not comparable—only direction and low shared vocabulary are signal.
|
| 287 |
- **Sample size and prompts:** 10 single-turn prompts vs Gryphe's 200 multi-turn certified set (intervals 1–20, ends on user turn). Small sample, higher variance.
|
| 288 |
+
- **Thinking overhead:** Gemma 4 thinking mode (`<|channel>thought`) adds roughly 3k characters (~600–700 tokens) of thinking trace in our probes. Gryphe's eval predates thinking configs and did not report this split.
|
| 289 |
- **Determinism:** Greedy 0.0 reduces variance but still yields more canonical phrasing (shared 1.6%→3.2%)—expected, not a failure.
|
| 290 |
- **If you see looping, use the delta path** (`voice delta` → `voice cast … delta-…`). Tiny shifts can affect behavior on abliterated targets. See “Why a delta helps when looping” above.
|
| 291 |
- **Scope:** Style transfer changes phrasing and voice, not knowledge or factuality. Not evaluated for safety, bias, or instruction following. See Gemma 4 model card Limitations.
|
benchmark.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
| 2 |
|
| 3 |
> **Anchor:** fanned out 4 isolated subagents (A OG1→OGg, B TEST1→TESTg, C OGg vs TESTg, D cross). All 10 prompts `max_tokens 2000` `seed 42` same 10 prompts. Chat template Gemma4 `<|channel>thought → <channel|>` parsed, `thinking` scraped, `text` stripped. Files verified `10/10` each. Heuristic cliché list 50-phrase distinct substring (not Gryphe private regex `calculating/predatory xx`). `words = len(text.split())`, `trigram Jaccard = |a∩b|/|a∪b|`, `TTR=|unique|/|toks|`, `maxRep=Counter(trigrams)`.
|
| 4 |
|
|
|
|
|
|
|
| 5 |
## 1. OG 1.0 → OG greedy (sampler effect on base, voice fixed)
|
| 6 |
|
| 7 |
*Subagent A* — **Greedy shortens and denoises.**
|
|
|
|
| 2 |
|
| 3 |
> **Anchor:** fanned out 4 isolated subagents (A OG1→OGg, B TEST1→TESTg, C OGg vs TESTg, D cross). All 10 prompts `max_tokens 2000` `seed 42` same 10 prompts. Chat template Gemma4 `<|channel>thought → <channel|>` parsed, `thinking` scraped, `text` stripped. Files verified `10/10` each. Heuristic cliché list 50-phrase distinct substring (not Gryphe private regex `calculating/predatory xx`). `words = len(text.split())`, `trigram Jaccard = |a∩b|/|a∪b|`, `TTR=|unique|/|toks|`, `maxRep=Counter(trigrams)`.
|
| 4 |
|
| 5 |
+
> Provenance note: §§1–4 draw on early probe runs whose draws are not archived (no temp/seed metadata on file). Treat directionally, not as reproducible. The §5/file-a/file-b tables in results.md reproduce from archives.
|
| 6 |
+
|
| 7 |
## 1. OG 1.0 → OG greedy (sampler effect on base, voice fixed)
|
| 8 |
|
| 9 |
*Subagent A* — **Greedy shortens and denoises.**
|
benchmarking.md
CHANGED
|
@@ -60,14 +60,14 @@ extraction on both:
|
|
| 60 |
| Task | n | A correct | B correct | A acc | B acc |
|
| 61 |
|---|---|---|---|---|---|
|
| 62 |
| ARC-Challenge (generative) | 100 | 94 | 95 | 0.940 | 0.950 |
|
| 63 |
-
| MMLU (generative, 2 × 57 subjects) | 114 |
|
| 64 |
| GSM8K | 100 | 76 | 92 | 0.760 | 0.920 |
|
| 65 |
|
| 66 |
-
Wrong/unanswered split — A: ARC 6/0, MMLU
|
| 67 |
MMLU 7/4, GSM8K 2/6. Unanswered = empty model content after thought
|
| 68 |
exhausted the token budget (counted separately, never folded into wrong).
|
| 69 |
GSM8K sample files contain each doc twice (harness duplication); scores
|
| 70 |
-
dedup by doc_id.
|
| 71 |
|
| 72 |
## Run labeling
|
| 73 |
|
|
|
|
| 60 |
| Task | n | A correct | B correct | A acc | B acc |
|
| 61 |
|---|---|---|---|---|---|
|
| 62 |
| ARC-Challenge (generative) | 100 | 94 | 95 | 0.940 | 0.950 |
|
| 63 |
+
| MMLU (generative, 2 × 57 subjects) | 114 | 101 | 103 | 0.886 | 0.904 |
|
| 64 |
| GSM8K | 100 | 76 | 92 | 0.760 | 0.920 |
|
| 65 |
|
| 66 |
+
Wrong/unanswered split — A: ARC 6/0, MMLU 5/8, GSM8K 1/23. B: ARC 5/0,
|
| 67 |
MMLU 7/4, GSM8K 2/6. Unanswered = empty model content after thought
|
| 68 |
exhausted the token budget (counted separately, never folded into wrong).
|
| 69 |
GSM8K sample files contain each doc twice (harness duplication); scores
|
| 70 |
+
dedup by doc_id, and split rescue pairs keep the decided verdict.
|
| 71 |
|
| 72 |
## Run labeling
|
| 73 |
|
creative-bench/runs/tensorwars.md
CHANGED
|
@@ -90,6 +90,8 @@ outputOnly × oldTied 158; fullShared × oldTied 158.
|
|
| 90 |
|
| 91 |
### Trigram overlap between builds (Jaccard)
|
| 92 |
|
|
|
|
|
|
|
| 93 |
Highest: outputOnly × fullShared 0.0581. Voice–voice pairs: 0.033–0.058.
|
| 94 |
Base–voice pairs: 0.026–0.036. Lowest: base × inputOnly 0.0260.
|
| 95 |
|
|
|
|
| 90 |
|
| 91 |
### Trigram overlap between builds (Jaccard)
|
| 92 |
|
| 93 |
+
Method: tokens are `re.findall(r"[a-z']+", s.lower())` (the voice-taste.py definition); other tokenizers give different numbers.
|
| 94 |
+
|
| 95 |
Highest: outputOnly × fullShared 0.0581. Voice–voice pairs: 0.033–0.058.
|
| 96 |
Base–voice pairs: 0.026–0.036. Lowest: base × inputOnly 0.0260.
|
| 97 |
|
results.md
CHANGED
|
@@ -14,27 +14,27 @@ to reproduce).
|
|
| 14 |
- Both files: temperature 0.0, seed 1234, identical prompts, identical token
|
| 15 |
budgets (ARC 1024, MMLU 2048, GSM8K 1024), identical answer extraction.
|
| 16 |
Unanswered items got one rescue pass at 4096 (MMLU) / 2048 (GSM8K),
|
| 17 |
-
applied to both files symmetrically.
|
|
|
|
| 18 |
|
| 19 |
## Scores
|
| 20 |
|
| 21 |
| Task | n | A correct | B correct | A acc | B acc |
|
| 22 |
|---|---|---|---|---|---|
|
| 23 |
| ARC-Challenge (generative) | 100 | 94 | 95 | 0.940 | 0.950 |
|
| 24 |
-
| MMLU (generative, 2 × 57 subjects) | 114 |
|
| 25 |
| GSM8K | 100 | 76 | 92 | 0.760 | 0.920 |
|
| 26 |
|
| 27 |
## Observations
|
| 28 |
|
| 29 |
-
1. **ARC (+1) and MMLU (+
|
| 30 |
points at n≈100). GSM8K (+16) exceeds it; see point 2.
|
| 31 |
2. **The GSM8K difference sits in unanswered counts.** File A left 23
|
| 32 |
items silent (empty content after thought exhausted the budget); file
|
| 33 |
B left 6. On items both files answered, accuracy is 0.987 (A) vs
|
| 34 |
0.979 (B). The traces hold whatever else there is to see.
|
| 35 |
-
3. **Thinking lengths match.**
|
| 36 |
-
median
|
| 37 |
-
distribution (103/215 shorter under B).
|
| 38 |
4. **Error overlap is minimal.** One GSM8K item was wrong under both
|
| 39 |
files; remaining errors are different items per file.
|
| 40 |
|
|
|
|
| 14 |
- Both files: temperature 0.0, seed 1234, identical prompts, identical token
|
| 15 |
budgets (ARC 1024, MMLU 2048, GSM8K 1024), identical answer extraction.
|
| 16 |
Unanswered items got one rescue pass at 4096 (MMLU) / 2048 (GSM8K),
|
| 17 |
+
applied to both files symmetrically. Rescue tie-break: on split pairs
|
| 18 |
+
(two verdicts for one doc) the decided verdict beats `unanswered`.
|
| 19 |
|
| 20 |
## Scores
|
| 21 |
|
| 22 |
| Task | n | A correct | B correct | A acc | B acc |
|
| 23 |
|---|---|---|---|---|---|
|
| 24 |
| ARC-Challenge (generative) | 100 | 94 | 95 | 0.940 | 0.950 |
|
| 25 |
+
| MMLU (generative, 2 × 57 subjects) | 114 | 101 | 103 | 0.886 | 0.904 |
|
| 26 |
| GSM8K | 100 | 76 | 92 | 0.760 | 0.920 |
|
| 27 |
|
| 28 |
## Observations
|
| 29 |
|
| 30 |
+
1. **ARC (+1) and MMLU (+2) differences fall within slice noise** (±5
|
| 31 |
points at n≈100). GSM8K (+16) exceeds it; see point 2.
|
| 32 |
2. **The GSM8K difference sits in unanswered counts.** File A left 23
|
| 33 |
items silent (empty content after thought exhausted the budget); file
|
| 34 |
B left 6. On items both files answered, accuracy is 0.987 (A) vs
|
| 35 |
0.979 (B). The traces hold whatever else there is to see.
|
| 36 |
+
3. **Thinking lengths roughly match.** No pairing script was archived, so no
|
| 37 |
+
median is claimed; per-file thinking lengths sit in the same range.
|
|
|
|
| 38 |
4. **Error overlap is minimal.** One GSM8K item was wrong under both
|
| 39 |
files; remaining errors are different items per file.
|
| 40 |
|
vlib/cmds_misc.py
CHANGED
|
@@ -24,7 +24,7 @@ def cmd_list(args):
|
|
| 24 |
|
| 25 |
voices = [d for d in _iter_voices() if (d / "voice.json").exists()]
|
| 26 |
if not voices:
|
| 27 |
-
_say(" No voices stored yet.
|
| 28 |
return
|
| 29 |
|
| 30 |
tw = _term_width()
|
|
@@ -44,7 +44,7 @@ def cmd_list(args):
|
|
| 44 |
def _list_bases():
|
| 45 |
base_root = ctx.VOICES_DIR / "base"
|
| 46 |
if not base_root.exists() or not any(base_root.rglob("*.json")):
|
| 47 |
-
_say(" No bases cached yet.
|
| 48 |
return
|
| 49 |
tw = _term_width()
|
| 50 |
w_base = 40 if tw >= 80 else max(20, tw - 30)
|
|
@@ -67,13 +67,32 @@ def _list_bases():
|
|
| 67 |
_say(f" {_trunc(base_id, w_base):<{w_base}} {_trunc(b_str, 18):<18} {_trunc(fetched, 12):<12}")
|
| 68 |
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
def _voice_tensors(meta):
|
| 71 |
"""Normalize voice metadata to a (tensors, synthetic) pair.
|
| 72 |
Flat-only files (tensor_name/shape/dtype, no tensors list) become a
|
| 73 |
-
synthetic 1-entry list so readers share one code path.
|
|
|
|
| 74 |
claims = meta.get("tensors")
|
| 75 |
if isinstance(claims, list) and claims:
|
| 76 |
-
|
|
|
|
| 77 |
if meta.get("tensor_name"):
|
| 78 |
return [{"name": meta.get("tensor_name"), "shape": meta.get("shape"),
|
| 79 |
"dtype": meta.get("dtype")}], True
|
|
@@ -149,25 +168,26 @@ def cmd_info(args):
|
|
| 149 |
_say(f" Dtype: {meta.get('dtype', '—')}")
|
| 150 |
_say(f" File: {bps[0]}")
|
| 151 |
return
|
| 152 |
-
_fail(f" ✗ Voice '{voicename}' not found. Try voice list")
|
| 153 |
|
| 154 |
meta = _read_meta(Path(voice_path).parent / "voice.json") or voice_meta or {}
|
| 155 |
name = meta.get("name", voicename)
|
| 156 |
source = meta.get("source_hf_model") or meta.get("source") or "—"
|
| 157 |
typ = meta.get("type", "voice")
|
| 158 |
_say(f" Name: {name}")
|
| 159 |
-
_say(f" Type: {typ}")
|
| 160 |
-
_say(f" Source: {source}")
|
| 161 |
if meta.get("family") or meta.get("architecture"):
|
| 162 |
-
|
|
|
|
|
|
|
| 163 |
tensors, _synthetic = _voice_tensors(meta)
|
| 164 |
only = tensors[0] if len(tensors) == 1 else {}
|
| 165 |
-
|
| 166 |
-
_say(f" Shape: {meta.get('shape') or only.get('shape', '—')}")
|
| 167 |
-
_say(f" Dtype: {meta.get('dtype') or only.get('dtype', '—')}")
|
| 168 |
-
if len(tensors) > 1:
|
| 169 |
for entry in tensors:
|
| 170 |
_say(f" - {entry.get('name')}: {entry.get('shape')} · {entry.get('dtype')}")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
b = meta.get("bytes")
|
| 172 |
if isinstance(b, int):
|
| 173 |
_say(f" Bytes: {b} ({b/1e6:.1f} MB)")
|
|
@@ -185,12 +205,12 @@ def cmd_remove(args):
|
|
| 185 |
name = args.voice.strip().lower()
|
| 186 |
target = next((d for d in _iter_voices() if d.name.lower() == name), None)
|
| 187 |
if target is None:
|
| 188 |
-
_fail(f" ✗ Voice '{args.voice}' not found.")
|
| 189 |
if _noninteractive(args) and not getattr(args, "yes", False):
|
| 190 |
-
_fail(f" ✗
|
| 191 |
if not _confirm(f" Remove voice '{target.name}'? [y/N]: ", args):
|
| 192 |
_say(" Cancelled.")
|
| 193 |
-
sys.exit(
|
| 194 |
import shutil
|
| 195 |
shutil.rmtree(target)
|
| 196 |
log_operation({"op": "remove", "voice": target.name, "output": str(target), "status": "ok"})
|
|
@@ -200,7 +220,7 @@ def cmd_remove(args):
|
|
| 200 |
def cmd_cleanup(args):
|
| 201 |
parts_dir = ctx.VOICES_DIR / ".parts"
|
| 202 |
if not parts_dir.exists() or not any(parts_dir.iterdir()):
|
| 203 |
-
|
| 204 |
return
|
| 205 |
removed, reclaimed = 0, 0
|
| 206 |
import shutil
|
|
@@ -212,7 +232,7 @@ def cmd_cleanup(args):
|
|
| 212 |
if lock.exists() and not force:
|
| 213 |
try:
|
| 214 |
if time.time() - lock.stat().st_mtime < 600:
|
| 215 |
-
_note(f"Skipping
|
| 216 |
continue
|
| 217 |
except Exception:
|
| 218 |
pass
|
|
@@ -236,11 +256,12 @@ def cmd_cleanup(args):
|
|
| 236 |
parts_dir.rmdir()
|
| 237 |
except Exception:
|
| 238 |
pass
|
| 239 |
-
|
| 240 |
-
|
| 241 |
def cmd_auth(args):
|
| 242 |
tok_path = ctx.HF_TOKEN_PATH
|
| 243 |
if getattr(args, "clear", False):
|
|
|
|
|
|
|
|
|
|
| 244 |
try:
|
| 245 |
tok_path.unlink(missing_ok=True)
|
| 246 |
_ok("Removed stored HF token.")
|
|
@@ -249,13 +270,15 @@ def cmd_auth(args):
|
|
| 249 |
return
|
| 250 |
if getattr(args, "show", False):
|
| 251 |
tok = _get_hf_token()
|
| 252 |
-
if not tok:
|
| 253 |
-
_say("
|
| 254 |
return
|
| 255 |
masked = tok[:4] + "·" * (len(tok) - 8) + tok[-4:] if len(tok) > 8 else "·" * len(tok)
|
| 256 |
src = "environment" if os.environ.get("HF_TOKEN") or os.environ.get("HF_HUB_TOKEN") else str(tok_path)
|
| 257 |
_say(f" ✓ HF token present: {masked} ({src})")
|
| 258 |
return
|
|
|
|
|
|
|
| 259 |
_say(" Paste your HF token (hf_…): it stays on this machine, 0600, never logged.")
|
| 260 |
try:
|
| 261 |
try:
|
|
@@ -264,10 +287,10 @@ def cmd_auth(args):
|
|
| 264 |
tok = input(" Paste HF token: ").strip()
|
| 265 |
except (EOFError, KeyboardInterrupt):
|
| 266 |
_say(" ⚠ Cancelled.")
|
| 267 |
-
sys.exit(
|
| 268 |
if not tok:
|
| 269 |
_say(" ⚠ No token entered.")
|
| 270 |
-
sys.exit(
|
| 271 |
if not tok.startswith("hf_") or len(tok) < 10:
|
| 272 |
_fail(" ✗ That doesn't look like an HF token (should start with hf_…).")
|
| 273 |
_step("Verifying…")
|
|
@@ -351,7 +374,7 @@ def cmd_path(_args):
|
|
| 351 |
except OSError:
|
| 352 |
_fail(f" ✗ 'voice' on PATH isn't ours ({existing}). Remove or rename it, then retry.")
|
| 353 |
if Path(old_target).name != "voice.py":
|
| 354 |
-
_fail(f" ✗ '{existing}' isn't a voice install (points at {old_target}). Remove
|
| 355 |
try:
|
| 356 |
Path(existing).unlink()
|
| 357 |
Path(existing).symlink_to(str(script))
|
|
@@ -385,7 +408,7 @@ def cmd_doctor(_args):
|
|
| 385 |
if (venv / "bin" / "python").exists():
|
| 386 |
_say(f" venv {venv} present")
|
| 387 |
else:
|
| 388 |
-
_say(f" venv not created yet (created on first get/cast/
|
| 389 |
try:
|
| 390 |
free = shutil.disk_usage(ctx.VOICES_DIR if ctx.VOICES_DIR.exists() else Path.home()).free
|
| 391 |
_say(f" disk free {free/1e9:.1f} GB")
|
|
@@ -417,6 +440,7 @@ def cmd_doctor(_args):
|
|
| 417 |
pass
|
| 418 |
else:
|
| 419 |
_say(f" reports: none yet — run: voice report")
|
|
|
|
| 420 |
try:
|
| 421 |
req = urllib.request.Request("https://huggingface.co/api/whoami-v2" if tok else "https://huggingface.co",
|
| 422 |
headers=_hf_auth_headers("https://huggingface.co"))
|
|
@@ -444,7 +468,7 @@ def _print_version():
|
|
| 444 |
|
| 445 |
|
| 446 |
def _print_completion(shell):
|
| 447 |
-
cmds = ["get", "cast", "delta", "list", "info", "remove", "cleanup", "auth", "report", "path", "doctor"]
|
| 448 |
voices = [d.name for d in _iter_voices() if (d / "voice.json").exists()]
|
| 449 |
vlist = " ".join(voices)
|
| 450 |
clist = " ".join(cmds)
|
|
|
|
| 24 |
|
| 25 |
voices = [d for d in _iter_voices() if (d / "voice.json").exists()]
|
| 26 |
if not voices:
|
| 27 |
+
_say(" No voices stored yet. Use 'voice get <model>' to download one, or 'voice add <file> <json>' for local files.")
|
| 28 |
return
|
| 29 |
|
| 30 |
tw = _term_width()
|
|
|
|
| 44 |
def _list_bases():
|
| 45 |
base_root = ctx.VOICES_DIR / "base"
|
| 46 |
if not base_root.exists() or not any(base_root.rglob("*.json")):
|
| 47 |
+
_say(" No bases cached yet. Use 'voice delta <voice>' to create one.")
|
| 48 |
return
|
| 49 |
tw = _term_width()
|
| 50 |
w_base = 40 if tw >= 80 else max(20, tw - 30)
|
|
|
|
| 67 |
_say(f" {_trunc(base_id, w_base):<{w_base}} {_trunc(b_str, 18):<18} {_trunc(fetched, 12):<12}")
|
| 68 |
|
| 69 |
|
| 70 |
+
def _dec_str(v):
|
| 71 |
+
"""Display coercion: GGUF-derived metadata sometimes holds raw byte
|
| 72 |
+
lists (e.g. [108, 108, 97, 109, 97]); render them as text, never dumps."""
|
| 73 |
+
if v is None:
|
| 74 |
+
return None
|
| 75 |
+
if isinstance(v, (bytes, bytearray)):
|
| 76 |
+
try:
|
| 77 |
+
return bytes(v).decode("ascii", "replace")
|
| 78 |
+
except Exception:
|
| 79 |
+
return str(v)
|
| 80 |
+
if isinstance(v, list) and v and all(isinstance(x, int) for x in v):
|
| 81 |
+
try:
|
| 82 |
+
return bytes(v).decode("ascii", "replace")
|
| 83 |
+
except Exception:
|
| 84 |
+
return str(v)
|
| 85 |
+
return v if isinstance(v, str) else str(v)
|
| 86 |
+
|
| 87 |
def _voice_tensors(meta):
|
| 88 |
"""Normalize voice metadata to a (tensors, synthetic) pair.
|
| 89 |
Flat-only files (tensor_name/shape/dtype, no tensors list) become a
|
| 90 |
+
synthetic 1-entry list so readers share one code path. Bare-string
|
| 91 |
+
entries (hand-written json) are coerced so readers never traceback."""
|
| 92 |
claims = meta.get("tensors")
|
| 93 |
if isinstance(claims, list) and claims:
|
| 94 |
+
fixed = [({"name": e} if isinstance(e, str) else e) for e in claims]
|
| 95 |
+
return [e for e in fixed if isinstance(e, dict)], False
|
| 96 |
if meta.get("tensor_name"):
|
| 97 |
return [{"name": meta.get("tensor_name"), "shape": meta.get("shape"),
|
| 98 |
"dtype": meta.get("dtype")}], True
|
|
|
|
| 168 |
_say(f" Dtype: {meta.get('dtype', '—')}")
|
| 169 |
_say(f" File: {bps[0]}")
|
| 170 |
return
|
| 171 |
+
_fail(f" ✗ Voice '{voicename}' not found. Try: voice list")
|
| 172 |
|
| 173 |
meta = _read_meta(Path(voice_path).parent / "voice.json") or voice_meta or {}
|
| 174 |
name = meta.get("name", voicename)
|
| 175 |
source = meta.get("source_hf_model") or meta.get("source") or "—"
|
| 176 |
typ = meta.get("type", "voice")
|
| 177 |
_say(f" Name: {name}")
|
|
|
|
|
|
|
| 178 |
if meta.get("family") or meta.get("architecture"):
|
| 179 |
+
_arch = _dec_str(meta.get("architecture"))
|
| 180 |
+
_fam = _dec_str(meta.get("family"))
|
| 181 |
+
_say(f" Family: {_fam or '—'}" + (f" ({_arch})" if _arch else ""))
|
| 182 |
tensors, _synthetic = _voice_tensors(meta)
|
| 183 |
only = tensors[0] if len(tensors) == 1 else {}
|
| 184 |
+
if len(tensors) != 1:
|
|
|
|
|
|
|
|
|
|
| 185 |
for entry in tensors:
|
| 186 |
_say(f" - {entry.get('name')}: {entry.get('shape')} · {entry.get('dtype')}")
|
| 187 |
+
else:
|
| 188 |
+
_say(f" Tensor: {meta.get('tensor_name') or only.get('name', '—')}")
|
| 189 |
+
_say(f" Shape: {meta.get('shape') or only.get('shape', '—')}")
|
| 190 |
+
_say(f" Dtype: {meta.get('dtype') or only.get('dtype', '—')}")
|
| 191 |
b = meta.get("bytes")
|
| 192 |
if isinstance(b, int):
|
| 193 |
_say(f" Bytes: {b} ({b/1e6:.1f} MB)")
|
|
|
|
| 205 |
name = args.voice.strip().lower()
|
| 206 |
target = next((d for d in _iter_voices() if d.name.lower() == name), None)
|
| 207 |
if target is None:
|
| 208 |
+
_fail(f" ✗ Voice '{args.voice}' not found. Try: voice list")
|
| 209 |
if _noninteractive(args) and not getattr(args, "yes", False):
|
| 210 |
+
_fail(f" ✗ Can't remove '{target.name}' in non-interactive mode without --yes.")
|
| 211 |
if not _confirm(f" Remove voice '{target.name}'? [y/N]: ", args):
|
| 212 |
_say(" Cancelled.")
|
| 213 |
+
sys.exit(1)
|
| 214 |
import shutil
|
| 215 |
shutil.rmtree(target)
|
| 216 |
log_operation({"op": "remove", "voice": target.name, "output": str(target), "status": "ok"})
|
|
|
|
| 220 |
def cmd_cleanup(args):
|
| 221 |
parts_dir = ctx.VOICES_DIR / ".parts"
|
| 222 |
if not parts_dir.exists() or not any(parts_dir.iterdir()):
|
| 223 |
+
_say("No incomplete downloads to clean.")
|
| 224 |
return
|
| 225 |
removed, reclaimed = 0, 0
|
| 226 |
import shutil
|
|
|
|
| 232 |
if lock.exists() and not force:
|
| 233 |
try:
|
| 234 |
if time.time() - lock.stat().st_mtime < 600:
|
| 235 |
+
_note(f"Skipping {p.name}: download in progress or stalled — use --force to clear")
|
| 236 |
continue
|
| 237 |
except Exception:
|
| 238 |
pass
|
|
|
|
| 256 |
parts_dir.rmdir()
|
| 257 |
except Exception:
|
| 258 |
pass
|
|
|
|
|
|
|
| 259 |
def cmd_auth(args):
|
| 260 |
tok_path = ctx.HF_TOKEN_PATH
|
| 261 |
if getattr(args, "clear", False):
|
| 262 |
+
if not tok_path.exists():
|
| 263 |
+
_say(" No HF token stored — nothing to clear.")
|
| 264 |
+
return
|
| 265 |
try:
|
| 266 |
tok_path.unlink(missing_ok=True)
|
| 267 |
_ok("Removed stored HF token.")
|
|
|
|
| 270 |
return
|
| 271 |
if getattr(args, "show", False):
|
| 272 |
tok = _get_hf_token()
|
| 273 |
+
if not tok or not tok.startswith("hf_") or len(tok) < 10:
|
| 274 |
+
_say(" No valid HF token stored. Run: voice auth")
|
| 275 |
return
|
| 276 |
masked = tok[:4] + "·" * (len(tok) - 8) + tok[-4:] if len(tok) > 8 else "·" * len(tok)
|
| 277 |
src = "environment" if os.environ.get("HF_TOKEN") or os.environ.get("HF_HUB_TOKEN") else str(tok_path)
|
| 278 |
_say(f" ✓ HF token present: {masked} ({src})")
|
| 279 |
return
|
| 280 |
+
if not sys.stdin.isatty():
|
| 281 |
+
_fail(" ✗ voice auth needs an interactive terminal (stdin is piped).")
|
| 282 |
_say(" Paste your HF token (hf_…): it stays on this machine, 0600, never logged.")
|
| 283 |
try:
|
| 284 |
try:
|
|
|
|
| 287 |
tok = input(" Paste HF token: ").strip()
|
| 288 |
except (EOFError, KeyboardInterrupt):
|
| 289 |
_say(" ⚠ Cancelled.")
|
| 290 |
+
sys.exit(1)
|
| 291 |
if not tok:
|
| 292 |
_say(" ⚠ No token entered.")
|
| 293 |
+
sys.exit(1)
|
| 294 |
if not tok.startswith("hf_") or len(tok) < 10:
|
| 295 |
_fail(" ✗ That doesn't look like an HF token (should start with hf_…).")
|
| 296 |
_step("Verifying…")
|
|
|
|
| 374 |
except OSError:
|
| 375 |
_fail(f" ✗ 'voice' on PATH isn't ours ({existing}). Remove or rename it, then retry.")
|
| 376 |
if Path(old_target).name != "voice.py":
|
| 377 |
+
_fail(f" ✗ '{existing}' isn't a voice install (points at {old_target}). Remove it (e.g. sudo mv {existing} {existing}.bak), then retry.")
|
| 378 |
try:
|
| 379 |
Path(existing).unlink()
|
| 380 |
Path(existing).symlink_to(str(script))
|
|
|
|
| 408 |
if (venv / "bin" / "python").exists():
|
| 409 |
_say(f" venv {venv} present")
|
| 410 |
else:
|
| 411 |
+
_say(f" venv not created yet (created on first get/cast/delta)")
|
| 412 |
try:
|
| 413 |
free = shutil.disk_usage(ctx.VOICES_DIR if ctx.VOICES_DIR.exists() else Path.home()).free
|
| 414 |
_say(f" disk free {free/1e9:.1f} GB")
|
|
|
|
| 440 |
pass
|
| 441 |
else:
|
| 442 |
_say(f" reports: none yet — run: voice report")
|
| 443 |
+
_step("Checking connectivity…")
|
| 444 |
try:
|
| 445 |
req = urllib.request.Request("https://huggingface.co/api/whoami-v2" if tok else "https://huggingface.co",
|
| 446 |
headers=_hf_auth_headers("https://huggingface.co"))
|
|
|
|
| 468 |
|
| 469 |
|
| 470 |
def _print_completion(shell):
|
| 471 |
+
cmds = ["get", "cast", "delta", "add", "list", "info", "remove", "cleanup", "auth", "report", "path", "doctor"]
|
| 472 |
voices = [d.name for d in _iter_voices() if (d / "voice.json").exists()]
|
| 473 |
vlist = " ".join(voices)
|
| 474 |
clist = " ".join(cmds)
|
vlib/cmds_voices.py
CHANGED
|
@@ -8,14 +8,14 @@ import sys
|
|
| 8 |
import urllib.error
|
| 9 |
import urllib.request
|
| 10 |
from vlib import ctx
|
| 11 |
-
from vlib.ui import _fail, _noninteractive, _note, _now_iso, _ok, _say, _step
|
| 12 |
from vlib.net import _cleanup_tmp, _safe_id
|
| 13 |
from vlib.tensors import _is_delta_safetensors, _is_gguf_file, read_safetensors, write_safetensors
|
| 14 |
from vlib.sources import _NAME_RULES, _base_paths, _family, _hf_license, _nested, _public_source, _sanitize_voice_name, _slugify_voice_name, open_source
|
| 15 |
from vlib.fetch import _fetch_pack, _fetch_tensor, _resolve_output_name, _source_arch, _write_fetched, _write_voicepack_json
|
| 16 |
from vlib.registry import _assert_not_symlink, _check_overwrite, _out_path, _read_meta, _registry_folder, _registry_name_exists, _registry_resolve, _resolve_name, _write_voice, log_operation
|
| 17 |
from vlib.cache import _ensure_base_tensors
|
| 18 |
-
from vlib.compute import _cast_core, _cast_pack, _load_tensor, _load_voice, _parse_exclude_list, _parse_tensor_list, _resolve_one_tensor, _tensor_src_meta
|
| 19 |
from vlib.delta import _choose_voice, _compute_delta, _resolve_base
|
| 20 |
|
| 21 |
|
|
@@ -23,7 +23,9 @@ def cmd_get(args):
|
|
| 23 |
source_id = args.source.strip().rstrip("/")
|
| 24 |
if not source_id:
|
| 25 |
_fail(" ✗ Enter a model name — for example: voice get google/gemma-3-1b")
|
| 26 |
-
|
|
|
|
|
|
|
| 27 |
|
| 28 |
try:
|
| 29 |
source = open_source(source_id)
|
|
@@ -55,13 +57,15 @@ def cmd_get(args):
|
|
| 55 |
if ctx.VERBOSE:
|
| 56 |
import traceback
|
| 57 |
_say(traceback.format_exc())
|
|
|
|
|
|
|
| 58 |
_fail(f" ✗ Could not reach the model. Check your connection ({type(e).__name__}).")
|
| 59 |
|
| 60 |
if want_multi or len(resolved) > 1:
|
| 61 |
# Multi-pack -> voicepack.safetensors + voicepack.json (file output, not the registry).
|
| 62 |
if getattr(args, "name", None):
|
| 63 |
_fail(" ✗ --name is for registry voices; packs save to files. Drop --name or the extra tensors.")
|
| 64 |
-
out = Path(getattr(args, "out", None) or (Path.cwd() / "voicepack.safetensors"))
|
| 65 |
out.parent.mkdir(parents=True, exist_ok=True)
|
| 66 |
_check_overwrite(str(out), args)
|
| 67 |
pack = _fetch_pack(source, source_id, resolved)
|
|
@@ -78,9 +82,7 @@ def cmd_get(args):
|
|
| 78 |
ref = source.ref(tname)
|
| 79 |
if getattr(args, "out", None):
|
| 80 |
# Standalone file; --name has no meaning here.
|
| 81 |
-
|
| 82 |
-
_fail(" ✗ --name is for registry voices; --out writes a standalone file. Drop one.")
|
| 83 |
-
out = Path(args.out)
|
| 84 |
out.parent.mkdir(parents=True, exist_ok=True)
|
| 85 |
_check_overwrite(str(out), args)
|
| 86 |
_step(f"Extracting {tname} ({ref.dtype} {tuple(ref.shape)})…")
|
|
@@ -102,11 +104,13 @@ def cmd_get(args):
|
|
| 102 |
# name the voice
|
| 103 |
default_name = source_id.split("/")[-1].split("@")[0].split(":")[0].replace(".gguf", "").replace(".safetensors", "")
|
| 104 |
name = _resolve_name(args, default_name)
|
|
|
|
|
|
|
| 105 |
folder = _registry_folder(name)
|
| 106 |
if _registry_name_exists(name) and folder.exists() and ((folder / "voice.safetensors").exists() or (folder / "voice.gguf").exists()):
|
| 107 |
_check_overwrite(str(folder), args)
|
| 108 |
|
| 109 |
-
_step(f"Downloading {tname}…")
|
| 110 |
tmp_dir = ctx.VOICES_DIR / ".parts" / _safe_id(source_id, tname)
|
| 111 |
try:
|
| 112 |
fetched = _fetch_tensor(source, tname, tmp_dir)
|
|
@@ -147,8 +151,42 @@ def cmd_get(args):
|
|
| 147 |
_say(f" Use it: voice cast <your-model.gguf> {name}")
|
| 148 |
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
def cmd_cast(args):
|
| 151 |
-
target = args.target
|
| 152 |
if not os.path.exists(target):
|
| 153 |
_fail(f' ✗ "{target}" couldn\'t be found.')
|
| 154 |
if os.path.isdir(target):
|
|
@@ -158,7 +196,6 @@ def cmd_cast(args):
|
|
| 158 |
voice_path, voice_meta = _registry_resolve(voice_arg)
|
| 159 |
if voice_path is None or not voice_path.exists():
|
| 160 |
_fail(f" ✗ Voice '{voice_arg}' not found. Use 'voice list' or pass a .safetensors/.gguf path.")
|
| 161 |
-
|
| 162 |
target_format = "gguf" if _is_gguf_file(target) else "safetensors"
|
| 163 |
out_path = _out_path(args, target, voice_arg)
|
| 164 |
_check_overwrite(out_path, args)
|
|
@@ -190,15 +227,23 @@ def cmd_cast(args):
|
|
| 190 |
_fail(" ✗ --exclude removes all selected tensors. Nothing to cast.")
|
| 191 |
if len(selected) > 1:
|
| 192 |
_cast_pack(target, str(voice_path), out_path, args, op="cast",
|
| 193 |
-
excludes=[n for n in _pack_names if n not in selected], meta=voice_meta
|
|
|
|
| 194 |
return
|
| 195 |
f32, ref, raw, qtype = _load_tensor(str(voice_path), selected[0])
|
| 196 |
src_meta = voice_meta if voice_meta is not None else _tensor_src_meta(str(voice_path))
|
| 197 |
-
_cast_core(target, target_format, out_path, f32, ref, src_meta, args, op="cast", vraw=raw, vqtype=qtype
|
|
|
|
| 198 |
return
|
| 199 |
if len(_pack_names) > 1:
|
| 200 |
_cast_pack(target, str(voice_path), out_path, args, op="cast", excludes=excludes, meta=voice_meta)
|
| 201 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
|
| 203 |
# auto-detect delta file via marker even without voice.json (e.g. shipped style.safetensors)
|
| 204 |
# do this after _check_overwrite so prompt and Detected don't interleave
|
|
@@ -263,7 +308,7 @@ def cmd_delta(args):
|
|
| 263 |
sanitized = _sanitize_voice_name(chosen) or _slugify_voice_name(chosen)
|
| 264 |
except (EOFError, KeyboardInterrupt):
|
| 265 |
_say(" ⚠ Cancelled.")
|
| 266 |
-
sys.exit(
|
| 267 |
if sanitized is None:
|
| 268 |
sanitized = "voice"
|
| 269 |
# keep original path for _compute_delta, but use sanitized name for delta naming / messages
|
|
@@ -283,16 +328,16 @@ def cmd_delta(args):
|
|
| 283 |
else:
|
| 284 |
# exists but not file/dir? treat as registry name
|
| 285 |
if "/" in voicename or "\\" in voicename or "." in voicename or _sanitize_voice_name(voicename.replace("delta-", "", 1) if voicename.lower().startswith("delta-") else voicename) is None:
|
| 286 |
-
_fail(" ✗ Invalid
|
| 287 |
voice_path, voice_meta = _registry_resolve(voicename)
|
| 288 |
if voice_path is None or not voice_path.exists():
|
| 289 |
-
_fail(f" ✗ Voice '{voicename}' not found. Try voice list")
|
| 290 |
else:
|
| 291 |
if "/" in voicename or "\\" in voicename or "." in voicename or _sanitize_voice_name(voicename.replace("delta-", "", 1) if voicename.lower().startswith("delta-") else voicename) is None:
|
| 292 |
-
_fail(" ✗ Invalid
|
| 293 |
voice_path, voice_meta = _registry_resolve(voicename)
|
| 294 |
if voice_path is None or not voice_path.exists():
|
| 295 |
-
_fail(f" ✗ Voice '{voicename}' not found. Try voice list")
|
| 296 |
# handle file-mode delta naming already set; for registry mode voice_path/voice_meta already resolved
|
| 297 |
if _voice_file_mode:
|
| 298 |
# voice_path already set, ensure it exists
|
|
@@ -303,7 +348,7 @@ def cmd_delta(args):
|
|
| 303 |
pass
|
| 304 |
|
| 305 |
source_hf = (voice_meta or {}).get("source_hf_model") or (voice_meta or {}).get("source") or "—"
|
| 306 |
-
_say(f" '{voicename}'
|
| 307 |
|
| 308 |
# --base may be an HF repo (org/model) or a local file/dir path (e.g. /path/to/lm_head.safetensors)
|
| 309 |
base_arg = getattr(args, "base", None)
|
|
@@ -424,20 +469,22 @@ def cmd_add(args):
|
|
| 424 |
try:
|
| 425 |
hdr, tens = read_safetensors(str(st_path))
|
| 426 |
except Exception as e:
|
| 427 |
-
_fail(f" ✗
|
| 428 |
if not tens:
|
| 429 |
_fail(f" ✗ No tensors found in {st_path}")
|
| 430 |
# validate json
|
| 431 |
try:
|
| 432 |
meta = json.loads(js_path.read_text(encoding="utf-8"))
|
| 433 |
except Exception as e:
|
| 434 |
-
_fail(f" ✗ {js_path} is not valid JSON
|
| 435 |
if not isinstance(meta, dict):
|
| 436 |
_fail(f" ✗ {js_path} must contain a JSON object")
|
| 437 |
# determine name: --name > json name > prompt
|
| 438 |
default_name = (meta.get("name") or st_path.stem or "voice").strip()
|
| 439 |
# sanitize default for display
|
| 440 |
name_arg = getattr(args, "name", None)
|
|
|
|
|
|
|
| 441 |
if name_arg and str(name_arg).strip():
|
| 442 |
name = str(name_arg).strip()
|
| 443 |
elif _noninteractive(args):
|
|
@@ -450,7 +497,7 @@ def cmd_add(args):
|
|
| 450 |
name = entered or default_name
|
| 451 |
except (EOFError, KeyboardInterrupt):
|
| 452 |
_say(" ⚠ Cancelled.")
|
| 453 |
-
sys.exit(
|
| 454 |
if _sanitize_voice_name(name) is None:
|
| 455 |
_fail(f" ✗ Invalid name '{name}'. {_NAME_RULES}")
|
| 456 |
folder = _registry_folder(name)
|
|
@@ -476,6 +523,29 @@ def cmd_add(args):
|
|
| 476 |
# ensure meta name matches sanitized folder name (lowercased)
|
| 477 |
meta = dict(meta)
|
| 478 |
meta["name"] = name.strip().lower() if _sanitize_voice_name(name) else name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 479 |
# copy safetensors atomically: use tmp + fsync + replace, 0600
|
| 480 |
tmp_st = dest_st.with_suffix(".tmp")
|
| 481 |
# stream copy with fsync
|
|
@@ -546,6 +616,7 @@ def cmd_add(args):
|
|
| 546 |
except Exception:
|
| 547 |
pass
|
| 548 |
log_operation({"op": "add", "source_st": str(st_path), "source_json": str(js_path), "output": str(folder), "status": "ok"})
|
| 549 |
-
|
|
|
|
| 550 |
_say(f" File: {dest_st} ({dest_st.stat().st_size/1e6:.1f} MB)")
|
| 551 |
-
_say(f" Use it: voice cast <your-model.gguf> {
|
|
|
|
| 8 |
import urllib.error
|
| 9 |
import urllib.request
|
| 10 |
from vlib import ctx
|
| 11 |
+
from vlib.ui import _fail, _noninteractive, _note, _now_iso, _ok, _say, _step, _warn
|
| 12 |
from vlib.net import _cleanup_tmp, _safe_id
|
| 13 |
from vlib.tensors import _is_delta_safetensors, _is_gguf_file, read_safetensors, write_safetensors
|
| 14 |
from vlib.sources import _NAME_RULES, _base_paths, _family, _hf_license, _nested, _public_source, _sanitize_voice_name, _slugify_voice_name, open_source
|
| 15 |
from vlib.fetch import _fetch_pack, _fetch_tensor, _resolve_output_name, _source_arch, _write_fetched, _write_voicepack_json
|
| 16 |
from vlib.registry import _assert_not_symlink, _check_overwrite, _out_path, _read_meta, _registry_folder, _registry_name_exists, _registry_resolve, _resolve_name, _write_voice, log_operation
|
| 17 |
from vlib.cache import _ensure_base_tensors
|
| 18 |
+
from vlib.compute import _cast_core, _cast_pack, _load_tensor, _load_voice, _parse_exclude_list, _parse_tensor_list, _resolve_one_tensor, _resolve_pack_targets, _tensor_src_meta
|
| 19 |
from vlib.delta import _choose_voice, _compute_delta, _resolve_base
|
| 20 |
|
| 21 |
|
|
|
|
| 23 |
source_id = args.source.strip().rstrip("/")
|
| 24 |
if not source_id:
|
| 25 |
_fail(" ✗ Enter a model name — for example: voice get google/gemma-3-1b")
|
| 26 |
+
_lp = Path(source_id).expanduser()
|
| 27 |
+
if (source_id.startswith(("/", "~", "./", "../")) or source_id.endswith((".safetensors", ".gguf", ".bin", ".pt")) or _lp.exists()) and not _lp.exists():
|
| 28 |
+
_fail(f' ✗ "{source_id}" couldn\'t be found.')
|
| 29 |
|
| 30 |
try:
|
| 31 |
source = open_source(source_id)
|
|
|
|
| 57 |
if ctx.VERBOSE:
|
| 58 |
import traceback
|
| 59 |
_say(traceback.format_exc())
|
| 60 |
+
if _lp.exists():
|
| 61 |
+
_fail(f' ✗ "{source_id}" is not a valid model file ({type(e).__name__}).')
|
| 62 |
_fail(f" ✗ Could not reach the model. Check your connection ({type(e).__name__}).")
|
| 63 |
|
| 64 |
if want_multi or len(resolved) > 1:
|
| 65 |
# Multi-pack -> voicepack.safetensors + voicepack.json (file output, not the registry).
|
| 66 |
if getattr(args, "name", None):
|
| 67 |
_fail(" ✗ --name is for registry voices; packs save to files. Drop --name or the extra tensors.")
|
| 68 |
+
out = Path(str(getattr(args, "out", None) or (Path.cwd() / "voicepack.safetensors"))).expanduser()
|
| 69 |
out.parent.mkdir(parents=True, exist_ok=True)
|
| 70 |
_check_overwrite(str(out), args)
|
| 71 |
pack = _fetch_pack(source, source_id, resolved)
|
|
|
|
| 82 |
ref = source.ref(tname)
|
| 83 |
if getattr(args, "out", None):
|
| 84 |
# Standalone file; --name has no meaning here.
|
| 85 |
+
out = Path(str(getattr(args, "out", None))).expanduser()
|
|
|
|
|
|
|
| 86 |
out.parent.mkdir(parents=True, exist_ok=True)
|
| 87 |
_check_overwrite(str(out), args)
|
| 88 |
_step(f"Extracting {tname} ({ref.dtype} {tuple(ref.shape)})…")
|
|
|
|
| 104 |
# name the voice
|
| 105 |
default_name = source_id.split("/")[-1].split("@")[0].split(":")[0].replace(".gguf", "").replace(".safetensors", "")
|
| 106 |
name = _resolve_name(args, default_name)
|
| 107 |
+
if not getattr(args, "name", None):
|
| 108 |
+
_note(f" No --name given; using '{name}'.")
|
| 109 |
folder = _registry_folder(name)
|
| 110 |
if _registry_name_exists(name) and folder.exists() and ((folder / "voice.safetensors").exists() or (folder / "voice.gguf").exists()):
|
| 111 |
_check_overwrite(str(folder), args)
|
| 112 |
|
| 113 |
+
_step(f"{'Reading' if getattr(source, 'path', None) else 'Downloading'} {tname}…")
|
| 114 |
tmp_dir = ctx.VOICES_DIR / ".parts" / _safe_id(source_id, tname)
|
| 115 |
try:
|
| 116 |
fetched = _fetch_tensor(source, tname, tmp_dir)
|
|
|
|
| 151 |
_say(f" Use it: voice cast <your-model.gguf> {name}")
|
| 152 |
|
| 153 |
|
| 154 |
+
def _resolve_single_target(target, target_format, ref):
|
| 155 |
+
"""Route one explicitly requested tensor by role (exact, else one alias,
|
| 156 |
+
else one same-role same-format match). Fails loud with hints instead of
|
| 157 |
+
falling back to the output head — the user named this tensor, so a silent
|
| 158 |
+
wrong-slot write is worse than an error. Default (unnamed) single casts
|
| 159 |
+
keep the legacy output-first fallback in _cast_gguf/_cast_st_prepare."""
|
| 160 |
+
if target_format == "gguf":
|
| 161 |
+
from gguf import GGUFReader
|
| 162 |
+
_r = GGUFReader(target)
|
| 163 |
+
_names = [t.name for t in _r.tensors]
|
| 164 |
+
_counts = {}
|
| 165 |
+
for t in _r.tensors:
|
| 166 |
+
try:
|
| 167 |
+
_c = 1
|
| 168 |
+
for d in t.shape:
|
| 169 |
+
_c *= int(d)
|
| 170 |
+
_counts[t.name] = _c
|
| 171 |
+
except Exception:
|
| 172 |
+
pass
|
| 173 |
+
else:
|
| 174 |
+
_header, _tensors = read_safetensors(target)
|
| 175 |
+
_names = list(_tensors.keys())
|
| 176 |
+
_counts = {}
|
| 177 |
+
for _n, _info in _tensors.items():
|
| 178 |
+
try:
|
| 179 |
+
_c = 1
|
| 180 |
+
for _d in _info["shape"]:
|
| 181 |
+
_c *= int(_d)
|
| 182 |
+
_counts[_n] = _c
|
| 183 |
+
except Exception:
|
| 184 |
+
pass
|
| 185 |
+
return _resolve_pack_targets([(ref.name, ref.shape)], _names, target, _counts)[ref.name]
|
| 186 |
+
|
| 187 |
+
|
| 188 |
def cmd_cast(args):
|
| 189 |
+
target = os.path.expanduser(args.target)
|
| 190 |
if not os.path.exists(target):
|
| 191 |
_fail(f' ✗ "{target}" couldn\'t be found.')
|
| 192 |
if os.path.isdir(target):
|
|
|
|
| 196 |
voice_path, voice_meta = _registry_resolve(voice_arg)
|
| 197 |
if voice_path is None or not voice_path.exists():
|
| 198 |
_fail(f" ✗ Voice '{voice_arg}' not found. Use 'voice list' or pass a .safetensors/.gguf path.")
|
|
|
|
| 199 |
target_format = "gguf" if _is_gguf_file(target) else "safetensors"
|
| 200 |
out_path = _out_path(args, target, voice_arg)
|
| 201 |
_check_overwrite(out_path, args)
|
|
|
|
| 227 |
_fail(" ✗ --exclude removes all selected tensors. Nothing to cast.")
|
| 228 |
if len(selected) > 1:
|
| 229 |
_cast_pack(target, str(voice_path), out_path, args, op="cast",
|
| 230 |
+
excludes=[n for n in _pack_names if n not in selected], meta=voice_meta,
|
| 231 |
+
order=selected)
|
| 232 |
return
|
| 233 |
f32, ref, raw, qtype = _load_tensor(str(voice_path), selected[0])
|
| 234 |
src_meta = voice_meta if voice_meta is not None else _tensor_src_meta(str(voice_path))
|
| 235 |
+
_cast_core(target, target_format, out_path, f32, ref, src_meta, args, op="cast", vraw=raw, vqtype=qtype,
|
| 236 |
+
target_name=_resolve_single_target(target, target_format, ref))
|
| 237 |
return
|
| 238 |
if len(_pack_names) > 1:
|
| 239 |
_cast_pack(target, str(voice_path), out_path, args, op="cast", excludes=excludes, meta=voice_meta)
|
| 240 |
return
|
| 241 |
+
if excludes and _pack_names:
|
| 242 |
+
# Single-tensor voice: honor --exclude instead of silently ignoring it.
|
| 243 |
+
for e in excludes:
|
| 244 |
+
if e in _pack_names or len([n for n in _pack_names if e in n]) == 1:
|
| 245 |
+
_fail(" ✗ --exclude removes all tensors. Nothing to cast.")
|
| 246 |
+
_warn(f" --exclude '{e}' not in voice (has {len(_pack_names)} tensor(s)). Ignoring.")
|
| 247 |
|
| 248 |
# auto-detect delta file via marker even without voice.json (e.g. shipped style.safetensors)
|
| 249 |
# do this after _check_overwrite so prompt and Detected don't interleave
|
|
|
|
| 308 |
sanitized = _sanitize_voice_name(chosen) or _slugify_voice_name(chosen)
|
| 309 |
except (EOFError, KeyboardInterrupt):
|
| 310 |
_say(" ⚠ Cancelled.")
|
| 311 |
+
sys.exit(1)
|
| 312 |
if sanitized is None:
|
| 313 |
sanitized = "voice"
|
| 314 |
# keep original path for _compute_delta, but use sanitized name for delta naming / messages
|
|
|
|
| 328 |
else:
|
| 329 |
# exists but not file/dir? treat as registry name
|
| 330 |
if "/" in voicename or "\\" in voicename or "." in voicename or _sanitize_voice_name(voicename.replace("delta-", "", 1) if voicename.lower().startswith("delta-") else voicename) is None:
|
| 331 |
+
_fail(f" ✗ Invalid name '{voicename}'. {_NAME_RULES}")
|
| 332 |
voice_path, voice_meta = _registry_resolve(voicename)
|
| 333 |
if voice_path is None or not voice_path.exists():
|
| 334 |
+
_fail(f" ✗ Voice '{voicename}' not found. Try: voice list")
|
| 335 |
else:
|
| 336 |
if "/" in voicename or "\\" in voicename or "." in voicename or _sanitize_voice_name(voicename.replace("delta-", "", 1) if voicename.lower().startswith("delta-") else voicename) is None:
|
| 337 |
+
_fail(f" ✗ Invalid name '{voicename}'. {_NAME_RULES}")
|
| 338 |
voice_path, voice_meta = _registry_resolve(voicename)
|
| 339 |
if voice_path is None or not voice_path.exists():
|
| 340 |
+
_fail(f" ✗ Voice '{voicename}' not found. Try: voice list")
|
| 341 |
# handle file-mode delta naming already set; for registry mode voice_path/voice_meta already resolved
|
| 342 |
if _voice_file_mode:
|
| 343 |
# voice_path already set, ensure it exists
|
|
|
|
| 348 |
pass
|
| 349 |
|
| 350 |
source_hf = (voice_meta or {}).get("source_hf_model") or (voice_meta or {}).get("source") or "—"
|
| 351 |
+
_say(f" Source of '{voicename}': {source_hf}")
|
| 352 |
|
| 353 |
# --base may be an HF repo (org/model) or a local file/dir path (e.g. /path/to/lm_head.safetensors)
|
| 354 |
base_arg = getattr(args, "base", None)
|
|
|
|
| 469 |
try:
|
| 470 |
hdr, tens = read_safetensors(str(st_path))
|
| 471 |
except Exception as e:
|
| 472 |
+
_fail(f" ✗ Not a valid .safetensors file: {e}")
|
| 473 |
if not tens:
|
| 474 |
_fail(f" ✗ No tensors found in {st_path}")
|
| 475 |
# validate json
|
| 476 |
try:
|
| 477 |
meta = json.loads(js_path.read_text(encoding="utf-8"))
|
| 478 |
except Exception as e:
|
| 479 |
+
_fail(f" ✗ {js_path} is not valid JSON ({e}). Re-export voice.json or check it with: python3 -m json.tool {js_path}")
|
| 480 |
if not isinstance(meta, dict):
|
| 481 |
_fail(f" ✗ {js_path} must contain a JSON object")
|
| 482 |
# determine name: --name > json name > prompt
|
| 483 |
default_name = (meta.get("name") or st_path.stem or "voice").strip()
|
| 484 |
# sanitize default for display
|
| 485 |
name_arg = getattr(args, "name", None)
|
| 486 |
+
if name_arg is not None and not str(name_arg).strip():
|
| 487 |
+
_fail(f" ✗ Empty --name. {_NAME_RULES}")
|
| 488 |
if name_arg and str(name_arg).strip():
|
| 489 |
name = str(name_arg).strip()
|
| 490 |
elif _noninteractive(args):
|
|
|
|
| 497 |
name = entered or default_name
|
| 498 |
except (EOFError, KeyboardInterrupt):
|
| 499 |
_say(" ⚠ Cancelled.")
|
| 500 |
+
sys.exit(1)
|
| 501 |
if _sanitize_voice_name(name) is None:
|
| 502 |
_fail(f" ✗ Invalid name '{name}'. {_NAME_RULES}")
|
| 503 |
folder = _registry_folder(name)
|
|
|
|
| 523 |
# ensure meta name matches sanitized folder name (lowercased)
|
| 524 |
meta = dict(meta)
|
| 525 |
meta["name"] = name.strip().lower() if _sanitize_voice_name(name) else name
|
| 526 |
+
meta.setdefault("downloaded_at", _now_iso())
|
| 527 |
+
if not meta.get("tensors") and not meta.get("tensor_name"):
|
| 528 |
+
_tl = [{"name": n, "shape": list(tens[n]["shape"]), "dtype": tens[n]["dtype"]} for n in tens if n != "delta.voice.marker"]
|
| 529 |
+
if _tl:
|
| 530 |
+
meta["tensors"] = _tl
|
| 531 |
+
if len(_tl) == 1:
|
| 532 |
+
meta["tensor_name"], meta["shape"], meta["dtype"] = _tl[0]["name"], _tl[0]["shape"], _tl[0]["dtype"]
|
| 533 |
+
try:
|
| 534 |
+
meta.setdefault("bytes", int(st_path.stat().st_size))
|
| 535 |
+
except Exception:
|
| 536 |
+
pass
|
| 537 |
+
elif isinstance(meta.get("tensors"), list):
|
| 538 |
+
# Entries may be bare strings or dicts missing shape/dtype
|
| 539 |
+
# (hand-written json): enrich from the validated header.
|
| 540 |
+
_fixed = []
|
| 541 |
+
for e in meta["tensors"]:
|
| 542 |
+
_d = {"name": e} if isinstance(e, str) else dict(e)
|
| 543 |
+
_n = _d.get("name")
|
| 544 |
+
if _n in tens and (not _d.get("shape") or not _d.get("dtype")):
|
| 545 |
+
_d["shape"] = list(tens[_n]["shape"])
|
| 546 |
+
_d["dtype"] = tens[_n]["dtype"]
|
| 547 |
+
_fixed.append(_d)
|
| 548 |
+
meta["tensors"] = _fixed
|
| 549 |
# copy safetensors atomically: use tmp + fsync + replace, 0600
|
| 550 |
tmp_st = dest_st.with_suffix(".tmp")
|
| 551 |
# stream copy with fsync
|
|
|
|
| 616 |
except Exception:
|
| 617 |
pass
|
| 618 |
log_operation({"op": "add", "source_st": str(st_path), "source_json": str(js_path), "output": str(folder), "status": "ok"})
|
| 619 |
+
_stored = meta["name"]
|
| 620 |
+
_ok(f"Added voice '{_stored}' → {folder}")
|
| 621 |
_say(f" File: {dest_st} ({dest_st.stat().st_size/1e6:.1f} MB)")
|
| 622 |
+
_say(f" Use it: voice cast <your-model.gguf> {_stored}")
|
vlib/compute.py
CHANGED
|
@@ -71,6 +71,13 @@ def _cast_st_prepare(target, tensors, vf32, vref, meta, args, vraw=None, vqtype=
|
|
| 71 |
if _qo in ("f32", "f16", "bf16"):
|
| 72 |
_want = {"f32": "F32", "f16": "F16", "bf16": "BF16"}[_qo]
|
| 73 |
if _want != tdtype.upper():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
_warn(f" Re-encoding target {tdtype} → {_want} for --quant {_qo} (extra conversion).")
|
| 75 |
tdtype = _want
|
| 76 |
# Show quant/target by default for tensor commands (advanced) and verbose for voice.
|
|
@@ -98,28 +105,31 @@ def _cast_st_prepare(target, tensors, vf32, vref, meta, args, vraw=None, vqtype=
|
|
| 98 |
return tname, data, tdtype, tshape
|
| 99 |
|
| 100 |
|
| 101 |
-
def _cast_core(target, target_format, out_path, vf32, vref, meta, args, op="cast", vraw=None, vqtype=None, strict_target=False):
|
| 102 |
if getattr(args, "speak", False) and target_format != "gguf":
|
| 103 |
-
_fail(" ✗ --speak needs a .gguf target.")
|
| 104 |
if target_format == "gguf":
|
| 105 |
-
_cast_gguf(target, out_path, vf32, vref, meta, args, op, vraw=vraw, vqtype=vqtype, strict_target=strict_target)
|
| 106 |
return
|
| 107 |
# safetensors target
|
| 108 |
header, tensors = read_safetensors(target)
|
| 109 |
t0s = time.time()
|
| 110 |
tname, data, tdtype, tshape = _cast_st_prepare(target, tensors, vf32, vref, meta, args,
|
| 111 |
-
vraw=vraw, vqtype=vqtype, strict_target=strict_target
|
|
|
|
| 112 |
_step(f"Replacing {tname} ({tdtype} {tshape})…")
|
| 113 |
rewrite_safetensors_tensor(target, out_path, tname, data, tdtype, tshape)
|
| 114 |
file_size = os.path.getsize(out_path)
|
| 115 |
try:
|
| 116 |
-
|
|
|
|
|
|
|
| 117 |
except Exception:
|
| 118 |
pass
|
| 119 |
log_operation({"op": op, "target": target, "format": "safetensors", "tensor": tname,
|
| 120 |
"dtype": tdtype, "shape": list(tshape), "output": out_path, "status": "ok"})
|
| 121 |
_ok(f"Done → {out_path}")
|
| 122 |
-
_say(f"
|
| 123 |
|
| 124 |
|
| 125 |
def _is_head_name(name):
|
|
@@ -320,7 +330,7 @@ def _gguf_fuse_one(target, target_tensor, tname, logical, vf32, vref, meta, args
|
|
| 320 |
except Exception as e:
|
| 321 |
_fail(f" ✗ Could not dequant voice for --quant target: {e}")
|
| 322 |
if _is_delta:
|
| 323 |
-
_f32v = _fuse_delta(target_tensor, _f32v)
|
| 324 |
t_quant0 = time.time()
|
| 325 |
_tq2 = target_tensor.tensor_type
|
| 326 |
if _tq2 in (Q.F32,):
|
|
@@ -352,7 +362,7 @@ def _gguf_fuse_one(target, target_tensor, tname, logical, vf32, vref, meta, args
|
|
| 352 |
except Exception as e:
|
| 353 |
_fail(f" ✗ Could not dequant voice for --quant {_quant_override}: {e}")
|
| 354 |
if _is_delta:
|
| 355 |
-
_f32v = _fuse_delta(target_tensor, _f32v)
|
| 356 |
_qn = _quant_from_key(_quant_override)
|
| 357 |
if _qn is None:
|
| 358 |
_fail(f" ✗ Invalid --quant '{_quant_override}'.")
|
|
@@ -494,7 +504,7 @@ def _gguf_fuse_one(target, target_tensor, tname, logical, vf32, vref, meta, args
|
|
| 494 |
_ans = input(f" Press enter to quantize to {_tqn} or enter custom quant (any like Q8_0/Q4_0/Q6_K/F16/F32/BF16): ").strip()
|
| 495 |
except (EOFError, KeyboardInterrupt):
|
| 496 |
_say(" ⚠ Cancelled.")
|
| 497 |
-
sys.exit(
|
| 498 |
_ans_n = _ans.strip().upper().replace("-", "_")
|
| 499 |
if _ans.strip() == "" or _ans_n == _tqn.upper():
|
| 500 |
pass
|
|
@@ -516,7 +526,9 @@ def _gguf_fuse_one(target, target_tensor, tname, logical, vf32, vref, meta, args
|
|
| 516 |
except Exception as e:
|
| 517 |
_fail(f" ✗ Could not quant to {_cq.name}: {e}")
|
| 518 |
_note(f"Quantized {fused.nbytes/1e6:.1f} MB → {_cq.name} @ {(fused.nbytes/1e6)/max(time.time()-t_quant0,1e-6):.0f} MB/s")
|
| 519 |
-
|
|
|
|
|
|
|
| 520 |
_custom_done = True
|
| 521 |
# keep-target path (default, silent when match, Enter=target when mismatch)
|
| 522 |
if not _custom_done:
|
|
@@ -545,17 +557,19 @@ def _gguf_fuse_one(target, target_tensor, tname, logical, vf32, vref, meta, args
|
|
| 545 |
_warn(f" {_tqn} not encodable ({_qerr(e)}); keeping {_near.name} (nearest size) instead of F16.")
|
| 546 |
q_head, out_qtype = _quantize_to_Q(fused, _near)
|
| 547 |
else:
|
| 548 |
-
_warn(f" Could not quant to {_tqn} ({_qerr(e)}), keeping F16.")
|
| 549 |
q_head, out_qtype = fused.astype(np.float16), Q.F16
|
| 550 |
try:
|
| 551 |
-
|
|
|
|
| 552 |
except Exception:
|
| 553 |
pass
|
| 554 |
try:
|
| 555 |
t_fuse0
|
| 556 |
except Exception:
|
| 557 |
t_fuse0 = time.time()
|
| 558 |
-
|
|
|
|
|
|
|
| 559 |
return q_head, out_qtype
|
| 560 |
|
| 561 |
|
|
@@ -653,6 +667,7 @@ def _gguf_write_repl(target, reader, arch, repl, out_path, args, op, detail=None
|
|
| 653 |
# progress poll for GGUF write (local disk, but user is waiting)
|
| 654 |
import threading
|
| 655 |
_stop_poll = [False]
|
|
|
|
| 656 |
def _poll_gguf():
|
| 657 |
# poll output file (or temp file) size
|
| 658 |
target_path = getattr(writer, 'fname', out_path)
|
|
@@ -690,7 +705,8 @@ def _gguf_write_repl(target, reader, arch, repl, out_path, args, op, detail=None
|
|
| 690 |
pass
|
| 691 |
time.sleep(0.25)
|
| 692 |
_thr = threading.Thread(target=_poll_gguf, daemon=True)
|
| 693 |
-
|
|
|
|
| 694 |
try:
|
| 695 |
writer.write_header_to_file()
|
| 696 |
writer.write_kv_data_to_file()
|
|
@@ -698,24 +714,27 @@ def _gguf_write_repl(target, reader, arch, repl, out_path, args, op, detail=None
|
|
| 698 |
writer.close()
|
| 699 |
except Exception as e:
|
| 700 |
_stop_poll[0] = True
|
| 701 |
-
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
|
|
|
|
| 705 |
sys.stdout.write("\n")
|
| 706 |
if ctx.VERBOSE:
|
| 707 |
_say(f" Details: {e}")
|
| 708 |
_fail(f" ✗ Could not save the voiced model to {out_path}.")
|
| 709 |
_stop_poll[0] = True
|
| 710 |
-
|
| 711 |
-
|
| 712 |
-
|
| 713 |
-
|
| 714 |
-
|
|
|
|
| 715 |
elapsed_w = time.time() - t_write0 or 1e-6
|
| 716 |
try:
|
| 717 |
final_sz = os.path.getsize(out_path)
|
| 718 |
-
|
|
|
|
| 719 |
except Exception:
|
| 720 |
pass
|
| 721 |
|
|
@@ -779,7 +798,7 @@ def _confirm_arch_mismatch(varch, arch, args):
|
|
| 779 |
_warn(f"This voice was trained for a {varch} model, but the target is {arch}. It may not sound right.")
|
| 780 |
if not _confirm(" Continue anyway? [y/N]: ", args):
|
| 781 |
_note("Cancelled.")
|
| 782 |
-
sys.exit(
|
| 783 |
|
| 784 |
|
| 785 |
def _cast_gguf_speak(target, reader, arch, out_path, vf32, vref, meta, args, op, vraw=None, vqtype=None):
|
|
@@ -809,8 +828,8 @@ def _cast_gguf_speak(target, reader, arch, out_path, vf32, vref, meta, args, op,
|
|
| 809 |
_fail(f" ✗ Voice shape {vref.shape} doesn't fit {tname} {olog}.")
|
| 810 |
_qo = _parse_quant_override(getattr(args, "quant", None) or "keep")
|
| 811 |
if _qo not in ("keep",):
|
| 812 |
-
fitted = _gguf_raw_to_f32(vraw, _vqtype, tuple(int(x) for x in vref.shape))
|
| 813 |
-
q_head, out_qtype = _quantize_to_Q(np.ascontiguousarray(fitted), Q[_qo])
|
| 814 |
else:
|
| 815 |
_need = 1
|
| 816 |
for _d in quant_shape_to_byte_shape(tuple(int(x) for x in vref.shape), _vqtype):
|
|
@@ -830,21 +849,21 @@ def _cast_gguf_speak(target, reader, arch, out_path, vf32, vref, meta, args, op,
|
|
| 830 |
if _qo is None:
|
| 831 |
_fail(f" ✗ Invalid --quant '{getattr(args, 'quant', None)}'.")
|
| 832 |
if _qo not in ("keep",):
|
| 833 |
-
q_head, out_qtype = _quantize_to_Q(fitted, Q[_qo])
|
| 834 |
elif fitted.shape[-1] % 32 == 0:
|
| 835 |
q_head, out_qtype = quantize(fitted, Q.Q8_0), Q.Q8_0
|
| 836 |
else:
|
| 837 |
-
_note(" last dim not
|
| 838 |
q_head, out_qtype = fitted.astype(np.float16), Q.F16
|
| 839 |
if invented:
|
| 840 |
-
_note("speak: voice
|
| 841 |
else:
|
| 842 |
-
_note("speak: voice
|
| 843 |
_gguf_write_repl(target, reader, arch, {tname: (q_head, out_qtype)}, out_path, args, op,
|
| 844 |
detail=(tname, olog, vref, vraw, vqtype, meta),
|
| 845 |
_extra_names=(tname,) if invented else ())
|
| 846 |
|
| 847 |
-
def _cast_gguf(target, out_path, vf32, vref, meta, args, op, vraw=None, vqtype=None, strict_target=False):
|
| 848 |
import numpy as np
|
| 849 |
from gguf import GGUFReader
|
| 850 |
|
|
@@ -855,7 +874,15 @@ def _cast_gguf(target, out_path, vf32, vref, meta, args, op, vraw=None, vqtype=N
|
|
| 855 |
_cast_gguf_speak(target, reader, arch, out_path, vf32, vref, meta, args, op, vraw=vraw, vqtype=vqtype)
|
| 856 |
return
|
| 857 |
target_tensor = None
|
| 858 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 859 |
for t in reader.tensors:
|
| 860 |
if t.name == vref.name:
|
| 861 |
target_tensor = t
|
|
@@ -943,8 +970,10 @@ def _role_key(name):
|
|
| 943 |
Trailing role is everything after the block number (e.g.
|
| 944 |
'self_attn.o_proj.weight'); unblocked names fall back to their last two
|
| 945 |
components (e.g. 'embed_tokens.weight'). The .weight/.bias suffix stays
|
| 946 |
-
in the key so a bias never matches a weight. The block
|
| 947 |
-
left-guarded
|
|
|
|
|
|
|
| 948 |
import re
|
| 949 |
m = re.search(r"(?<![A-Za-z0-9_])(?:layers|layer|blk|blks|blocks|h)\.(\d+)\b", name)
|
| 950 |
if m:
|
|
@@ -1044,10 +1073,13 @@ def _resolve_pack_targets(pairs, target_names, target, counts=None):
|
|
| 1044 |
return mapping
|
| 1045 |
|
| 1046 |
|
| 1047 |
-
def _cast_pack(target, src_path, out_path, args, op, excludes=(), meta=None):
|
| 1048 |
"""Cast every tensor in a pack file onto target (minus excludes).
|
| 1049 |
GGUF and safetensors targets each get one write pass (repl-dict fused first).
|
| 1050 |
-
Delta marker on the pack is detected once and threaded into every tensor.
|
|
|
|
|
|
|
|
|
|
| 1051 |
src = open_source(str(src_path))
|
| 1052 |
all_names = [n for n in src.names() if n != "delta.voice.marker"]
|
| 1053 |
for e in excludes:
|
|
@@ -1062,7 +1094,12 @@ def _cast_pack(target, src_path, out_path, args, op, excludes=(), meta=None):
|
|
| 1062 |
_m = [n for n in all_names if e in n]
|
| 1063 |
if len(_m) == 1:
|
| 1064 |
resolved_ex.add(_m[0])
|
|
|
|
|
|
|
| 1065 |
to_cast = [n for n in all_names if n not in resolved_ex]
|
|
|
|
|
|
|
|
|
|
| 1066 |
if not to_cast:
|
| 1067 |
_fail(" ✗ --exclude removes all tensors. Nothing to cast.")
|
| 1068 |
_step(f"Casting {len(to_cast)} tensors from {Path(src_path).name} onto {Path(target).name}…")
|
|
|
|
| 71 |
if _qo in ("f32", "f16", "bf16"):
|
| 72 |
_want = {"f32": "F32", "f16": "F16", "bf16": "BF16"}[_qo]
|
| 73 |
if _want != tdtype.upper():
|
| 74 |
+
from vlib.tensors import dtype_bytes as _db
|
| 75 |
+
try:
|
| 76 |
+
_same_size = _db(_want) == _db(tdtype.upper())
|
| 77 |
+
except Exception:
|
| 78 |
+
_same_size = False
|
| 79 |
+
if not _same_size:
|
| 80 |
+
_fail(f" ✗ --quant {_qo} would change '{tname}' {tdtype} → {_want} (different byte size; safetensors casts keep byte size). Use --quant keep|target.")
|
| 81 |
_warn(f" Re-encoding target {tdtype} → {_want} for --quant {_qo} (extra conversion).")
|
| 82 |
tdtype = _want
|
| 83 |
# Show quant/target by default for tensor commands (advanced) and verbose for voice.
|
|
|
|
| 105 |
return tname, data, tdtype, tshape
|
| 106 |
|
| 107 |
|
| 108 |
+
def _cast_core(target, target_format, out_path, vf32, vref, meta, args, op="cast", vraw=None, vqtype=None, strict_target=False, target_name=None):
|
| 109 |
if getattr(args, "speak", False) and target_format != "gguf":
|
| 110 |
+
_fail(" ✗ --speak needs a .gguf target. Re-run without --speak for .safetensors, or point cast at a .gguf file.")
|
| 111 |
if target_format == "gguf":
|
| 112 |
+
_cast_gguf(target, out_path, vf32, vref, meta, args, op, vraw=vraw, vqtype=vqtype, strict_target=strict_target, target_name=target_name)
|
| 113 |
return
|
| 114 |
# safetensors target
|
| 115 |
header, tensors = read_safetensors(target)
|
| 116 |
t0s = time.time()
|
| 117 |
tname, data, tdtype, tshape = _cast_st_prepare(target, tensors, vf32, vref, meta, args,
|
| 118 |
+
vraw=vraw, vqtype=vqtype, strict_target=strict_target,
|
| 119 |
+
target_name=target_name)
|
| 120 |
_step(f"Replacing {tname} ({tdtype} {tshape})…")
|
| 121 |
rewrite_safetensors_tensor(target, out_path, tname, data, tdtype, tshape)
|
| 122 |
file_size = os.path.getsize(out_path)
|
| 123 |
try:
|
| 124 |
+
_mb = len(data) / 1e6
|
| 125 |
+
_rate = f" @ {(_mb) / max(time.time() - t0s, 1e-6):.0f} MB/s" if _mb >= 0.1 else ""
|
| 126 |
+
_note(f"Kept '{tname}': {_mb:.1f} MB → {tdtype}{_rate}")
|
| 127 |
except Exception:
|
| 128 |
pass
|
| 129 |
log_operation({"op": op, "target": target, "format": "safetensors", "tensor": tname,
|
| 130 |
"dtype": tdtype, "shape": list(tshape), "output": out_path, "status": "ok"})
|
| 131 |
_ok(f"Done → {out_path}")
|
| 132 |
+
_say(f" Saved → {out_path} ({tdtype} {list(tshape)})")
|
| 133 |
|
| 134 |
|
| 135 |
def _is_head_name(name):
|
|
|
|
| 330 |
except Exception as e:
|
| 331 |
_fail(f" ✗ Could not dequant voice for --quant target: {e}")
|
| 332 |
if _is_delta:
|
| 333 |
+
_f32v = _fuse_delta(target_tensor, _f32v, strict=True)
|
| 334 |
t_quant0 = time.time()
|
| 335 |
_tq2 = target_tensor.tensor_type
|
| 336 |
if _tq2 in (Q.F32,):
|
|
|
|
| 362 |
except Exception as e:
|
| 363 |
_fail(f" ✗ Could not dequant voice for --quant {_quant_override}: {e}")
|
| 364 |
if _is_delta:
|
| 365 |
+
_f32v = _fuse_delta(target_tensor, _f32v, strict=True)
|
| 366 |
_qn = _quant_from_key(_quant_override)
|
| 367 |
if _qn is None:
|
| 368 |
_fail(f" ✗ Invalid --quant '{_quant_override}'.")
|
|
|
|
| 504 |
_ans = input(f" Press enter to quantize to {_tqn} or enter custom quant (any like Q8_0/Q4_0/Q6_K/F16/F32/BF16): ").strip()
|
| 505 |
except (EOFError, KeyboardInterrupt):
|
| 506 |
_say(" ⚠ Cancelled.")
|
| 507 |
+
sys.exit(1)
|
| 508 |
_ans_n = _ans.strip().upper().replace("-", "_")
|
| 509 |
if _ans.strip() == "" or _ans_n == _tqn.upper():
|
| 510 |
pass
|
|
|
|
| 526 |
except Exception as e:
|
| 527 |
_fail(f" ✗ Could not quant to {_cq.name}: {e}")
|
| 528 |
_note(f"Quantized {fused.nbytes/1e6:.1f} MB → {_cq.name} @ {(fused.nbytes/1e6)/max(time.time()-t_quant0,1e-6):.0f} MB/s")
|
| 529 |
+
_fd = time.time() - t_fuse0
|
| 530 |
+
if _fd >= 0.5:
|
| 531 |
+
_note(f"Fusing done in {_fd:.1f}s")
|
| 532 |
_custom_done = True
|
| 533 |
# keep-target path (default, silent when match, Enter=target when mismatch)
|
| 534 |
if not _custom_done:
|
|
|
|
| 557 |
_warn(f" {_tqn} not encodable ({_qerr(e)}); keeping {_near.name} (nearest size) instead of F16.")
|
| 558 |
q_head, out_qtype = _quantize_to_Q(fused, _near)
|
| 559 |
else:
|
|
|
|
| 560 |
q_head, out_qtype = fused.astype(np.float16), Q.F16
|
| 561 |
try:
|
| 562 |
+
_mbk = fused.nbytes / 1e6
|
| 563 |
+
_note(f"Kept '{tname}': {_mbk:.1f} MB → {out_qtype.name}" + (f" @ {_mbk / max(time.time() - t_quant0, 1e-6):.0f} MB/s" if fused.nbytes >= 100000 else ""))
|
| 564 |
except Exception:
|
| 565 |
pass
|
| 566 |
try:
|
| 567 |
t_fuse0
|
| 568 |
except Exception:
|
| 569 |
t_fuse0 = time.time()
|
| 570 |
+
_fd = time.time() - t_fuse0
|
| 571 |
+
if _fd >= 0.5:
|
| 572 |
+
_note(f"Fusing done in {_fd:.1f}s")
|
| 573 |
return q_head, out_qtype
|
| 574 |
|
| 575 |
|
|
|
|
| 667 |
# progress poll for GGUF write (local disk, but user is waiting)
|
| 668 |
import threading
|
| 669 |
_stop_poll = [False]
|
| 670 |
+
_tiny_w = bool(total_write) and total_write < 100000
|
| 671 |
def _poll_gguf():
|
| 672 |
# poll output file (or temp file) size
|
| 673 |
target_path = getattr(writer, 'fname', out_path)
|
|
|
|
| 705 |
pass
|
| 706 |
time.sleep(0.25)
|
| 707 |
_thr = threading.Thread(target=_poll_gguf, daemon=True)
|
| 708 |
+
if not _tiny_w:
|
| 709 |
+
_thr.start()
|
| 710 |
try:
|
| 711 |
writer.write_header_to_file()
|
| 712 |
writer.write_kv_data_to_file()
|
|
|
|
| 714 |
writer.close()
|
| 715 |
except Exception as e:
|
| 716 |
_stop_poll[0] = True
|
| 717 |
+
if not _tiny_w:
|
| 718 |
+
try:
|
| 719 |
+
_thr.join(timeout=0.5)
|
| 720 |
+
except Exception:
|
| 721 |
+
pass
|
| 722 |
sys.stdout.write("\n")
|
| 723 |
if ctx.VERBOSE:
|
| 724 |
_say(f" Details: {e}")
|
| 725 |
_fail(f" ✗ Could not save the voiced model to {out_path}.")
|
| 726 |
_stop_poll[0] = True
|
| 727 |
+
if not _tiny_w:
|
| 728 |
+
try:
|
| 729 |
+
_thr.join(timeout=0.5)
|
| 730 |
+
except Exception:
|
| 731 |
+
pass
|
| 732 |
+
sys.stdout.write("\n")
|
| 733 |
elapsed_w = time.time() - t_write0 or 1e-6
|
| 734 |
try:
|
| 735 |
final_sz = os.path.getsize(out_path)
|
| 736 |
+
_rate_w = f" @ {final_sz / elapsed_w / 1e6:.0f} MB/s" if final_sz >= 100000 else ""
|
| 737 |
+
_note(f"Wrote {final_sz / 1e6:.1f} MB{_rate_w}")
|
| 738 |
except Exception:
|
| 739 |
pass
|
| 740 |
|
|
|
|
| 798 |
_warn(f"This voice was trained for a {varch} model, but the target is {arch}. It may not sound right.")
|
| 799 |
if not _confirm(" Continue anyway? [y/N]: ", args):
|
| 800 |
_note("Cancelled.")
|
| 801 |
+
sys.exit(1)
|
| 802 |
|
| 803 |
|
| 804 |
def _cast_gguf_speak(target, reader, arch, out_path, vf32, vref, meta, args, op, vraw=None, vqtype=None):
|
|
|
|
| 828 |
_fail(f" ✗ Voice shape {vref.shape} doesn't fit {tname} {olog}.")
|
| 829 |
_qo = _parse_quant_override(getattr(args, "quant", None) or "keep")
|
| 830 |
if _qo not in ("keep",):
|
| 831 |
+
fitted = _gguf_raw_to_f32(vraw, _vqtype, tuple(reversed(tuple(int(x) for x in vref.shape))))
|
| 832 |
+
q_head, out_qtype = _quantize_to_Q(np.ascontiguousarray(fitted), Q[_qo.upper()])
|
| 833 |
else:
|
| 834 |
_need = 1
|
| 835 |
for _d in quant_shape_to_byte_shape(tuple(int(x) for x in vref.shape), _vqtype):
|
|
|
|
| 849 |
if _qo is None:
|
| 850 |
_fail(f" ✗ Invalid --quant '{getattr(args, 'quant', None)}'.")
|
| 851 |
if _qo not in ("keep",):
|
| 852 |
+
q_head, out_qtype = _quantize_to_Q(fitted, Q[_qo.upper()])
|
| 853 |
elif fitted.shape[-1] % 32 == 0:
|
| 854 |
q_head, out_qtype = quantize(fitted, Q.Q8_0), Q.Q8_0
|
| 855 |
else:
|
| 856 |
+
_note(f" Head last dim {fitted.shape[-1]} not ×32 — Q8_0 needs %32, keeping F16 (larger, compatible).")
|
| 857 |
q_head, out_qtype = fitted.astype(np.float16), Q.F16
|
| 858 |
if invented:
|
| 859 |
+
_note(" speak: voice → invented output.weight (file untied)")
|
| 860 |
else:
|
| 861 |
+
_note(" speak: voice → output.weight")
|
| 862 |
_gguf_write_repl(target, reader, arch, {tname: (q_head, out_qtype)}, out_path, args, op,
|
| 863 |
detail=(tname, olog, vref, vraw, vqtype, meta),
|
| 864 |
_extra_names=(tname,) if invented else ())
|
| 865 |
|
| 866 |
+
def _cast_gguf(target, out_path, vf32, vref, meta, args, op, vraw=None, vqtype=None, strict_target=False, target_name=None):
|
| 867 |
import numpy as np
|
| 868 |
from gguf import GGUFReader
|
| 869 |
|
|
|
|
| 874 |
_cast_gguf_speak(target, reader, arch, out_path, vf32, vref, meta, args, op, vraw=vraw, vqtype=vqtype)
|
| 875 |
return
|
| 876 |
target_tensor = None
|
| 877 |
+
if target_name is not None:
|
| 878 |
+
# Explicitly routed (requested subset): honor it, never fall back.
|
| 879 |
+
for t in reader.tensors:
|
| 880 |
+
if t.name == target_name:
|
| 881 |
+
target_tensor = t
|
| 882 |
+
break
|
| 883 |
+
if target_tensor is None:
|
| 884 |
+
_fail(f" ✗ Resolved target '{target_name}' for '{vref.name}' not in {target}.")
|
| 885 |
+
if target_tensor is None and vref.name:
|
| 886 |
for t in reader.tensors:
|
| 887 |
if t.name == vref.name:
|
| 888 |
target_tensor = t
|
|
|
|
| 970 |
Trailing role is everything after the block number (e.g.
|
| 971 |
'self_attn.o_proj.weight'); unblocked names fall back to their last two
|
| 972 |
components (e.g. 'embed_tokens.weight'). The .weight/.bias suffix stays
|
| 973 |
+
in the key so a bias never matches a weight. The block keyword
|
| 974 |
+
(layers/blk/...) is left-guarded against mid-word hits; the generic
|
| 975 |
+
dotted-number fallback still fires on version-like segments, so the
|
| 976 |
+
elem-count gate remains the real false-friend veto."""
|
| 977 |
import re
|
| 978 |
m = re.search(r"(?<![A-Za-z0-9_])(?:layers|layer|blk|blks|blocks|h)\.(\d+)\b", name)
|
| 979 |
if m:
|
|
|
|
| 1073 |
return mapping
|
| 1074 |
|
| 1075 |
|
| 1076 |
+
def _cast_pack(target, src_path, out_path, args, op, excludes=(), meta=None, order=()):
|
| 1077 |
"""Cast every tensor in a pack file onto target (minus excludes).
|
| 1078 |
GGUF and safetensors targets each get one write pass (repl-dict fused first).
|
| 1079 |
+
Delta marker on the pack is detected once and threaded into every tensor.
|
| 1080 |
+
order (requested subset): process in the user's order, not file order."""
|
| 1081 |
+
if getattr(args, "speak", False) and not _is_gguf_file(target):
|
| 1082 |
+
_fail(" ✗ --speak needs a .gguf target. Re-run without --speak for .safetensors, or point cast at a .gguf file.")
|
| 1083 |
src = open_source(str(src_path))
|
| 1084 |
all_names = [n for n in src.names() if n != "delta.voice.marker"]
|
| 1085 |
for e in excludes:
|
|
|
|
| 1094 |
_m = [n for n in all_names if e in n]
|
| 1095 |
if len(_m) == 1:
|
| 1096 |
resolved_ex.add(_m[0])
|
| 1097 |
+
elif len(_m) > 1:
|
| 1098 |
+
_fail(f" ✗ --exclude '{e}' is ambiguous: {', '.join(_m)}. Name one tensor exactly.")
|
| 1099 |
to_cast = [n for n in all_names if n not in resolved_ex]
|
| 1100 |
+
if order:
|
| 1101 |
+
_pos = {n: i for i, n in enumerate(order)}
|
| 1102 |
+
to_cast.sort(key=lambda n: (_pos.get(n, len(_pos)), n))
|
| 1103 |
if not to_cast:
|
| 1104 |
_fail(" ✗ --exclude removes all tensors. Nothing to cast.")
|
| 1105 |
_step(f"Casting {len(to_cast)} tensors from {Path(src_path).name} onto {Path(target).name}…")
|
vlib/ctx.py
CHANGED
|
@@ -24,10 +24,11 @@ REPORTS_DATASET_ID = "Wiself/voice-reports"
|
|
| 24 |
REPORTS_REMOTE_PREFIX = "data/reports-"
|
| 25 |
|
| 26 |
|
| 27 |
-
VERSION = "3.0"
|
| 28 |
|
| 29 |
|
| 30 |
DTYPE_BYTES = {"F32": 4, "F16": 2, "BF16": 2}
|
| 31 |
|
| 32 |
|
| 33 |
VERBOSE = False
|
|
|
|
|
|
| 24 |
REPORTS_REMOTE_PREFIX = "data/reports-"
|
| 25 |
|
| 26 |
|
| 27 |
+
VERSION = "3.0.1"
|
| 28 |
|
| 29 |
|
| 30 |
DTYPE_BYTES = {"F32": 4, "F16": 2, "BF16": 2}
|
| 31 |
|
| 32 |
|
| 33 |
VERBOSE = False
|
| 34 |
+
QUIET = False
|
vlib/delta.py
CHANGED
|
@@ -29,7 +29,7 @@ def _choose_voice(args):
|
|
| 29 |
choice = input(f" Choose voice [1-{len(voices)}]: ").strip()
|
| 30 |
except (EOFError, KeyboardInterrupt):
|
| 31 |
_say(" ⚠ Cancelled.")
|
| 32 |
-
sys.exit(
|
| 33 |
if not choice.isdigit() or not (1 <= int(choice) <= len(voices)):
|
| 34 |
_fail(" ✗ Invalid choice.")
|
| 35 |
return voices[int(choice) - 1][1].get("name", voices[int(choice) - 1][0])
|
|
@@ -44,6 +44,8 @@ def _resolve_base(args, source_hf):
|
|
| 44 |
return str(p.resolve())
|
| 45 |
norm = _normalize_hf_repo(base_arg)
|
| 46 |
if norm is None:
|
|
|
|
|
|
|
| 47 |
_fail(f" ✗ Invalid HF repo '{base_arg}'. Use org/model or a local path.")
|
| 48 |
return norm
|
| 49 |
if source_hf not in ("—", "", None) and "/" in source_hf:
|
|
@@ -52,12 +54,12 @@ def _resolve_base(args, source_hf):
|
|
| 52 |
suggested, is_multi, count, _raw = None, False, 0, []
|
| 53 |
if suggested is None:
|
| 54 |
if _noninteractive(args):
|
| 55 |
-
_fail(" ✗ Could not detect the base model.
|
| 56 |
try:
|
| 57 |
entered = input(" Enter base HF repo (org/model) or local path: ").strip()
|
| 58 |
except (EOFError, KeyboardInterrupt):
|
| 59 |
_say(" ⚠ Cancelled.")
|
| 60 |
-
sys.exit(
|
| 61 |
if not entered:
|
| 62 |
_fail(" ✗ Invalid base repo.")
|
| 63 |
p = Path(entered).expanduser()
|
|
@@ -77,7 +79,7 @@ def _resolve_base(args, source_hf):
|
|
| 77 |
entered = input(f" Press enter to use {suggested}, or type another repo/path: ").strip()
|
| 78 |
except (EOFError, KeyboardInterrupt):
|
| 79 |
_say(" ⚠ Cancelled.")
|
| 80 |
-
sys.exit(
|
| 81 |
if not entered:
|
| 82 |
return suggested
|
| 83 |
p = Path(entered).expanduser()
|
|
@@ -96,9 +98,9 @@ def _delta_gate(args, warn_lines, phrase, fail_hint):
|
|
| 96 |
try:
|
| 97 |
ans = input(f" Type {phrase} to continue, Enter to cancel: ").strip()
|
| 98 |
except (EOFError, KeyboardInterrupt):
|
| 99 |
-
_say(" Cancelled."); sys.exit(
|
| 100 |
if ans.strip().lower() != phrase.lower():
|
| 101 |
-
_say(" Cancelled."); sys.exit(
|
| 102 |
|
| 103 |
|
| 104 |
def _check_delta_gate(args, voice_path, base_path):
|
|
@@ -289,17 +291,25 @@ def _compute_delta(voice_path, base_path, delta_folder, delta_name, args=None):
|
|
| 289 |
total_bytes = total_elems * 2
|
| 290 |
t0 = time.time()
|
| 291 |
last = [0.0]
|
|
|
|
|
|
|
| 292 |
def _delta_progress(force=False):
|
| 293 |
now = time.time()
|
| 294 |
if not force and now - last[0] < 0.25 and processed < total_elems:
|
| 295 |
return
|
| 296 |
last[0] = now
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 303 |
sys.stdout.write(_transform(msg) + ("\n" if _progress_pref() else "\r"))
|
| 304 |
sys.stdout.flush()
|
| 305 |
with open(voice_path, "rb") as fv, open(base_path, "rb") as fb, open(tmp_out, "wb") as out:
|
|
@@ -327,7 +337,7 @@ def _compute_delta(voice_path, base_path, delta_folder, delta_name, args=None):
|
|
| 327 |
done += cur
|
| 328 |
processed += cur
|
| 329 |
_delta_progress()
|
| 330 |
-
_delta_progress(
|
| 331 |
sys.stdout.write("\n")
|
| 332 |
# marker byte for auto-detect (delta.voice.marker)
|
| 333 |
out.write(b"\x01")
|
|
|
|
| 29 |
choice = input(f" Choose voice [1-{len(voices)}]: ").strip()
|
| 30 |
except (EOFError, KeyboardInterrupt):
|
| 31 |
_say(" ⚠ Cancelled.")
|
| 32 |
+
sys.exit(1)
|
| 33 |
if not choice.isdigit() or not (1 <= int(choice) <= len(voices)):
|
| 34 |
_fail(" ✗ Invalid choice.")
|
| 35 |
return voices[int(choice) - 1][1].get("name", voices[int(choice) - 1][0])
|
|
|
|
| 44 |
return str(p.resolve())
|
| 45 |
norm = _normalize_hf_repo(base_arg)
|
| 46 |
if norm is None:
|
| 47 |
+
if "/" in base_arg or base_arg.startswith(("~", ".")) or base_arg.endswith((".safetensors", ".gguf", ".bin", ".pt")):
|
| 48 |
+
_fail(f' ✗ "{base_arg}" couldn\'t be found. Pass an existing local path or an HF repo (org/model).')
|
| 49 |
_fail(f" ✗ Invalid HF repo '{base_arg}'. Use org/model or a local path.")
|
| 50 |
return norm
|
| 51 |
if source_hf not in ("—", "", None) and "/" in source_hf:
|
|
|
|
| 54 |
suggested, is_multi, count, _raw = None, False, 0, []
|
| 55 |
if suggested is None:
|
| 56 |
if _noninteractive(args):
|
| 57 |
+
_fail(" ✗ Could not detect the base model. Re-run with --base <org/model or local .safetensors>.")
|
| 58 |
try:
|
| 59 |
entered = input(" Enter base HF repo (org/model) or local path: ").strip()
|
| 60 |
except (EOFError, KeyboardInterrupt):
|
| 61 |
_say(" ⚠ Cancelled.")
|
| 62 |
+
sys.exit(1)
|
| 63 |
if not entered:
|
| 64 |
_fail(" ✗ Invalid base repo.")
|
| 65 |
p = Path(entered).expanduser()
|
|
|
|
| 79 |
entered = input(f" Press enter to use {suggested}, or type another repo/path: ").strip()
|
| 80 |
except (EOFError, KeyboardInterrupt):
|
| 81 |
_say(" ⚠ Cancelled.")
|
| 82 |
+
sys.exit(1)
|
| 83 |
if not entered:
|
| 84 |
return suggested
|
| 85 |
p = Path(entered).expanduser()
|
|
|
|
| 98 |
try:
|
| 99 |
ans = input(f" Type {phrase} to continue, Enter to cancel: ").strip()
|
| 100 |
except (EOFError, KeyboardInterrupt):
|
| 101 |
+
_say(" Cancelled."); sys.exit(1)
|
| 102 |
if ans.strip().lower() != phrase.lower():
|
| 103 |
+
_say(" Cancelled."); sys.exit(1)
|
| 104 |
|
| 105 |
|
| 106 |
def _check_delta_gate(args, voice_path, base_path):
|
|
|
|
| 291 |
total_bytes = total_elems * 2
|
| 292 |
t0 = time.time()
|
| 293 |
last = [0.0]
|
| 294 |
+
last_pct = [-1.0]
|
| 295 |
+
tiny = total_bytes < 100000
|
| 296 |
def _delta_progress(force=False):
|
| 297 |
now = time.time()
|
| 298 |
if not force and now - last[0] < 0.25 and processed < total_elems:
|
| 299 |
return
|
| 300 |
last[0] = now
|
| 301 |
+
pct = round(processed / total_elems * 100) if total_elems else 100
|
| 302 |
+
if pct == last_pct[0] and not force:
|
| 303 |
+
return
|
| 304 |
+
last_pct[0] = pct
|
| 305 |
+
if tiny:
|
| 306 |
+
msg = f" → crafting delta {pct:3.0f}% · {processed}/{total_elems} elems"
|
| 307 |
+
else:
|
| 308 |
+
elapsed = now - t0 or 1e-6
|
| 309 |
+
mbps = (processed * 2) / elapsed / 1e6
|
| 310 |
+
remain = total_bytes - processed * 2
|
| 311 |
+
eta = _fmt_eta(remain, mbps)
|
| 312 |
+
msg = f" → crafting delta {pct:3.0f}% · {processed*2/1e6:.0f}/{total_bytes/1e6:.0f} MB · {mbps:.1f} MB/s · {eta} "
|
| 313 |
sys.stdout.write(_transform(msg) + ("\n" if _progress_pref() else "\r"))
|
| 314 |
sys.stdout.flush()
|
| 315 |
with open(voice_path, "rb") as fv, open(base_path, "rb") as fb, open(tmp_out, "wb") as out:
|
|
|
|
| 337 |
done += cur
|
| 338 |
processed += cur
|
| 339 |
_delta_progress()
|
| 340 |
+
_delta_progress()
|
| 341 |
sys.stdout.write("\n")
|
| 342 |
# marker byte for auto-detect (delta.voice.marker)
|
| 343 |
out.write(b"\x01")
|
vlib/fetch.py
CHANGED
|
@@ -122,7 +122,9 @@ def _write_fetched(fetched, tensor_name, out_path):
|
|
| 122 |
kind, raw_path, data, dtype, shape = fetched
|
| 123 |
if _is_quant_fetched(fetched):
|
| 124 |
if not str(out_path).endswith(".gguf"):
|
| 125 |
-
|
|
|
|
|
|
|
| 126 |
_write_single_tensor_gguf(tensor_name, raw_path, raw_path.stat().st_size, dtype, shape, str(out_path))
|
| 127 |
return Path(out_path)
|
| 128 |
tmp = str(out_path) + ".tmp"
|
|
|
|
| 122 |
kind, raw_path, data, dtype, shape = fetched
|
| 123 |
if _is_quant_fetched(fetched):
|
| 124 |
if not str(out_path).endswith(".gguf"):
|
| 125 |
+
_fixed = str(out_path)[:-len(".safetensors")] + ".gguf" if str(out_path).endswith(".safetensors") else str(out_path) + ".gguf"
|
| 126 |
+
_warn(f" Quant artifact needs .gguf — writing {_fixed} instead of the requested extension.")
|
| 127 |
+
out_path = _fixed
|
| 128 |
_write_single_tensor_gguf(tensor_name, raw_path, raw_path.stat().st_size, dtype, shape, str(out_path))
|
| 129 |
return Path(out_path)
|
| 130 |
tmp = str(out_path) + ".tmp"
|
vlib/registry.py
CHANGED
|
@@ -6,7 +6,7 @@ import os
|
|
| 6 |
import sys
|
| 7 |
import time
|
| 8 |
from vlib import ctx
|
| 9 |
-
from vlib.ui import _confirm, _fail, _noninteractive, _say, _warn
|
| 10 |
from vlib.tensors import _is_gguf_file, _is_quant_fetched, _write_safetensors_streaming, _write_single_tensor_gguf, write_safetensors
|
| 11 |
from vlib.sources import _NAME_RULES, _sanitize_voice_name, _slugify_voice_name
|
| 12 |
|
|
@@ -277,7 +277,7 @@ def _resolve_name(args, default_name):
|
|
| 277 |
name = entered or default_slug
|
| 278 |
except (EOFError, KeyboardInterrupt):
|
| 279 |
_say(" ⚠ Cancelled.")
|
| 280 |
-
sys.exit(
|
| 281 |
if _sanitize_voice_name(name) is None:
|
| 282 |
_fail(f" ✗ Invalid name '{name}'. {_NAME_RULES}")
|
| 283 |
return name
|
|
@@ -285,7 +285,7 @@ def _resolve_name(args, default_name):
|
|
| 285 |
|
| 286 |
def _out_path(args, target, voice_arg):
|
| 287 |
if getattr(args, "out", None):
|
| 288 |
-
out = args.out
|
| 289 |
# jail: resolve but allow any absolute path user explicitly requested; block symlink traversal
|
| 290 |
if out.endswith(("/", os.sep)) or os.path.isdir(out) or not os.path.splitext(out)[1]:
|
| 291 |
out = os.path.join(out, f"{_stem(voice_arg)}-{_stem(target)}{'.gguf' if _is_gguf_file(target) else '.safetensors'}")
|
|
@@ -312,7 +312,8 @@ def _check_overwrite(out_path, args):
|
|
| 312 |
_fail(f" ✗ Output '{out_path}' exists. Use --yes to overwrite in non-interactive mode.")
|
| 313 |
if not _confirm(f" Output '{out_path}' already exists. Overwrite? [y/N]: ", args):
|
| 314 |
_say(" Cancelled.")
|
| 315 |
-
sys.exit(
|
|
|
|
| 316 |
out_dir = os.path.dirname(os.path.abspath(out_path))
|
| 317 |
if out_dir and os.path.islink(out_dir):
|
| 318 |
_fail(f" ✗ Refusing to write through symlink: {out_dir}")
|
|
|
|
| 6 |
import sys
|
| 7 |
import time
|
| 8 |
from vlib import ctx
|
| 9 |
+
from vlib.ui import _confirm, _fail, _noninteractive, _note, _say, _warn
|
| 10 |
from vlib.tensors import _is_gguf_file, _is_quant_fetched, _write_safetensors_streaming, _write_single_tensor_gguf, write_safetensors
|
| 11 |
from vlib.sources import _NAME_RULES, _sanitize_voice_name, _slugify_voice_name
|
| 12 |
|
|
|
|
| 277 |
name = entered or default_slug
|
| 278 |
except (EOFError, KeyboardInterrupt):
|
| 279 |
_say(" ⚠ Cancelled.")
|
| 280 |
+
sys.exit(1)
|
| 281 |
if _sanitize_voice_name(name) is None:
|
| 282 |
_fail(f" ✗ Invalid name '{name}'. {_NAME_RULES}")
|
| 283 |
return name
|
|
|
|
| 285 |
|
| 286 |
def _out_path(args, target, voice_arg):
|
| 287 |
if getattr(args, "out", None):
|
| 288 |
+
out = os.path.expanduser(args.out)
|
| 289 |
# jail: resolve but allow any absolute path user explicitly requested; block symlink traversal
|
| 290 |
if out.endswith(("/", os.sep)) or os.path.isdir(out) or not os.path.splitext(out)[1]:
|
| 291 |
out = os.path.join(out, f"{_stem(voice_arg)}-{_stem(target)}{'.gguf' if _is_gguf_file(target) else '.safetensors'}")
|
|
|
|
| 312 |
_fail(f" ✗ Output '{out_path}' exists. Use --yes to overwrite in non-interactive mode.")
|
| 313 |
if not _confirm(f" Output '{out_path}' already exists. Overwrite? [y/N]: ", args):
|
| 314 |
_say(" Cancelled.")
|
| 315 |
+
sys.exit(1)
|
| 316 |
+
_note(f" Overwriting '{out_path}'.")
|
| 317 |
out_dir = os.path.dirname(os.path.abspath(out_path))
|
| 318 |
if out_dir and os.path.islink(out_dir):
|
| 319 |
_fail(f" ✗ Refusing to write through symlink: {out_dir}")
|
vlib/reports.py
CHANGED
|
@@ -8,7 +8,7 @@ import sys
|
|
| 8 |
import urllib.error
|
| 9 |
import urllib.request
|
| 10 |
from vlib import ctx
|
| 11 |
-
from vlib.ui import _noninteractive, _now_iso, _ok, _say, _step, _warn
|
| 12 |
from vlib.net import _get_hf_token, _parse_retry_after
|
| 13 |
from vlib.tensors import _is_gguf_file, read_safetensors
|
| 14 |
from vlib.sources import _family, _public_source, detect_output_tensor, largest_2d
|
|
@@ -62,10 +62,32 @@ def _prompt_share(args, preview=None):
|
|
| 62 |
ans = input(" Leave a breadcrumb to help the next person? [y/N] (N): ").strip().lower()
|
| 63 |
except (EOFError, KeyboardInterrupt):
|
| 64 |
_say(" ⚠ Cancelled.")
|
| 65 |
-
sys.exit(
|
| 66 |
return ans in ("y", "yes")
|
| 67 |
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
def _push_reports_batch(records):
|
| 70 |
"""Batch push: group by shard, single fetch+upload per shard. Returns pushed count.
|
| 71 |
Non-collaborators lack write access to Wiself/voice-reports → fallback to PR (create_pr=True).
|
|
@@ -252,15 +274,22 @@ def _last_operation():
|
|
| 252 |
def cmd_report(args):
|
| 253 |
msg = _sanitize_note(getattr(args, "message", None))
|
| 254 |
voice_arg = getattr(args, "voice", None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
import uuid, platform
|
| 256 |
report_id = uuid.uuid4().hex
|
| 257 |
ts = _now_iso()
|
| 258 |
-
# sanitize voice/target early for CSV safety
|
| 259 |
-
voice_name = _sanitize_note(voice_arg.strip()) if voice_arg and voice_arg.strip() else None
|
| 260 |
-
target_raw = getattr(args, "target", None)
|
| 261 |
-
target_basename = _sanitize_note(Path(target_raw).name) if target_raw else None
|
| 262 |
# auto-pull voice provenance
|
|
|
|
| 263 |
voice_meta = None
|
|
|
|
| 264 |
try:
|
| 265 |
if voice_arg:
|
| 266 |
vp, vm = _registry_resolve(voice_arg)
|
|
@@ -274,7 +303,7 @@ def cmd_report(args):
|
|
| 274 |
except Exception:
|
| 275 |
pass
|
| 276 |
else:
|
| 277 |
-
|
| 278 |
voices = sorted([d for d in _iter_voices() if (d / "voice.json").exists()], key=lambda p: p.stat().st_mtime, reverse=True)
|
| 279 |
if voices:
|
| 280 |
vm = _read_meta(voices[0] / "voice.json")
|
|
@@ -293,7 +322,9 @@ def cmd_report(args):
|
|
| 293 |
voice_name = _sanitize_note(vm.get("name") or voices[0].name)
|
| 294 |
except Exception:
|
| 295 |
pass
|
| 296 |
-
|
|
|
|
|
|
|
| 297 |
target_info = None
|
| 298 |
if target_raw and Path(target_raw).expanduser().exists():
|
| 299 |
try:
|
|
@@ -401,22 +432,9 @@ def cmd_report(args):
|
|
| 401 |
_append_report(record)
|
| 402 |
_ok(f"Thanks for noting — saved locally ({report_id[:8]}…) → {ctx.REPORTS_JSONL}")
|
| 403 |
_say(f" Outbox: {ctx.REPORTS_OUTBOX / (report_id + '.json')} (private, stays until you choose to share)")
|
| 404 |
-
# also handle --sync of pending
|
| 405 |
if getattr(args, "sync", False):
|
| 406 |
-
|
| 407 |
-
if not pending:
|
| 408 |
-
_say(" No pending reports to sync.")
|
| 409 |
-
return
|
| 410 |
-
_step(f"Syncing {len(pending)} pending report(s)…")
|
| 411 |
-
recs = []
|
| 412 |
-
for p in pending:
|
| 413 |
-
try:
|
| 414 |
-
recs.append(json.loads(p.read_text()))
|
| 415 |
-
except Exception as e:
|
| 416 |
-
_warn(f" Could not read {p.name}: {e}")
|
| 417 |
-
if recs:
|
| 418 |
-
n = _push_reports_batch(recs)
|
| 419 |
-
_ok(f"Synced {n}/{len(recs)} report(s).")
|
| 420 |
return
|
| 421 |
# warm preview — what will be shared
|
| 422 |
preview = None
|
|
|
|
| 8 |
import urllib.error
|
| 9 |
import urllib.request
|
| 10 |
from vlib import ctx
|
| 11 |
+
from vlib.ui import _fail, _noninteractive, _note, _now_iso, _ok, _say, _step, _warn
|
| 12 |
from vlib.net import _get_hf_token, _parse_retry_after
|
| 13 |
from vlib.tensors import _is_gguf_file, read_safetensors
|
| 14 |
from vlib.sources import _family, _public_source, detect_output_tensor, largest_2d
|
|
|
|
| 62 |
ans = input(" Leave a breadcrumb to help the next person? [y/N] (N): ").strip().lower()
|
| 63 |
except (EOFError, KeyboardInterrupt):
|
| 64 |
_say(" ⚠ Cancelled.")
|
| 65 |
+
sys.exit(1)
|
| 66 |
return ans in ("y", "yes")
|
| 67 |
|
| 68 |
|
| 69 |
+
def _sync_pending():
|
| 70 |
+
"""Sync outbox without creating anything. Shared by sync-only mode."""
|
| 71 |
+
pending = sorted(ctx.REPORTS_OUTBOX.glob("*.json"))
|
| 72 |
+
if not pending:
|
| 73 |
+
_say(" No pending reports to sync.")
|
| 74 |
+
return
|
| 75 |
+
_step(f"Syncing {len(pending)} pending report(s)…")
|
| 76 |
+
recs = []
|
| 77 |
+
for p in pending:
|
| 78 |
+
try:
|
| 79 |
+
recs.append(json.loads(p.read_text()))
|
| 80 |
+
except Exception as e:
|
| 81 |
+
_warn(f" Could not read {p.name}: {e}")
|
| 82 |
+
if recs:
|
| 83 |
+
n = _push_reports_batch(recs)
|
| 84 |
+
if n < len(recs):
|
| 85 |
+
_warn(f" Synced {n}/{len(recs)} report(s) — rest stay queued.")
|
| 86 |
+
else:
|
| 87 |
+
_ok(f"Synced {n}/{len(recs)} report(s).")
|
| 88 |
+
return
|
| 89 |
+
|
| 90 |
+
|
| 91 |
def _push_reports_batch(records):
|
| 92 |
"""Batch push: group by shard, single fetch+upload per shard. Returns pushed count.
|
| 93 |
Non-collaborators lack write access to Wiself/voice-reports → fallback to PR (create_pr=True).
|
|
|
|
| 274 |
def cmd_report(args):
|
| 275 |
msg = _sanitize_note(getattr(args, "message", None))
|
| 276 |
voice_arg = getattr(args, "voice", None)
|
| 277 |
+
target_raw = getattr(args, "target", None)
|
| 278 |
+
if getattr(args, "sync", False) and not (msg or voice_arg or target_raw):
|
| 279 |
+
# Sync-only: never mint a report just to sync.
|
| 280 |
+
_sync_pending()
|
| 281 |
+
return
|
| 282 |
+
if not msg:
|
| 283 |
+
_fail(' ✗ Empty note — pass -m "what you tried, what happened".')
|
| 284 |
+
if isinstance(getattr(args, "message", None), str) and len(getattr(args, "message")) > 240:
|
| 285 |
+
_note(" Note truncated to 240 chars.")
|
| 286 |
import uuid, platform
|
| 287 |
report_id = uuid.uuid4().hex
|
| 288 |
ts = _now_iso()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
# auto-pull voice provenance
|
| 290 |
+
_voice_missed = None
|
| 291 |
voice_meta = None
|
| 292 |
+
voice_name = _sanitize_note(voice_arg.strip()) if voice_arg and voice_arg.strip() else None
|
| 293 |
try:
|
| 294 |
if voice_arg:
|
| 295 |
vp, vm = _registry_resolve(voice_arg)
|
|
|
|
| 303 |
except Exception:
|
| 304 |
pass
|
| 305 |
else:
|
| 306 |
+
_voice_missed = voice_arg
|
| 307 |
voices = sorted([d for d in _iter_voices() if (d / "voice.json").exists()], key=lambda p: p.stat().st_mtime, reverse=True)
|
| 308 |
if voices:
|
| 309 |
vm = _read_meta(voices[0] / "voice.json")
|
|
|
|
| 322 |
voice_name = _sanitize_note(vm.get("name") or voices[0].name)
|
| 323 |
except Exception:
|
| 324 |
pass
|
| 325 |
+
if _voice_missed:
|
| 326 |
+
_warn(f" Voice '{_voice_missed}' not in registry — note saved without its provenance.")
|
| 327 |
+
target_basename = _sanitize_note(Path(target_raw).name) if target_raw else None
|
| 328 |
target_info = None
|
| 329 |
if target_raw and Path(target_raw).expanduser().exists():
|
| 330 |
try:
|
|
|
|
| 432 |
_append_report(record)
|
| 433 |
_ok(f"Thanks for noting — saved locally ({report_id[:8]}…) → {ctx.REPORTS_JSONL}")
|
| 434 |
_say(f" Outbox: {ctx.REPORTS_OUTBOX / (report_id + '.json')} (private, stays until you choose to share)")
|
| 435 |
+
# also handle --sync of pending (record already saved above)
|
| 436 |
if getattr(args, "sync", False):
|
| 437 |
+
_sync_pending()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 438 |
return
|
| 439 |
# warm preview — what will be shared
|
| 440 |
preview = None
|
vlib/ui.py
CHANGED
|
@@ -28,7 +28,17 @@ def _say(msg):
|
|
| 28 |
print(_transform(msg), flush=True)
|
| 29 |
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
def _ok(msg):
|
|
|
|
|
|
|
| 32 |
_say(f" ✓ {msg}")
|
| 33 |
|
| 34 |
|
|
@@ -37,10 +47,14 @@ def _warn(msg):
|
|
| 37 |
|
| 38 |
|
| 39 |
def _step(msg):
|
|
|
|
|
|
|
| 40 |
_say(f" → {msg}")
|
| 41 |
|
| 42 |
|
| 43 |
def _note(msg):
|
|
|
|
|
|
|
| 44 |
_say(f" ↳ {msg}")
|
| 45 |
|
| 46 |
|
|
@@ -80,7 +94,7 @@ def _confirm(question, args):
|
|
| 80 |
ans = input(question).strip().lower()
|
| 81 |
except (EOFError, KeyboardInterrupt):
|
| 82 |
_say(" ⚠ Cancelled.")
|
| 83 |
-
sys.exit(
|
| 84 |
return ans in ("y", "yes")
|
| 85 |
|
| 86 |
|
|
|
|
| 28 |
print(_transform(msg), flush=True)
|
| 29 |
|
| 30 |
|
| 31 |
+
def _quiet():
|
| 32 |
+
try:
|
| 33 |
+
from vlib import ctx as _ctx
|
| 34 |
+
return bool(getattr(_ctx, "QUIET", False))
|
| 35 |
+
except Exception:
|
| 36 |
+
return False
|
| 37 |
+
|
| 38 |
+
|
| 39 |
def _ok(msg):
|
| 40 |
+
if _quiet():
|
| 41 |
+
return
|
| 42 |
_say(f" ✓ {msg}")
|
| 43 |
|
| 44 |
|
|
|
|
| 47 |
|
| 48 |
|
| 49 |
def _step(msg):
|
| 50 |
+
if _quiet():
|
| 51 |
+
return
|
| 52 |
_say(f" → {msg}")
|
| 53 |
|
| 54 |
|
| 55 |
def _note(msg):
|
| 56 |
+
if _quiet():
|
| 57 |
+
return
|
| 58 |
_say(f" ↳ {msg}")
|
| 59 |
|
| 60 |
|
|
|
|
| 94 |
ans = input(question).strip().lower()
|
| 95 |
except (EOFError, KeyboardInterrupt):
|
| 96 |
_say(" ⚠ Cancelled.")
|
| 97 |
+
sys.exit(1)
|
| 98 |
return ans in ("y", "yes")
|
| 99 |
|
| 100 |
|
voice-cli.tar.gz
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6f57c560666c407c280e5880e644e08fd09b2d020b317888f41afced8dc88b9d
|
| 3 |
+
size 69538
|
voice.py
CHANGED
|
@@ -58,75 +58,87 @@ from vlib.cmds_misc import cmd_list, _list_bases, _voice_tensors, _verify_voice_
|
|
| 58 |
def main():
|
| 59 |
global VERBOSE
|
| 60 |
parser = argparse.ArgumentParser(prog="voice", description="Lift a model's voice and cast it onto another model.")
|
| 61 |
-
parser.add_argument("-v", "--verbose", action="store_true")
|
| 62 |
-
parser.add_argument("--non-interactive", action="store_true")
|
| 63 |
-
parser.add_argument("--version", action="store_true")
|
| 64 |
-
parser.add_argument("--completion", choices=["bash", "zsh", "fish"])
|
| 65 |
sub = parser.add_subparsers(dest="command")
|
| 66 |
|
| 67 |
p_get = sub.add_parser("get", help="Get a voice from a model (safetensors repo, .gguf, or URL)")
|
| 68 |
p_get.add_argument("source", help="HF model ID, .gguf/.safetensors path, or URL")
|
| 69 |
p_get.add_argument("tensors", nargs="*", help="Tensor name(s) to fetch (default: auto-detect output head; 2+ or --multi saves a voicepack)")
|
| 70 |
-
p_get.add_argument("-q", "--quiet", action="store_true")
|
| 71 |
-
p_get.add_argument("--name", help="Voice name to save (registry voices only)")
|
| 72 |
-
p_get.add_argument("--multi", action="store_true", help="Fetch
|
| 73 |
p_get.add_argument("--out", help="Write a standalone file instead of a registry voice (default pack name: voicepack.safetensors)")
|
| 74 |
-
p_get.add_argument("--yes", action="store_true")
|
| 75 |
|
| 76 |
p_cast = sub.add_parser("cast", help="Cast a voice onto a .gguf or .safetensors file")
|
| 77 |
p_cast.add_argument("target", help="Path to the target .gguf or .safetensors")
|
| 78 |
p_cast.add_argument("voice", help="Voice name, or a .safetensors/.gguf path")
|
| 79 |
p_cast.add_argument("tensors", nargs="*", help="Only cast these tensors (default: every tensor in the voice)")
|
| 80 |
-
p_cast.add_argument("--out", help="Output file (default: ~/Voiced/<voice>-<model>/<voice>-<model>.
|
| 81 |
-
p_cast.add_argument("--yes", action="store_true")
|
| 82 |
-
p_cast.add_argument("--quant", default="keep", help="Output quant override: keep (default, preserve quality) | target | any quant (q8_0,q4_0,q4_k,q6_k,iq4_nl,f16,f32,bf16,...)")
|
| 83 |
-
p_cast.add_argument("--exclude", action="append", dest="excludes", default=[], help="Skip
|
| 84 |
-
p_cast.add_argument("--speak", action="store_true", help="Voice speaks through output.weight (invented if absent)")
|
|
|
|
| 85 |
p_delta = sub.add_parser("delta", help="Make a reusable style (voice − base)")
|
| 86 |
-
p_delta.add_argument("voicename", nargs="?")
|
| 87 |
p_delta.add_argument("--base", help="Base HF repo (org/model) or local path to base safetensors")
|
| 88 |
-
p_delta.add_argument("--yes", action="store_true")
|
|
|
|
| 89 |
|
| 90 |
p_add = sub.add_parser("add", help="Add a voice from local voice.safetensors + voice.json")
|
| 91 |
p_add.add_argument("safetensors", help="Path to voice.safetensors (required)")
|
| 92 |
p_add.add_argument("json", help="Path to voice.json (required)")
|
| 93 |
p_add.add_argument("--name", help="Voice name to save (default from voice.json)")
|
| 94 |
p_add.add_argument("--yes", action="store_true", help="Auto-confirm overwrite")
|
|
|
|
| 95 |
|
| 96 |
p_list = sub.add_parser("list", help="List stored voices")
|
| 97 |
-
p_list.add_argument("target", nargs="?", choices=["base"])
|
| 98 |
-
p_list.add_argument("--base", dest="list_base", action="store_true")
|
|
|
|
| 99 |
|
| 100 |
p_info = sub.add_parser("info", help="Show voice details")
|
| 101 |
-
p_info.add_argument("voicename")
|
|
|
|
| 102 |
|
| 103 |
p_rm = sub.add_parser("remove", help="Remove a stored voice")
|
| 104 |
-
p_rm.add_argument("voice")
|
| 105 |
-
p_rm.add_argument("--yes", action="store_true")
|
|
|
|
| 106 |
|
| 107 |
p_cleanup = sub.add_parser("cleanup", help="Remove incomplete downloads")
|
| 108 |
-
p_cleanup.add_argument("--force", action="store_true")
|
|
|
|
| 109 |
|
| 110 |
p_auth = sub.add_parser("auth", help="Save your HF token (optional)")
|
| 111 |
-
p_auth.add_argument("--clear", action="store_true")
|
| 112 |
-
p_auth.add_argument("--show", action="store_true")
|
|
|
|
| 113 |
|
| 114 |
p_report = sub.add_parser("report", help="Save a report locally and optionally share to community")
|
| 115 |
p_report.add_argument("--message", "-m", help="Freeform note (240ch, sanitized)")
|
| 116 |
p_report.add_argument("--voice", help="Voice name context")
|
| 117 |
p_report.add_argument("--target", help="Target file basename context")
|
| 118 |
p_report.add_argument("--reporter", help="Reporter id (optional, 64ch)")
|
| 119 |
-
p_report.add_argument("--yes", action="store_true", help="Non-interactive: auto-share to community")
|
| 120 |
p_report.add_argument("--no-push", action="store_true", help="Local only, skip share prompt")
|
| 121 |
p_report.add_argument("--sync", action="store_true", help="Sync pending outbox to community")
|
|
|
|
| 122 |
p_report.add_argument("--operation", help=argparse.SUPPRESS)
|
| 123 |
|
| 124 |
-
sub.add_parser("path", help="Put voice on your PATH")
|
| 125 |
-
|
|
|
|
|
|
|
| 126 |
|
| 127 |
args = parser.parse_args()
|
| 128 |
VERBOSE = args.verbose
|
| 129 |
ctx.VERBOSE = args.verbose
|
|
|
|
| 130 |
|
| 131 |
if getattr(args, "completion", None):
|
| 132 |
_print_completion(args.completion)
|
|
@@ -136,7 +148,7 @@ def main():
|
|
| 136 |
sys.exit(0)
|
| 137 |
if args.command is None:
|
| 138 |
parser.print_help()
|
| 139 |
-
sys.exit(
|
| 140 |
|
| 141 |
_ensure_venv(args.command)
|
| 142 |
|
|
|
|
| 58 |
def main():
|
| 59 |
global VERBOSE
|
| 60 |
parser = argparse.ArgumentParser(prog="voice", description="Lift a model's voice and cast it onto another model.")
|
| 61 |
+
parser.add_argument("-v", "--verbose", action="store_true", help="Verbose: tensor shapes, decisions, and paths")
|
| 62 |
+
parser.add_argument("--non-interactive", action="store_true", help="Fail instead of prompting (same as piped stdin; needs --yes to overwrite/remove)")
|
| 63 |
+
parser.add_argument("--version", action="store_true", help="Show version and environment")
|
| 64 |
+
parser.add_argument("--completion", choices=["bash", "zsh", "fish"], help="Print shell completion script")
|
| 65 |
sub = parser.add_subparsers(dest="command")
|
| 66 |
|
| 67 |
p_get = sub.add_parser("get", help="Get a voice from a model (safetensors repo, .gguf, or URL)")
|
| 68 |
p_get.add_argument("source", help="HF model ID, .gguf/.safetensors path, or URL")
|
| 69 |
p_get.add_argument("tensors", nargs="*", help="Tensor name(s) to fetch (default: auto-detect output head; 2+ or --multi saves a voicepack)")
|
| 70 |
+
p_get.add_argument("-q", "--quiet", action="store_true", help="Quieter: progress and success notes off (warnings and errors still print)")
|
| 71 |
+
p_get.add_argument("--name", help="Voice name to save (registry voices only; not with --out)")
|
| 72 |
+
p_get.add_argument("--multi", action="store_true", help="Fetch the named tensors (1+) as voicepack.safetensors + voicepack.json (not with --name)")
|
| 73 |
p_get.add_argument("--out", help="Write a standalone file instead of a registry voice (default pack name: voicepack.safetensors)")
|
| 74 |
+
p_get.add_argument("--yes", action="store_true", help="Assume yes to prompts (overwrite without asking)")
|
| 75 |
|
| 76 |
p_cast = sub.add_parser("cast", help="Cast a voice onto a .gguf or .safetensors file")
|
| 77 |
p_cast.add_argument("target", help="Path to the target .gguf or .safetensors")
|
| 78 |
p_cast.add_argument("voice", help="Voice name, or a .safetensors/.gguf path")
|
| 79 |
p_cast.add_argument("tensors", nargs="*", help="Only cast these tensors (default: every tensor in the voice)")
|
| 80 |
+
p_cast.add_argument("--out", help="Output file or folder (default: ~/Voiced/<voice>-<model>/<voice>-<model>.<ext matching target>; a folder invents the filename)")
|
| 81 |
+
p_cast.add_argument("--yes", action="store_true", help="Assume yes to prompts (overwrite without asking)")
|
| 82 |
+
p_cast.add_argument("--quant", default="keep", help="Output quant override: keep (default, preserve quality) | target | any quant (q8_0,q4_0,q4_k,q6_k,iq4_nl,f16,f32,bf16,...; safetensors targets: keep|target|f32|f16|bf16)")
|
| 83 |
+
p_cast.add_argument("--exclude", action="append", dest="excludes", default=[], help="Skip tensors on cast (repeatable: --exclude foo --exclude bar, or --exclude foo,bar)")
|
| 84 |
+
p_cast.add_argument("--speak", action="store_true", help="Voice speaks through output.weight (invented if absent when head/embed geometry survives; GGUF targets only)")
|
| 85 |
+
p_cast.add_argument("-q", "--quiet", action="store_true", help="Quieter: progress and success notes off (warnings and errors still print)")
|
| 86 |
p_delta = sub.add_parser("delta", help="Make a reusable style (voice − base)")
|
| 87 |
+
p_delta.add_argument("voicename", nargs="?", help="Voice name (default: pick from registry)")
|
| 88 |
p_delta.add_argument("--base", help="Base HF repo (org/model) or local path to base safetensors")
|
| 89 |
+
p_delta.add_argument("--yes", action="store_true", help="Assume yes to prompts (overwrite without asking)")
|
| 90 |
+
p_delta.add_argument("-q", "--quiet", action="store_true", help="Quieter: progress and success notes off (warnings and errors still print)")
|
| 91 |
|
| 92 |
p_add = sub.add_parser("add", help="Add a voice from local voice.safetensors + voice.json")
|
| 93 |
p_add.add_argument("safetensors", help="Path to voice.safetensors (required)")
|
| 94 |
p_add.add_argument("json", help="Path to voice.json (required)")
|
| 95 |
p_add.add_argument("--name", help="Voice name to save (default from voice.json)")
|
| 96 |
p_add.add_argument("--yes", action="store_true", help="Auto-confirm overwrite")
|
| 97 |
+
p_add.add_argument("-q", "--quiet", action="store_true", help="Quieter: progress and success notes off (warnings and errors still print)")
|
| 98 |
|
| 99 |
p_list = sub.add_parser("list", help="List stored voices")
|
| 100 |
+
p_list.add_argument("target", nargs="?", choices=["base"], metavar="base", help="Show cached base heads (same as --base)")
|
| 101 |
+
p_list.add_argument("--base", dest="list_base", action="store_true", help="Show cached base heads instead of voices")
|
| 102 |
+
p_list.add_argument("-q", "--quiet", action="store_true", help="Quieter: progress and success notes off (warnings and errors still print)")
|
| 103 |
|
| 104 |
p_info = sub.add_parser("info", help="Show voice details")
|
| 105 |
+
p_info.add_argument("voicename", help="Voice name")
|
| 106 |
+
p_info.add_argument("-q", "--quiet", action="store_true", help="Quieter: progress and success notes off (warnings and errors still print)")
|
| 107 |
|
| 108 |
p_rm = sub.add_parser("remove", help="Remove a stored voice")
|
| 109 |
+
p_rm.add_argument("voice", help="Voice name")
|
| 110 |
+
p_rm.add_argument("--yes", action="store_true", help="Assume yes to prompts (remove without asking)")
|
| 111 |
+
p_rm.add_argument("-q", "--quiet", action="store_true", help="Quieter: progress and success notes off (warnings and errors still print)")
|
| 112 |
|
| 113 |
p_cleanup = sub.add_parser("cleanup", help="Remove incomplete downloads")
|
| 114 |
+
p_cleanup.add_argument("--force", action="store_true", help="Also clear in-progress downloads (locked)")
|
| 115 |
+
p_cleanup.add_argument("-q", "--quiet", action="store_true", help="Quieter: progress and success notes off (warnings and errors still print)")
|
| 116 |
|
| 117 |
p_auth = sub.add_parser("auth", help="Save your HF token (optional)")
|
| 118 |
+
p_auth.add_argument("--clear", action="store_true", help="Remove the stored token")
|
| 119 |
+
p_auth.add_argument("--show", action="store_true", help="Show the masked token")
|
| 120 |
+
p_auth.add_argument("-q", "--quiet", action="store_true", help="Quieter: progress and success notes off (warnings and errors still print)")
|
| 121 |
|
| 122 |
p_report = sub.add_parser("report", help="Save a report locally and optionally share to community")
|
| 123 |
p_report.add_argument("--message", "-m", help="Freeform note (240ch, sanitized)")
|
| 124 |
p_report.add_argument("--voice", help="Voice name context")
|
| 125 |
p_report.add_argument("--target", help="Target file basename context")
|
| 126 |
p_report.add_argument("--reporter", help="Reporter id (optional, 64ch)")
|
| 127 |
+
p_report.add_argument("--yes", action="store_true", help="Non-interactive: skip preview and auto-share to community")
|
| 128 |
p_report.add_argument("--no-push", action="store_true", help="Local only, skip share prompt")
|
| 129 |
p_report.add_argument("--sync", action="store_true", help="Sync pending outbox to community")
|
| 130 |
+
p_report.add_argument("-q", "--quiet", action="store_true", help="Quieter: progress and success notes off (warnings and errors still print)")
|
| 131 |
p_report.add_argument("--operation", help=argparse.SUPPRESS)
|
| 132 |
|
| 133 |
+
p_path = sub.add_parser("path", help="Put voice on your PATH")
|
| 134 |
+
p_path.add_argument("-q", "--quiet", action="store_true", help="Quieter: progress and success notes off (warnings and errors still print)")
|
| 135 |
+
p_doctor = sub.add_parser("doctor", help="Check your setup")
|
| 136 |
+
p_doctor.add_argument("-q", "--quiet", action="store_true", help="Quieter: progress and success notes off (warnings and errors still print)")
|
| 137 |
|
| 138 |
args = parser.parse_args()
|
| 139 |
VERBOSE = args.verbose
|
| 140 |
ctx.VERBOSE = args.verbose
|
| 141 |
+
ctx.QUIET = bool(getattr(args, "quiet", False))
|
| 142 |
|
| 143 |
if getattr(args, "completion", None):
|
| 144 |
_print_completion(args.completion)
|
|
|
|
| 148 |
sys.exit(0)
|
| 149 |
if args.command is None:
|
| 150 |
parser.print_help()
|
| 151 |
+
sys.exit(2)
|
| 152 |
|
| 153 |
_ensure_venv(args.command)
|
| 154 |
|
voice.pyz
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c40ffe00455ad5333d675583f91175f9ae059bce03fa2a8a64dc16837379981e
|
| 3 |
+
size 256579
|