DEV Community

Cover image for How I Check an Audiobook for Missing Words
cleora
cleora

Posted on

How I Check an Audiobook for Missing Words

Part 3 of Building All to Audiobook

What if a passage sounds natural but skips half a sentence? In Studio, I transcribe each generated passage locally and compare it with the source text. That gives me specific passages to review before exporting a whole book.

Building All to Audiobook

I ran into these problems while building All to Audiobook for my mom. After neck surgery, holding a book became difficult for her, and many of the ebooks she wanted to read had no audiobook edition. I wanted her to turn books she already had into audio she could keep and listen to in her usual player.

The app processes documents and generates speech on the reader's own device, then exports MP3 or chaptered M4B files. This series follows the practical problems I encountered while building it, the approaches I chose, and what still needs work.

The first part covered text preparation. The second covered saving finished passages so a closed tab doesn't mean starting over. This time I'm looking at the audio itself. The checks and editing controls below are in Studio, the desktop app.

A good voice sample doesn't settle it

One Chinese listening comparison left me choosing between an expressive reading with unstable tone and a steadier one that sounded a little flat. I kept the steadier version for long listening sessions.

For a narrator made from a reference recording, I reuse that recording and its transcript for each passage, with fixed sampling settings. I shorten long pauses in the generated audio. At export, I measure each chapter's loudness and apply a second normalization pass so chapters play at a similar level.

These steps help with consistency. They can't tell me whether the model left out part of the text. A passage with missing words can still have an ordinary duration and a convincing voice.

How do I check for missing words?

After generating a passage, a separate local speech-recognition model transcribes it in the book's language. I compare that transcript with the text the voice was supposed to read.

The comparison uses the longest common subsequence. It counts source words that appear in the transcript in the same order, allowing gaps where words are missing or different. English, German, French and Spanish use word tokens; Chinese uses individual characters. Case and punctuation don't count.

The score is the matched token count divided by the source token count. I also keep the unmatched phrases, so the interface can highlight the part worth listening to.

For example, suppose the input says:

Nora left the lantern on the table beside the open window.

And the transcript says:

Nora left the lantern beside the open window.

Eight of eleven words match. The missing phrase is "on the table." This is an illustration of the comparison, not a recording from a test.

Illustrative word comparison: the source has eleven words, the transcript matches eight in order, and the missing phrase is on the table. The score is about 73%, below the 80% threshold.

The check compares text with a transcript. A low score can come from a speech error or a transcription error.

Pronunciation replacements complicate the comparison. The spelling I send to the narrator may differ from the spelling a transcriber writes down. I compare against both the prepared book text and the pronunciation-adjusted version, then use the better match. I also normalize forms such as "Mr." and "Mister."

One automatic retry, then a decision

When fewer than 80% of the source tokens match, Studio makes one more take with a new random seed for voices that can produce a different reading. It transcribes the second take and keeps it only if its match score is higher.

The English preset voices are an exception. Changing the seed doesn't change their reading, so I don't automatically generate the same passage twice. A pronunciation-list edit can help when a particular word sounds wrong.

If the kept take remains below the threshold, the passage gets a Check label. The rest of the book continues. I don't keep retrying until the recognizer happens to accept something.

The 80% threshold is a review rule, not an accuracy claim. A passage can pass while still missing a word. The check gives me a way to find substantial omissions without requiring a full listen before I can inspect anything.

Fix the passage and keep the rest

A flagged passage shows the match count and highlights the unmatched phrases. The reader can play that passage, choose Make again, or select It sounds right: keep it if the audio is fine.

That last option matters because the recognizer can be wrong. It might transcribe a name differently even when the narrator said it correctly. I want the reader to be able to clear that warning after listening.

A manual remake puts that passage back in the queue and leaves the other completed passages alone. Its old audio file stays until a replacement is ready. Speed and the pause after a passage can also be adjusted without asking the voice model to speak again.

Saving individual passages, which I wrote about last time, makes this possible. The reader can repair a small part of the book and build the final download from the resulting files.

What the score misses

The current comparison is permissive about numbers. A number written as digits can match a number written as words, even when they represent different values. That avoids some false warnings, but it means this check cannot verify that a date or amount was read correctly.

Extra words are another gap. If the transcript includes all the source words in order and repeats a sentence afterward, the score can still be 100%. I haven't added a repetition penalty to this check.

Very short passages are skipped: fewer than four word tokens, or six Chinese characters. If the transcription worker fails, the passage stays unchecked and the book continues. Neither case proves the audio is correct.

And a transcript tells me little about an awkward pause, a sudden change in tone, or a voice that becomes tiring over several chapters. Those still need listening. I use the check to find likely omissions and make them repairable; I still choose voices by ear.

You can try All to Audiobook with a text-based PDF. For the passage checking and remakes described here, use Studio, the desktop app.

Next in the series: running a speech model inside a browser, using the GPU when it works and falling back to the CPU when it doesn't.

Top comments (0)