# How to Clone a Voice from a Family Archive: Recording, Fine-Tuning a TTS Model and Running It Locally

> AI Release · @ai_releaseorg · https://ai-release.org/guides/kak-klonirovat-golos-iz-semeynogo-arhiva-zapis-obucheni_en.html

## TL;DR
- Time to complete: 2–4 hours of manual work (digitizing, cleaning, dataset assembly), plus unattended training time that depends on your GPU and dataset size.
- Difficulty: Intermediate — you need a terminal, Python virtual environments, and basic audio knowledge (sample rate, mono/stereo).
- You will need: Linux, macOS, or WSL2 on Windows; `ffmpeg`/`ffprobe`; Python 3 with `venv`; Whisper for transcription; one open TTS toolkit that ships a fine-tuning recipe (for example Coqui TTS/XTTS or Piper — the exact commands differ per release, so check that toolkit's documentation); a GPU with enough VRAM for your chosen recipe; written consent from the family members whose voices you use.

## What you will get
- A cleaned, single-speaker dataset in `dataset/wavs/` plus a validated `dataset/metadata.csv` that any LJSpeech-style training recipe can read.
- A fine-tuned voice checkpoint in `models/family_voice_v1/` and a `configs/finetune_voice.yaml` you can re-run for the next training round.
- A local HTTP service on `http://127.0.0.1:8080/speak` that returns a `.wav` file for any text you POST to it.

## Quick start
```bash
mkdir -p archive/raw archive/wavs dataset/transcripts dataset/wavs out models
ffmpeg -i archive/raw/tape_01.wav -af "highpass=f=80,lowpass=f=8000,afftdn=nf=-25,loudnorm=I=-16:TP=-1.5:LRA=11" -ar 22050 -ac 1 -sample_fmt s16 archive/wavs/tape_01_clean.wav
ffprobe -v error -show_entries stream=sample_rate,channels -show_entries format=duration -of default=noprint_wrappers=1 archive/wavs/tape_01_clean.wav
whisper archive/wavs/tape_01_clean.wav --model small --language en --output_dir dataset/transcripts --output_format tsv
```
Details and verification — in the steps below.

## Requirements and setup
![Illustration: Requirements and setup](https://ai-release.org/guides/img/kak-klonirovat-golos-iz-semeynogo-arhiva-zapis-obucheni-en-1.jpg?v=1795423782)

- **OS:** Linux, macOS, or Windows with WSL2. All commands below are bash.
- **ffmpeg + ffprobe:** `sudo apt install ffmpeg` (Debian/Ubuntu) or `brew install ffmpeg` (macOS). Verify with `ffmpeg -version`.
- **Python 3 + venv:** `python3 -m venv .venv && source .venv/bin/activate`.
- **Whisper:** `pip install -U openai-whisper`. It downloads model weights on first run, so budget disk space.
- **TTS toolkit:** pick one with a documented fine-tuning recipe and install it inside the same venv. Version pinning, VRAM needs and flag names are toolkit-specific — check the documentation of the one you pick.
- **Hardware:** if you plan to train on GPU, size it first: see [How much RAM and VRAM a local LLM needs](https://ai-release.org/guides/localnye-ii-modeli-skolko-ram-i-vram.html?utm_source=tg&utm_medium=channel&utm_campaign=guide_inline&utm_content=guide_to_guide) for how VRAM maps to model size and batch size.
- **Legal:** only clone voices of people who gave you explicit permission. Get it in writing before you train.
- **Checklist before you start:**
  - [ ] Original recordings copied to `archive/raw/` and never edited in place
  - [ ] A backup of `archive/raw/` on a second disk
  - [ ] Consent confirmed for every speaker in the dataset
  - [ ] `ffmpeg -filters | grep loudnorm` returns a line (the filter exists in your build)

## Step 1. Digitize, clean and segment the archive recordings
**What to do:** inventory every source file, convert it to the format your toolkit expects, remove hiss and level jumps, then cut long recordings into short clips.

**Why:** TTS training reads short aligned clips. Cassette and reel-to-reel transfers carry hum, wow-and-flutter and uneven loudness; if you train on that, the model learns the noise as part of the voice.

```bash
for f in archive/raw/*; do
  echo "== $f"
  ffprobe -v error -show_entries stream=codec_name,sample_rate,channels \
    -show_entries format=duration -of default=noprint_wrappers=1 "$f"
done
```

**Example:** the inventory prints `sample_rate=44100`, `channels=2`, `duration=1832.400000` for `tape_01.wav` — a 30-minute stereo transfer that must become mono 22050 Hz for most recipes.

Cleaning and downmix:

```bash
ffmpeg -i archive/raw/tape_01.wav \
  -af "highpass=f=80,lowpass=f=8000,afftdn=nf=-25,loudnorm=I=-16:TP=-1.5:LRA=11" \
  -ar 22050 -ac 1 -sample_fmt s16 archive/wavs/tape_01_clean.wav
```

Why it works: `highpass`/`lowpass` cut rumble and tape hiss outside the speech band, `afftdn` is a noise reducer, `loudnorm` normalizes perceived loudness, and `-ac 1` collapses stereo to mono. 22050 Hz / 16-bit / mono is a common training input format — confirm the exact rate your toolkit expects in its docs.

Find the quiet gaps, then cut clips of roughly a few seconds each:

```bash
ffmpeg -i archive/wavs/tape_01_clean.wav -af silencedetect=noise=-35dB:d=0.5 -f null - 2>&1 | grep silence_
ffmpeg -ss 00:00:12.400 -to 00:00:19.100 -i archive/wavs/tape_01_clean.wav -c copy archive/wavs/tape_01_0012.wav
```

**How to check:** `ffprobe` on a clip must show exactly one mono stream at your target rate:

```bash
ffprobe -v error -show_entries stream=sample_rate,channels -of default=noprint_wrappers=1 archive/wavs/tape_01_0012.wav
# sample_rate=22050
# channels=1
```

If you see `channels=2` or a different `sample_rate`, the conversion step did not apply — re-run the cleaning command on that source file.

## Step 2. Build the dataset and fine-tune the TTS model
![Illustration: Step 2. Build the dataset and fine-tune the TTS model](https://ai-release.org/guides/img/kak-klonirovat-golos-iz-semeynogo-arhiva-zapis-obucheni-en-2.jpg?v=1795423789)

**What to do:** transcribe every clip, write a `metadata.csv` manifest, validate it, and start the training run.

**Why:** a fine-tuning recipe needs two things: audio files and their exact transcripts. Mismatched transcripts teach the model wrong pronunciation, and a missing file aborts training halfway through.

Transcribe each clip (run per file or in a loop):

```bash
whisper archive/wavs/tape_01_0012.wav --model small --language en --output_dir dataset/transcripts --output_format tsv
```

**Example:** the command writes `dataset/transcripts/tape_01_0012.tsv`; open it, fix names and numbers by hand, and keep only the text column.

Assemble the manifest — the standard LJSpeech-style format is `file_id|text|normalized_text`, and `file_id` is the filename without `.wav`:

```python
# build_metadata.py — run: python build_metadata.py
import csv
from pathlib import Path

rows = []
for tsv in sorted(Path("dataset/transcripts").glob("*.tsv")):
    lines = tsv.read_text(encoding="utf-8").strip().splitlines()[1:]  # skip header
    text = " ".join(l.split("\t", 1)[-1].strip() for l in lines if l.strip())
    rows.append((tsv.stem, text, text))

with open("dataset/metadata.csv", "w", encoding="utf-8", newline="") as f:
    csv.writer(f, delimiter="|").writerows(rows)
print(f"wrote {len(rows)} rows")
```

Validate before burning GPU time — this script also produces the error text used in Troubleshooting:

```python
# check_dataset.py — run: python check_dataset.py dataset/wavs dataset/metadata.csv
import csv, sys, wave
from pathlib import Path

wavs, meta = Path(sys.argv[1]), Path(sys.argv[2])
bad = 0
for i, row in enumerate(csv.reader(meta.open(encoding="utf-8"), delimiter="|"), 1):
    if not row or not row[0].strip():
        continue
    f = wavs / f"{row[0]}.wav"
    if not f.exists():
        print(f"ERROR: metadata.csv line {i}: audio file {f} not found")
        bad += 1
        continue
    with wave.open(str(f)) as w:
        dur = w.getnframes() / w.getframerate()
    if dur < 2 or dur > 15:
        print(f"WARN: {f.name} duration {dur:.2f}s outside 2-15s")
sys.exit(1 if bad else 0)
```

Training config (rename keys to match your toolkit's schema — schemas differ between releases, so check the documentation):

```yaml
# configs/finetune_voice.yaml
dataset:
  meta_file: dataset/metadata.csv
  wav_dir: dataset/wavs
audio:
  sample_rate: 22050
  mono: true
train:
  batch_size: 8
  epochs: 10
  output_dir: models/family_voice_v1
```

Start the run with your toolkit's training entry point (placeholder — substitute the real module/script name from its docs):

```bash
python -m <toolkit>.train --config configs/finetune_voice.yaml
```

**How to check:** during training the log must print decreasing loss values, and after it finishes the output directory must contain a checkpoint plus a config file:

```bash
ls -lh models/family_voice_v1
# config.json
# model.pth        (name depends on the toolkit)
```

## Step 3. Run the cloned voice locally and verify it
![Illustration: Step 3. Run the cloned voice locally and verify it](https://ai-release.org/guides/img/kak-klonirovat-golos-iz-semeynogo-arhiva-zapis-obucheni-en-3.jpg?v=1795423794)

**What to do:** generate a test sentence from the checkpoint, then expose it as a local HTTP service on port 8080.

**Why:** a checkpoint is not a product. A small HTTP wrapper lets any script or app in your home network request speech without knowing the toolkit's Python API.

Smoke test through the toolkit CLI first:

```bash
tts --model_path models/family_voice_v1 \
    --config_path models/family_voice_v1/config.json \
    --text "Grandma, this recording is for the family archive." \
    --out_path out/smoke.wav
```

Then the service (loader class and argument names vary by toolkit — check the docs):

```python
# server.py — run: uvicorn server:app --host 127.0.0.1 --port 8080
import uuid, pathlib
from fastapi import FastAPI
from fastapi.responses import FileResponse
from pydantic import BaseModel
from TTS.api import TTS

app = FastAPI()
tts = TTS(model_path="models/family_voice_v1",
          config_path="models/family_voice_v1/config.json")
OUT = pathlib.Path("out"); OUT.mkdir(exist_ok=True)

class Req(BaseModel):
    text: str

@app.post("/speak")
def speak(req: Req):
    name = f"{uuid.uuid4().hex}.wav"
    tts.tts_to_file(text=req.text, file_path=str(OUT / name))
    return FileResponse(OUT / name, media_type="audio/wav")
```

Install and start: `pip install fastapi uvicorn`, then `uvicorn server:app --host 127.0.0.1 --port 8080`.

**How to check:** POST a sentence and inspect the returned file:

```bash
curl -X POST http://127.0.0.1:8080/speak \
  -H "Content-Type: application/json" \
  -d '{"text":"We are recording this for the family archive."}' \
  -o out/test.wav
file out/test.wav
# out/test.wav: RIFF (little-endian) data, WAVE audio, 16 bit, mono 22050 Hz
```

Success looks like a `.wav` of plausible length that keeps the speaker's timbre and accent. Compare it side by side with a source clip; if the output is intelligible but flat, the dataset was probably too small or too noisy — go back to Step 1. For more local-model runtime options, see [Open-weight AI models: how to run them for free in 2026](https://ai-release.org/guides/kakie-ii-modeli-imeyut-otkrytye-vesa-i-kak-ih-zapustit.html?utm_source=tg&utm_medium=channel&utm_campaign=guide_inline&utm_content=guide_to_guide).

## Troubleshooting

**Problem. ffmpeg rejects the cleanup filter chain.**
- Error: `No such filter: 'loudnorm'`
- Cause: a minimal ffmpeg build without the filter set, or a distro package that strips filters.
- Solution: install the full build and confirm the filter exists: `sudo apt install --reinstall ffmpeg && ffmpeg -filters | grep loudnorm`. On static builds, download a full build from the vendor's own page.

**Problem. Dataset validation fails before training starts.**
- Error: `ERROR: metadata.csv line 42: audio file dataset/wavs/tape_01_0031.wav not found`
- Cause: the `file_id` in `metadata.csv` does not match the actual `.wav` filename — typical after renaming clips by hand or mixing `tape_01_0012.wav` with the id `tape01_0012`.
- Solution: list the mismatch and fix the id column: `ls dataset/wavs | head` then edit the line, or regenerate the manifest with `python build_metadata.py`. Re-run `python check_dataset.py dataset/wavs dataset/metadata.csv` until it exits with no `ERROR` lines.

**Problem. Training stops on the GPU.**
- Error: `RuntimeError: CUDA out of memory.` (the allocation sizes that follow vary per run)
- Cause: batch size or clip length is larger than your card's VRAM allows.
- Solution: lower `batch_size` in `configs/finetune_voice.yaml` (for example from 8 to 4 or 2), cut clips closer to a few seconds, and if your toolkit exposes gradient accumulation, raise it instead of the batch size. Confirm the flag name in the docs.

## Summary and next steps
You now have a cleaned dataset, a fine-tuned checkpoint, and a local voice service on port 8080. Next, version the dataset and config in git, then add a second speaker as a separate output directory so the two voices never contaminate each other's training data.

## FAQ

**How much audio do I need to clone a voice?**
It depends on the method: zero-shot cloning works from a short reference clip, while fine-tuning needs a larger transcribed dataset. Your toolkit documents its own minimum — check the documentation rather than guessing.

**Can I run the whole pipeline without a GPU?**
Cleaning and transcription run on CPU (Whisper is slower there), but training on CPU is impractical for most recipes. Size your card against the recipe's VRAM requirements before you start.

**Why does the output sound like the recording, hiss included?**
Because the model learned the noise as part of the voice. Re-clean the sources with `afftdn` and `loudnorm`, drop clips with music or overlapping speakers, and retrain.

**Can I publish the generated audio online?**
Only with the speaker's explicit permission, and be transparent that the voice is synthetic. Consent you collected for a private family archive does not automatically cover public distribution.
