Dev.to AI 🤖 Ai 👁 0 📖 7 min read

None of My 5 AI Voice Takes Was Upload-Ready: A Stdlib Python Pre-Upload Check for TTS Audio

#ad #ElevenAgentsPartner Disclosure: I'm an ElevenLabs affiliate partner. This post has no affiliate links; it links only to my own site, and some pages there contain affiliate links. Neither company sponsored or review

#ad #ElevenAgentsPartner

Disclosure: I'm an ElevenLabs affiliate partner. This post has no affiliate links; it links only to my own site, and some pages there contain affiliate links. Neither company sponsored or reviewed this post.

Last week I ran one 62-word YouTube Shorts script through five TTS engines and published the raw audio plus the numbers in Same Shorts script, five AI voices. The surprising part wasn't which voice sounded best. It was that none of the raw files was ready to upload. Every one sat below YouTube's playback level of about -14 LUFS, and a couple already touched 0 dBFS, so turning them up would clip.

That's a build problem, not a taste problem. So I wrote the post-generation checks as a small stdlib Python script, the same way you'd lint a file before you commit it.

What the test measured

From the original post (all files generated November 19, 2026, no edits, no normalization):

  • Duration and pace: all five finished in 21–22 seconds.
  • Loudness and true peak: from ffmpeg's EBU R128 meter. Raw files ranged from -23.4 to -16.9 LUFS.
  • Word mismatches: each file was transcribed with Whisper base and diffed against the 62-word script. That's a quick intelligibility check, not a listening panel.
  • License: what each engine's model card or terms say about commercial use.

For the demo I only load the three free engines (Microsoft Edge's "Andrew" voice through edge-tts, Kokoro-82M and Piper). ElevenLabs gets its own section on credits below.

The script

Stdlib only. The thresholds at the top are my targets, not platform rules, so change them.

#!/usr/bin/env python3
"""Pre-upload check for a voiceover take. Stdlib only.

Feed it the numbers you measured (ffmpeg loudnorm/ebur128 + a Whisper diff)
and it tells you what to fix before the take goes into a Short.
"""
import csv
import io
import sys

# My own targets. Change them; they are not platform rules.
TARGET_LUFS = -14.0      # roughly where YouTube plays back
CEILING_DBFS = -1.0      # true-peak ceiling after normalizing
MAX_MISMATCHES = 0       # Whisper word mismatches before I listen again
PACE_WPM = (150, 190)    # my comfortable range for a Short
MAX_SECONDS = 30.0       # my own length target for this format

# Measurements from infinityme.dev/blog/ai-voice-test-same-shorts-script/
# (62-word script, generated Nov 19, 2026). Local/free engines only here.
SAMPLE = """engine,seconds,wpm,lufs,peak_dbfs,mismatches,license
Edge neural (Andrew) via edge-tts,21.5,182,-20.4,-2.1,1,unclear
Kokoro-82M (af_heart),21.1,185,-22.4,0.0,0,apache-2.0
Piper (ljspeech-high),22.2,176,-16.9,0.2,4,gpl-engine+pd-data
"""

LICENSE_NOTES = {
    "apache-2.0": None,
    "gpl-engine+pd-data": "check the model card of the exact voice you use",
    "unclear": "no published commercial license for this route",
}


def check(row):
    """Return (gain_db, list_of_problems) for one take."""
    lufs = float(row["lufs"])
    peak = float(row["peak_dbfs"])
    gain = round(TARGET_LUFS - lufs, 1)
    problems = []

    new_peak = round(peak + gain, 1)
    if new_peak > CEILING_DBFS:
        problems.append(
            f"+{gain} dB gain puts peak at {new_peak:+} dBFS -> use a limiter, not plain gain")

    mism = int(row["mismatches"])
    if mism > MAX_MISMATCHES:
        problems.append(f"{mism} word mismatch(es) -> listen and regenerate those lines")

    wpm = int(row["wpm"])
    if not PACE_WPM[0] <= wpm <= PACE_WPM[1]:
        problems.append(f"pace {wpm} wpm outside {PACE_WPM[0]}-{PACE_WPM[1]}")

    secs = float(row["seconds"])
    if secs > MAX_SECONDS:
        problems.append(f"{secs}s is over your {MAX_SECONDS}s target")

    note = LICENSE_NOTES.get(row["license"], "unknown license -> do not publish yet")
    if note:
        problems.append(f"license: {note}")
    return gain, problems


def credits_to_usd(credits, plan_usd, plan_credits):
    """Cost of one take on a credit plan (character-cost header -> dollars)."""
    return round(credits * plan_usd / plan_credits, 4)


def main(text):
    rows = list(csv.DictReader(io.StringIO(text)))
    clean = 0
    for row in rows:
        gain, problems = check(row)
        status = "OK " if not problems else "FIX"
        print(f"[{status}] {row['engine']}  (normalize: {gain:+} dB)")
        for p in problems:
            print(f"       - {p}")
        clean += not problems
    print(f"\n{clean}/{len(rows)} takes ready to upload as-is")
    return clean


if __name__ == "__main__":
    data = open(sys.argv[1]).read() if len(sys.argv) > 1 else SAMPLE
    main(data)

The loudness part is the one people skip. To hit -14 LUFS you add -14 - measured_lufs dB of gain. That gain also lifts the peak by the same amount. If the new peak lands above your ceiling (I use -1 dBFS), plain gain will clip, and you need a limiter or a loudness normalizer that has a true-peak ceiling.

Output on the real numbers

$ python3 voice_check.py
[FIX] Edge neural (Andrew) via edge-tts  (normalize: +6.4 dB)
       - +6.4 dB gain puts peak at +4.3 dBFS -> use a limiter, not plain gain
       - 1 word mismatch(es) -> listen and regenerate those lines
       - license: no published commercial license for this route
[FIX] Kokoro-82M (af_heart)  (normalize: +8.4 dB)
       - +8.4 dB gain puts peak at +8.4 dBFS -> use a limiter, not plain gain
[FIX] Piper (ljspeech-high)  (normalize: +2.9 dB)
       - +2.9 dB gain puts peak at +3.1 dBFS -> use a limiter, not plain gain
       - 4 word mismatch(es) -> listen and regenerate those lines
       - license: check the model card of the exact voice you use

0/3 takes ready to upload as-is

Zero out of three ready as-is. A few things this made obvious:

  • Kokoro was word-perfect in the test, and its model card lists Apache 2.0, which permits commercial use. Its only problem is level: +8.4 dB of gain on a file that already peaks at 0.0 dBFS. One limiter pass and it's done.
  • Piper is free and runs offline on a normal CPU, but Whisper heard "popcorn" as "pop one", "heat" as "eat" and "starch" as "start". The original post also noted it left only 0.3 s of silence across the whole take, which sounds rushed. The script doesn't measure pauses yet; that's a good next check to add with ffmpeg -af silencedetect.
  • Edge via edge-tts sounds good and costs nothing, but edge-tts is an unofficial client for Edge's read-aloud service, and Microsoft publishes no commercial license for using it that way. The post points to Azure AI Speech if you want the same voices with a clear license. So the script flags it until you switch routes.

Not legal advice. Terms change, so check each vendor's current terms before you publish.

The ElevenLabs part: read the header, not the pricing page

The same test also ran two ElevenLabs models on the same stock voice, Brian. In that test, Multilingual v2 came back word-perfect, and Flash v2.5 had 3 mismatches (it ran "Heat it" together into "Heated", for example). The useful trick for a pipeline is that the API returns a character-cost header with every request. You don't have to guess how many credits a take used.

For this 345-character script the header said:

  • Multilingual v2: 344 credits
  • Flash v2.5: 172 credits

credits_to_usd() turns that into money. The post priced it on Starter, listed at $6/month for 30,000 credits (elevenlabs.io/pricing, checked Nov 19, 2026):

$ python3 -c "from voice_check import credits_to_usd as c; print(c(344,6,30000), c(172,6,30000), 10000//344)"
0.0688 0.0344 29

So about $0.07 and $0.03 per Short. The last number is the free plan: 10,000 monthly credits covers about 29 scripts like this on Multilingual v2, but the Free plan is non-commercial and needs "elevenlabs.io" in the title. The Commercial License starts on Starter. If you're running a monetized channel, it's the Starter math that applies, not the free quota.

My suggestion for a pipeline: log the header value next to each generated file. After a month you have your real cost per Short, retakes included, instead of an estimate.

Tests

Ten small unittest cases cover the gain math, the limiter flag, the headroom edge case, each threshold, an unknown license, and the credit numbers from the post:

$ python3 test_voice_check.py
test_clean_take ... ok
test_credits_page_example ... ok
test_free_quota_count ... ok
test_gain_value ... ok
test_headroom_ok ... ok
test_length ... ok
test_limiter_needed ... ok
test_mismatch ... ok
test_pace ... ok
test_unknown_license ... ok
----------------------------------------------------------------------
Ran 10 tests in 0.000s

OK

How I'd wire it in

  1. Generate the take (any engine).
  2. Measure it: ffmpeg -i take.mp3 -af ebur128=peak=true -f null - gives integrated loudness and true peak.
  3. Transcribe with Whisper and diff the words against your script.
  4. Append a CSV row and run python3 voice_check.py takes.csv.
  5. Fix what it flags: limiter for level, regenerate only the mismatched lines, swap route if the license is unclear.

It's about 90 lines, it doesn't call any API, and it caught every one of my raw files. If you want to hear the five takes before you pick an engine, the audio is all on the original test page.

What do you check before a TTS file goes into your edit? I'm thinking of adding pause length next.

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.