human-voice-writer
# human-voice-writer
**Your agent trains a small LLM on your writing, on your machine, then rewrites any draft so it sounds like you.**
Built for sales and GTM outreach: cold emails, LinkedIn DMs and follow-ups, where an AI tone costs you replies. You write a draft (or let an AI write it), run it through `voice humanize`, and get the same message back in your voice: same names, numbers, links and ask.
- **One prompt, one confirmation.** Your agent (Claude Code, Cursor, Codex) shows you what it found and the plan, then does the whole setup: collect, de-identify, build the dataset, train, evaluate, fix.
- **Local and private.** Training and inference run on your Mac (MLX) or your NVIDIA GPU. Your messages never leave the machine. No cloud GPUs, no API key after setup.
- **Fact lock.** Names, numbers, links and the ask can't change. If the model changes one, it regenerates; if it keeps failing, you get your original draft back.
- **Measured, not vibes.** An automatic eval compares the fine-tune with a "big model + style prompt" baseline on your own held-out messages, and says so if the fine-tune loses.
## Quickstart
Tell your agent:
```
install gtm.zelto.ai/set-up-human-voice-writer.md
```
The agent follows [`set-up-human-voice-writer.md`](set-up-human-voice-writer.md). First it runs a diagnostic: which models can train on your machine and which sources it can reach (connectors, exports on disk, local app databases, note folders). Then it asks you **once**: go with that plan, customize it (model, sources), or add a source it didn't see. After that it runs to the end and finishes with one message: your score and how to use it. The only other things you may see are the permission prompts your agent or OS shows anyway (connector login, macOS Full Disk Access).
Then:
```bash
voice humanize "Hi Priya, I hope this finds you well. Could we move the demo to 4pm Thursday?"
cat draft.txt | voice humanize -c linkedin
voice humanize -c whatsapp "..." # message channels can print several short messages, the way you text
```
Or ask your agent: *"humanize this before sending"*. It calls the `voice_humanize` MCP tool.
## Requirements
- An **Apple Silicon Mac** (8 GB+) or a PC with an **NVIDIA GPU** (6 GB+ VRAM). Other machines are not supported in v0; setup says so and stops.
- Python 3.10–3.13 and [uv](https://docs.astral.sh/uv/).
- The agent's own connectors and browser for collection (Gmail/Slack MCPs, a browser tool). Without them it uses whatever is on disk: Takeout, LinkedIn/X exports, WhatsApp chats, notes.
## How it works
| Step | Command (CLI / MCP) | What happens |
|---|---|---|
| Setup | `voice setup` / `voice_setup` | The diagnostic: hardware, the models that fit (from [`models.yaml`](models.yaml)), and local sources found (paths only). Installs local deps, registers the MCP server. `--model` applies your choice |
| Confirm | the agent asks you once | Go with the plan, customize it, or add a source |
| Collect | the agent's own tools | The agent wires each source it can reach and writes canonical records to `~/.voice/raw/*.jsonl` |
| Prepare | `voice prepare` / `voice_prepare` | Loads the records, merges chat bursts (~2 min), strips email quotes and signatures, de-identifies, drops sensitive messages, dedupes, holds out ~12%, deletes raw files |
| Pairs | `voice add-pairs` / `voice_add_pairs` | The agent writes an "AI-style" version of each message; pairs whose facts don't match are rejected |
| Train | `voice train` / `voice_train` | LoRA fine-tune on this machine (MLX or Unsloth/TRL) |
| Eval | `voice eval` / `voice_eval` | Style similarity, local AI-detector, fact lock, local baseline, "is it me?" judge pairs + agent baseline → pass/fail + suggested fix |
| Use | `voice humanize` / `voice_humanize` | Channel-aware rewrite with the fact lock |
| Status | `voice status` / `voice_status` | Models, default, last eval, running jobs |
Everything lives in `~/.voice/` (set `VOICE_HOME` to move it).
### Sources: wired by the agent
The tool doesn't ship a parser for any app. Connectors, exports and local databases differ for every user and change all the time, and the user's agent already knows how to reach them. The agent wires each source and writes **canonical records**, one JSON object per message:
```json
{"text": "the message exactly as sent", "is_me": true, "from": "Sender Name", "to": ["Recipient"],
"thread": "conversation id", "channel": "whatsapp", "ts": "2026-03-01T10:00:00Z"}
```
Everything after that is the tool's process: email cleanup (quoted replies, signatures), chat bursts, context from the other side, a fallback when `is_me` is missing, de-identification, dedupe and the held-out split. The playbook tells the agent where each source usually lives and the rules for converting it (one record per message, include the other side, drop system and AI-written text, never pre-redact).
### De-identification
Local only: regex (emails, phones, URLs, cards with a Luhn check, IBANs, IDs, handles, street addresses), every third-party name found in message metadata (senders, recipients, chat partners), a greeting heuristic ("Hola Martina"), and spaCy NER when installed (`[ner]` extra; `voice setup` downloads `xx_ent_wiki_sm`). Placeholders are consistent across the dataset (`<PERSON_1>` is always the same person; "Ana" and "Ana Pérez" share one). The user's own name, company and email domain are kept. The agent then checks a sample and the `leak_candidates`, and re-runs with `--extra-redact "Nickname" --extra-redact "Acme=COMPANY"`.
### Models
Picked from the hardware by default; see [`models.yaml`](models.yaml) for the full fit matrix. New models are added there, with no code changes.
| Machine | Default |
|---|---|
| Mac 8 GB | `tiny` Qwen2.5-0.5B-Instruct |
| Mac 16 GB | `small` Qwen3-1.7B |
| Mac 32 GB+ | `medium` Qwen3-4B |
| NVIDIA 8 GB | `small` Qwen3-1.7B |
| NVIDIA 16–24 GB | `medium` Qwen3-4B |
`voice train` refuses models marked ❌ for the machine. On a failed eval, the suggested fix walks up the catalog to the next model that fits.
`voice bench` measures real training times on your Mac and `voice setup` shows them. Measured on an M5 Pro (64 GB), for 1,000 messages × 3 epochs (~300 tokens each):
| Model | Size | Minutes |
|---|---|---|
| `tiny` Qwen2.5-0.5B-Instruct | 0.5B | 2.9 |
| `tiny-q3` Qwen3-0.6B | 0.6B | 3.0 |
| `small` Qwen3-1.7B | 1.7B | 6.1 |
| `small-alt` SmolLM2-1.7B-Instruct | 1.7B | 6.7 |
| `medium` Qwen3-4B | 4B | 14.1 |
| `large` Qwen3-8B | 8B | 23.1 |
Times for other machines in `models.yaml` are estimates until someone runs `voice bench` there.
### Channels
Channels come from your data: the agent names one per source (`whatsapp`, `linkedin`, `imessage`, `slack`…), the model learns each, and `voice humanize -c <channel>` takes the same names (`voice status` lists them). The generic `message`, `post` and `email` always work. Each channel has a kind:
| Kind | Channels | Behavior |
|---|---|---|
| message | `message` and any name you invent (`whatsapp`, `linkedin`, `imessage`, `slack`, `sms`…) | Messages within ~2 min merge into one turn; humanize can return several short messages, the way you text |
| post | `post`, `linkedin_post`, `x`, `notes`, `*_post` | One block |
| email | `email`, `*_email` | Quoted replies and signatures stripped; one block |
A channel the model never saw falls back to the closest learned channel of the same kind.
### AI detector
`voice eval` scores outputs with a local AI-text detector: the mean of two small open classifiers that run on your machine, [fakespot-ai/roberta-base-ai-text-detection-v1](https://huggingface.co/fakespot-ai/roberta-base-ai-text-detection-v1) and [rasbt/ai-text-detector-modernbert](https://huggingface.co/rasbt/ai-text-detector-modernbert) (both Apache-2.0, ~275M parameters together, ~5 ms per message). `voice setup` installs them (`[detector]` extra) and caches the weights, so eval works offline.
We picked them by AUROC on 1,482 real de-identified messages vs AI-style rewrites of the same messages (English + Spanish, mostly short DMs):
| Detector | All | Spanish | Short (<12 words) | Long |
|---|---|---|---|---|
| **fakespot + rasbt (default)** | **0.76** | **0.82** | **0.81** | **0.73** |
| fakespot-ai/roberta-base-ai-text-detection-v1 | 0.73 | 0.70 | 0.73 | 0.71 |
| ShantanuT01/vanguard-ai-text-detector | 0.69 | 0.78 | 0.80 | 0.58 |
| rasbt/ai-text-detector-modernbert | 0.64 | 0.80 | 0.74 | 0.64 |
| desklib/ai-text-detector-v1.01 | 0.60 | 0.53 | 0.61 | 0.61 |
| previous heuristic (AI-tell phrases) | 0.59 | 0.54 | 0.57 | 0.59 |
| openai-community/roberta-base-openai-detector | 0.42 | 0.35 | 0.41 | 0.45 |
Without torch the eval falls back to the heuristic and says so. Change the models in `models.yaml` → `detector`.
### Export to llama.cpp, Ollama, LM Studio
```bash
voice export # merge adapter → GGUF (Q4_K_M) + Ollama Modelfile, in ~/.voice/models/<id>/export/
voice export --ollama-name my-voice # also runs `ollama create my-voice` if Ollama is installed
voice export --format hf # merged Hugging Face safetensors instead
```
GGUF export needs llama.cpp (`brew install llama.cpp`); the converter is fetched from the same llama.cpp commit as your binaries. Exported models take prompts in the training format (`Channel: <channel>\nDraft:\n<draft>`, system prompt from `voice export --print-system`). The fact lock lives in `voice humanize`, so use that when names, numbers and links must not change.
## Development
```bash
uv venv && uv pip install -e ".[mlx,ner,detector,dev]"
.venv/bin/python -m pytest # synthetic fixtures only, no model downloads
VOICE_BACKEND=fake voice ... # run any command without a GPU (deterministic fake model)
VOICE_HARDWARE=mac8 voice setup # pretend to be another machine tier
```
```
models.yaml base model catalog + hardware fit matrix
set-up-human-voice-writer.md the agent playbook (the product)
voice/
ingest.py canonical records → messages → turns (source-agnostic)
channels.py channel names and kinds (message / post / email), learned from the data
deid.py de-identification
prepare.py voice_prepare + voice_add_pairs (dataset builder)
train.py, train_cuda.py voice_train (MLX / Unsloth)
eval.py, detector.py voice_eval
humanize.py, factlock.py voice_humanize + fact lock
hardware.py, setup_tool.py hardware detection, model selection, voice_setup
diagnose.py local source scan for the setup diagnostic (paths only)
export.py, bench.py voice export (GGUF / Ollama), voice bench (measured training times)
server.py MCP stdio server (7 tools)
cli.py CLI mirror
examples/ synthetic sample dataset
tests/ tests + synthetic fixtures
```
The MCP server lives at `voice/server.py` rather than the spec's `mcp/server.py`, because a top-level `mcp/` package would shadow the MCP SDK it imports.
## License
MIT. See [LICENSE](LICENSE).
TDQS
Scored across 7 tools
Each tool maps to a distinct pipeline stage (setup, status, prepare, add_pairs, train, eval, humanize), so an agent can mostly tell them apart. Minor overlap: setup and status both surface model/default info, and prepare vs add_pairs both touch datasets, though descriptions differentiate them.
All seven tools use a uniform voice_ prefix with a clear verb/noun or verb form (voice_setup, voice_status, voice_prepare, voice_add_pairs, voice_train, voice_eval, voice_humanize). The convention is predictable and consistent throughout.
Seven tools is well-scoped for a fine-tuning-plus-generation pipeline. Each tool earns its place as a discrete stage with no bloat.
The surface covers the full lifecycle: setup, monitoring, data prep, pair authoring, training, evaluation, and generation. Minor gaps exist (no delete/reset, model export, or dataset cleanup), but core workflows are fully closed.