Case file 13AI · Tooling9 min read

The free voices didn't make it. The free word timings did.

Paid text-to-speech voices the podcast one line at a time. I tried to replace it with local models that voice a whole conversation in one take. They lost, and the reasons are worth knowing before you try.

Read by an AI voice of Sajib. Words light up as he reads.

GPU memory

19 of 24 GB

What macOS lets the GPU use on a 24 GB Mac. Free RAM beyond that doesn't help.

Longest take that fit

275 words

402 words ran out of GPU memory. Takes are now capped at 240.

Words timed

1,388

97% heard as written by a local speech model. The rest placed between their neighbours.

The headphones on the desk play a podcast: about nine minutes of a host asking me about my work. The script is mine. The voices are AI, and the podcast says so in its first line.

This article covers how it’s voiced, what happened when I tried to voice it for free with local models, why the paid version stayed, and the one free piece that did make it: a transcript that follows the audio word by word.

One line at a time

The script is a Markdown file. Each line belongs to the host or to me. A script reads every line, sends it to a text-to-speech API, and joins the clips with short silences: a quick reply comes straight in, a change of topic gets a pause. It writes the MP3 and a JSON file with each line’s start and end time, which drives the transcript.

Each clip is cached under a hash of its voice, speed and text. Editing one line re-voices one line. Every call costs money, so pnpm podcast:dry lists the lines that would be voiced, and their size, without calling anything. A re-voice once started before the script was final. The dry run exists so that it doesn’t happen again.

One detail is worth knowing if you build the same thing. The API streams its WAV files, so the header carries a placeholder size, 0x7fff0000, instead of the real one. ffmpeg doesn’t mind. Stricter readers refuse the file. Every clip that leaves the pipeline is rewritten by ffmpeg first.

The problem with clips

Line by line is clean and cheap to edit, but the lines don’t hear each other. A reply doesn’t pick up the energy of the question before it. Hosted podcast tools voice the whole conversation in one go, and it shows.

Dialogue models do the same: give them a script with two speakers and two short voice samples, and they voice the exchange in one take. Several run locally through audio.cpp. My machine is an M4 Pro with 24 GB of memory. I tried two of them.

Model one: the voices drifted

The first was an 8-billion-parameter dialogue model, about 13 GB at 8-bit. It ran at roughly real time: about eight minutes for the episode.

It clones a voice by carrying on from a sample and its transcript. Over a long take the two voices bled into each other. The host lost her voice on some lines, and there was robotic distortion now and then. The model’s own documentation lists this drift as a known issue.

I tried to fix it with settings: shorter takes, a longer voice sample, a lower sampling temperature. The next run came back 2 minutes 40 seconds long. Eight of its twelve takes had stopped at exactly 5.52 seconds. The voices had also started to drift the other way. Every change traded one problem for another, so I stopped tuning it.

A reference that wasn’t what I thought

For more lively voices, I used samples from a hosted tool’s version of the same podcast. I cut that audio into lines by matching its pauses to the script’s timing.

The cuts were wrong from the start. When I later ran speech-to-text over it, the tool hadn’t read my script at all. It had voiced an older draft, reworded, with projects I had since removed. The “host” sample I had been cloning from had the guest’s voice inside it, saying “That’s fair, that’s most of my week.”

The lesson is cheap to apply: run speech-to-text over a voice sample before you clone from it. It takes seconds and shows what is really in the clip.

Model two: a ceiling I didn’t know about

The second model is built for long podcasts: up to 90 minutes and four speakers. It clones each voice from a sample alone, with no transcript. At 8-bit it is a 10.6 GB file.

It ran out of GPU memory on the first take, while memory still looked free. That’s the part worth knowing. On Apple silicon the GPU shares memory with everything else, but macOS caps how much of it the GPU may use. The log says so in one line:

recommendedMaxWorkingSetSize = 19069.67 MB

On a 24 GB Mac the GPU gets about 19 GB. The model takes over half of that before it says a word. The 6 GB of RAM that Activity Monitor showed as spare was outside the GPU’s allowance.

My first guesses were wrong. Loading part of the model at 8-bit didn’t help. Capping the number of tokens it could generate didn’t help either. So I stopped guessing and measured, growing the input until it broke:

Take Result
Two short lines Fits
97 words Fits: 31 seconds of audio
275 words Fits: 98 seconds of audio, in 2 minutes 14 seconds
402 words Out of GPU memory

Takes are now capped at 240 words, split at one of the host’s lines. The full episode became eight takes, voiced in about twelve minutes.

The take that repeated its sample

The first take began with 25 seconds of nonsense: “Welcome to the desk. I’m Alexis and today that you’re dash. Hi again…”

The host’s voice sample started with the same words as the script, “Welcome to the desk. I’m Alexis”. The model treats the sample as the start of its own speech. When the script said those words again, it carried on with the sample’s sentence instead of mine, and garbled the place where the two parted. A different random seed only moved the garble a few words along.

The fix is a sample that shares no words with the opening of the script. It’s an easy trap: the most natural sample of a host is the host introducing the show, which is exactly what the script opens with.

Why the paid voices stayed

With the memory limit and the echo fixed, the local episode ran start to finish. Listening to it next to the paid version, it still wasn’t good enough to replace it, so the paid version stayed.

The work isn’t lost. The scripts stay in the repo and the model files stay on disk, so trying the next local model is one command, and I already know the two traps to check first.

Word by word

The free piece that did make it is smaller.

The transcript used to highlight whole lines. Now it highlights the word being spoken. That needs the start time of every word, and the paid API doesn’t return them for speech it generates.

A speech-to-text model does. Parakeet, a 0.6-billion-parameter model, runs locally through the same audio.cpp, and it returns a time for every word it hears. Because the podcast is voiced line by line, every line’s clip is still in the cache. Each one is short, so there’s no long audio to split, and every timing is exact to its own line. All 67 clips go through in one session, so the model loads once.

What it hears isn’t always what the script says. It heard “frontend” as two words, “wait” as “weight”, and “Aisha” as “ASHA”. The site has to show the script’s words, so the two lists are lined up instead of copied. The longest common run of matching words gets the heard timings, and a script word also matches two heard words that join into it, like “front end”. Any word still without a match is placed between its neighbours, shared out by length. 97% of the 1,388 words were heard as written.

Once, the model skipped a whole sentence: it heard nothing after “December” in a 19-second line. My first version squeezed the sixteen missing words into the last word’s fraction of a second, so they would have flashed past. Now words missing at the end of a line spread out to the end of its clip. That’s the advantage of short clips: a miss stays inside one line, and the line’s own length bounds it.

Each line in the JSON file gets a list of word start times, in seconds from the line’s start. That’s about 7 KB of numbers on the page. In the player each word is a span. While the audio plays, a loop on the browser’s animation frame marks the current word. The audio element’s own timeupdate event fires only about four times a second, too slowly for single words. Only the spans that change are touched. Screen readers still read whole lines.

What I learned

Find the memory ceiling before you blame the model. On a Mac, the GPU’s share is a fixed fraction of RAM, and the log prints it. Measure what fits by growing the input until it breaks. It takes a few runs and replaces a lot of guessing.

Check what’s really in a voice sample. Run speech-to-text over it, and make sure it shares no words with the opening of what you’re about to voice.

Short clips make alignment safe. When a speech model misses something, the damage stays inside one line.

And look for the small model that does one job. The big local models didn’t replace the paid voices, but a small speech model, running for free in seconds, made the transcript better than the paid API could.