3. How detection works#
Detection opens with one pass over the whole file that transcribes nothing, and
then puts as much of the file through Whisper as it has to: the probing every
file pays for, and further passes that run only where chapters are still
missing. Each pass has a name rather than a number, and the progress bar names
the one that is running — as something in progress, so Probe shows as
Probing... and Scan as Scanning...:
| Pass | What it does | When it runs |
|---|---|---|
Download |
Fetches the book from an Audiobookshelf server. Its bar fills with bytes off the network rather than with play time. | Only in ABS mode |
Analyze |
Measures the file — silences, speech, music. Recognizes nothing. | Always |
Probe |
Transcribes a short window everywhere a chapter could start. | Always |
SC-probe |
The same, on a file with no chapter music: all it has to read is pauses, in chronological order. | Instead of Probe, whenever there is no music to read |
J-probe / S-probe |
The same probing, split into the jingles first and the pauses afterwards. | Instead of Probe, on a book of chapter music — see Reading the music first |
SD-probe |
A quick skim of the longest pauses, before the chronological walk itself. | On a book with no chapter music — see Reading the longest pauses first |
SF-probe |
Sweeps a gap for pauses shorter than probing was ever willing to consider. | Inside Probe or Re-probe, only where a chapter is missing |
Re-probe |
Probes a gap again on the heavier model. | Only with a heavier --upgrade-model, and only where a chapter is missing |
Scan |
Transcribes a whole stretch end to end. | Only where a chapter is still missing |
Re-scan |
Reads that stretch once more, framed differently. | Only where the Scan came back empty |
The names run cheapest to dearest: Analyze never calls Whisper at all, Probe
samples a few seconds at a time, and Scan reads everything. A Re- prefix
means the same machinery again over audio that already came back empty, framed
differently so the recognizer reads it afresh rather than repeating itself.
This section is an overview of what each pass does; the machinery that keeps it accurate and fast — how probe windows are sized and stitched together word-safely, how each mark is pinpointed to its exact position, the transcript caching and the self-tuning that cut the number of Whisper calls — is documented in the source. Only what affects using the tool is covered here.
Analyze — silences, speech and music#
ffmpeg's silencedetect filter finds every silence of at least half a second
below --noise-floor dBFS (normally −35), in one quick decode pass over the
whole file — short ones as well as long, because mark placement and window seams
are anchored to the whole list. Which of them are worth probing is a separate
question, decided afterwards by --min-silence-length (default, and starting
point with auto: 1.5 s). Chapter announcements in audiobooks practically always
follow such a pause. If the scan ends prematurely (e.g. because of a damaged file), the file
is aborted with an error instead of silently reporting "no chapters".
Before that scan, a few short excerpts from across the file are decoded to
check that the threshold suits this particular recording — see
--noise-floor. It costs about a second even on a
long book, and on an ordinary master it confirms the usual −35 dBFS and
changes nothing.
silencedetect is amplitude-only: a jingle (a short music sting) that abuts
the narration with no detectable gap around it produces no silence at all, so
it never gives Probe a candidate near that transition. By default, a
voice-activity detection pre-pass runs over the same decode using a bundled
model — Silero VAD, MIT-licensed,
embedded in the executable (~2.2 MB, no separate download; see
THIRD-PARTY-NOTICES.md). Music reads as
non-speech to a speech detector, the same as silence, so a jingle shows up as
a non-speech region flanked by speech even when there is no amplitude gap
around it, and Probe gets a candidate at every jingle it finds. There is no way
to switch this off: what the pre-pass measures — where each jingle starts and
where the speech behind it resumes — is what probe windows are cut to and what
mark placement is measured against, so a run without it would be a different
tool. A book with no music simply yields no jingles and costs the scan itself,
which is a fraction of one pass over the file.
Probe — short windows where a chapter could start#
A short window of audio is transcribed with Whisper at the start of the file and at every place a chapter could plausibly be announced. What made a place a candidate also decides where its window opens and how far it runs:
- A pause. The announcement is expected directly after it, so the window opens a few seconds before the pause ends — enough lead-in for the recognizer to settle — and runs about twenty seconds past it.
- A jingle, whenever the VAD pre-pass ran (the default; see Analyze). The announcement is expected in the first speech behind the music, so the window opens shortly before that speech begins. Where the pre-pass heard a brief sound inside the music, the announcement may be buried in it, and the window covers the whole jingle as well.
- A pause that merely leads into a jingle is not a candidate of its own. Everything a window from there would hear belongs to the jingle behind it, and the jingle listens for the same announcement from a better place.
No setting decides how wide any of these windows is — each is cut to its own
candidate, so a book's jingles cost only the jingles' own probes however long
they run. How far back the tool believes music can reach, where that question
comes up at all (see Scan and
--mark-before-jingle), is measured from the file's own jingles rather than
assumed.
Reading the music first#
On a book that announces every chapter after a music sting, the pauses in between can only ever confirm what the music already said — and there are thousands of them. Such a file is probed in two halves instead of one sweep: every jingle first, in order, and only then the pauses, and only where they can still be carrying something. That is any stretch of the file where the chapter numbering still has a hole, everything before the first chapter found, and everything after the last — so a prologue and an epilogue are still looked for exactly where they belong. The pauses between two chapters whose numbers already run consecutively are the ones that are skipped, and nothing else can be announced there: there is no number left for a chapter to carry, and neither a prologue nor an epilogue may sit there.
A file gets this shape by itself when it has at least one jingle per hour of
play time — unless one of your own --custom mappings may be
announced between two chapters, which is exactly what would then stop being
looked for. A mapping restricted to before-first-chapter or
after-last-chapter costs nothing; an untagged one, or one restricted to
after-first-chapter, keeps the file on the ordinary single sweep.
--jingle-first asks for the shape whatever the file looks like.
--verbose says which shape a file ran under, and the progress bar names the
half that is running: J-probe while the music is read, then S-probe, which
marks the stretches it has left to look at out on the bar (see
section 12). An ordinary file walks both
together and stays Probe throughout.
Reading the longest pauses first#
A book with no chapter music announces its chapters after its pauses — and it
has a hundred pauses that announce nothing for every one that does. Such a
file is skimmed once through before probing proper, taking its pauses longest
first, purely to find out roughly where its chapters are. SC-probe then
reads the file in order as probing always has, but passes over every pause
that lies between two chapters whose numbers already run consecutively:
nothing else can be announced there, for the same reason as above. Nothing
read during the skim is read a second time.
The skim stops by itself as soon as the pauses get too short to be this book's
chapter breaks, and on a file that announces nothing at all it gives up having
spent no more than --early-abort would have. It only decides
which pauses are worth reading; everything about how a chapter is recognised,
numbered and placed is still decided by the ordinary pass behind it, reading the
file in order.
A file gets this shape by itself unless it is already being read music-first, or
one of your own --custom mappings may be announced between two
chapters — the same exclusion, for the same reason. It is also skipped when you
give --min-silence-length a value of your own, that being you naming the pauses
worth probing. --verbose says so, and the progress bar shows the skim as
SD-probe.
Each transcript is matched against the chapter phrase (see --chapter-phrase),
and the chapter number is parsed from digits, Roman numerals or number words
(see section 7).
If the phrase is heard but nothing following it can be read as a number,
--verbose reports it and quotes what was transcribed there, and the spot is
read again: with --upgrade-model first if that names a better model than the
probing one, then from two differently framed windows — the wording a
recognizer produces at a given place depends on where the window around it
begins, so a second framing often reads cleanly. A number found that way is
believed only if it continues the chapter sequence, so a book's own mentions of
the word "chapter" cannot turn into a mark; the recovered chapter is marked
exactly where it was first heard. Only a stretch that yielded no chapter at all
is treated this way, so those mentions stay out of the log as well.
A window that yields nothing at all gets a second look when the VAD pre-pass
contradicts it — that is, when someone was heard speaking inside the jingle the
window covered and the transcript has no words for that spot. Whisper reads
audio in 30-second chunks, and a lone word inside a jingle can drop out of a
window that crosses one while being transcribed cleanly from a shorter window
over the same audio. The spot is therefore read once more from a window short
enough to stay inside a single chunk — through the model --upgrade-model names
where that is a better one than --model, since an announcement quiet enough to
be dropped is also one a larger model is likelier to recover — and --verbose
says so, naming the recognizer it used.
A number that is read but cannot plausibly belong where it was heard — one
that would leave more than three chapters missing in one go, or one below the
chapters already found — is not taken at face value either. It is read again:
with --upgrade-model first if that names a better model than the probing one,
then from two differently framed windows around the announcement. The new
reading is adopted only if it fits the sequence at that point, so a book that
genuinely skips numbers keeps its own numbering; where nothing sensible can be
read, the original number stands (and, if it was below the sequence, is skipped
as before). The mark itself never moves — only the number changes.
--verbose reports every attempt and its outcome.
Inside a gap search — a re-reading of the stretch between two chapters already found, looking for the ones missing between them — "fits the sequence" is much narrower, because both ends of the hole are known. Only the numbers actually missing from that stretch can be right there, so anything else is questioned and re-read as above, and a number at or beyond the chapter that closes the gap is refused outright rather than displacing it.
Mark placement supplies one more reading of the number, at no extra cost. Unless
--quick-marks is in force, pinning down where an announcement begins
(see below) means transcribing it several times over in short windows framed on
the announcement itself, and those windows read a spoken number more reliably
than the long one that found the chapter — the same audio can come back as
"chapter forty" from a 45-second window and "chapter fourteen" from every
window under seven seconds long. When those readings agree clearly with one
another, disagree with the number in hand, and offer one that fits the
sequence, the mark is recorded under theirs. --verbose reports the correction.
Where a chapter announcement is found, the mark is placed a fixed lead-in
before it — 0.35 seconds by default, --mark-lead — no matter what precedes
it: a silence, a jingle, or nothing at all. When a
jingle precedes the announcement, Whisper's own timestamp for it is not always
trusted outright: if the voice-activity pre-pass shows the announcement's own
opening syllable was brief enough to be folded into the jingle's non-speech
stretch, the mark is placed there instead — VAD's boundaries pinpoint it more
reliably than Whisper's own timing in that case. Failing that, if the
timestamp still comes back smeared to before the jingle even starts, the mark
is floored at the jingle's own end instead of landing early, back in the
previous chapter's narration.
One more layer sits on top of that by default, for the case where even this
still lands on the wrong spot — typically a
jingle whose own music briefly resembles speech closely enough to fool the
voice-activity detector, in either direction: short of the true announcement
or generously past it. Every mark placed by default-mode probing — including
the starting point --mark-before-jingle would otherwise walk backward
from — is double-checked against the audio itself, by transcribing short,
isolated clips of it: the stretch the chapter phrase was heard in is searched,
closing in on the announcement a few checks at a time rather than combing
through it, and the announcement's own beginning is then
measured to within a tenth of a second. Where a pause of at least half a second
runs up to the announcement, that measurement is replaced by a direct one: the
audio from the end of the pause onward is examined for the point where sound
actually resumes, and the mark is set --mark-lead seconds ahead of that.
Speech recognition is remarkably good at reading a word whose beginning has
been cut off, which makes it a poor judge of where the word began; the
waveform is not. The upshot is that a mark carries the full lead-in you asked
for rather than whatever was left of it. Books that play a jingle straight
into the announcement have no such pause and are marked as before.
Hearing the phrase at the mark is not by itself taken as proof that the
mark is right — a jingle is not transcribed at all, so a mark several seconds
inside one hears the announcement just as clearly as a mark sitting on it. A
mark that cannot be confirmed this way is searched for once more, in full, through
the model --upgrade-model names where that is a better one than --model — a
quietly-spoken announcement inside a jingle can be lost on the smaller model and
plain to the larger. Only when neither hears it is the mark left as originally
placed rather than guessed at. A corrected mark that would land in the middle of
speech is refused the same way, and keeps the position it had before the
correction: a mark belongs in a pause or in a chapter's music, and only a short
gap between the announcement and whatever was said just before it — a recording
that names its reader before each chapter, say — can lead the search into the
earlier words. Finally, whatever mark results —
confirmed, corrected, or left as is — is nudged up to 0.15 seconds earlier to
the quietest point in that stretch, but only when doing so is a clear (at
least 6 dB) improvement over the mark's own position; a mark is never moved
later. This keeps a player from starting playback abruptly mid-sound (an
audible "plop") without ever risking eating into the announcement itself.
This costs a handful of extra Whisper transcriptions per chapter on top of the
probe itself — a mark that already sits close to its announcement is the
quickest case, one left seconds away from it the slowest. --quick-marks/-Q
skips the whole layer when that time matters more than the last few tenths of a
second of accuracy (the machinery is documented in the source).
--mark-before-jingle anchors the mark to the end of the
previous chapter's actual narration instead, by walking backward from
whatever mark default mode (normally already refined as described above)
found: first out of any silence
the mark sits in, then — if no real speech is heard right there — back
through the jingle's own music, until real narration is found and the mark is
placed there; a mark with real narration already right before it is left
unchanged. Where two jingles play back to back — the previous chapter's outro
sting followed by this chapter's own, with an audible break between them —
the walk stops at that break, so the mark lands at the start of the second
jingle rather than in front of the first. When a jingle opens the file with
nothing spoken before it at all, the mark instead backs off by a small fixed
margin. In the rare case that the refinement above could not confirm the
announcement — so the walk started from an unverified position — the walked
result is itself re-transcribed afterward and corrected further back if the
announcement is still audible there. The result is then nudged earlier to a
nearby, clearly quieter point in the same way (see above) (the
machinery for all of this is documented in the source).
In-text mentions ("…as we learned in chapter three…") are rejected by requiring the
announcement to follow a real pause; out-of-order detections and duplicates of
an already-marked chapter are dropped, keeping the earliest position. Each
mark also carries Whisper's own confidence, and marks below 0.5 are flagged
for a spot-check rather than trusted silently (see
section 12). That figure is taken from the
short re-readings the mark refinement makes of the announcement itself — the
median of them — rather than from the wide window that first found it, whose
segment usually holds a jingle and several sentences of narration besides and
so says more about those than about the announcement.
By default (--min-silence-length auto), Probe does not probe every silence
from Analyze. As chapters are found it learns how long this book's real
inter-chapter breaks are and stops probing clearly shorter in-chapter pauses,
so far fewer Whisper probes are needed without a fixed guess; should a chapter
later turn up out of sequence, everything skipped since the previous chapter
is re-probed before Scan has to step in. Giving --min-silence-length an
explicit numeric value disables this and probes every silence at or above it.
Only chapters found at a pause teach it. One found at a jingle is left out: the pause in front of a jingle is the run-up to the music, not the break between two chapters, and it is routinely a different length — so learning from it would move the threshold away from the breaks that still have to be found. It also means a book whose chapters all open with a jingle never narrows its threshold at all, which costs nothing: those chapters are being found at the jingles, not at the pauses.
That measurement also runs the other way. When a book's own chapter breaks turn out shorter than the 1.5 seconds probing started at — a narrator whose pauses simply sit under the default — the figure settles below the starting point, as low as 0.8 seconds.
Where a chapter is missing, that shorter figure is acted on twice. A gap in the numbering re-reads its own stretch with the pauses down to it, so a chapter behind a pause the run was never willing to probe is often recovered on the spot and on the cheap model. And when Probe is done, the gaps still open are swept for those pauses once more — a tenth of a second at a time, longest first, each slice taking only the time it takes, so a gap dense with short pauses still gets the slice most likely to hold the chapter rather than being given up as too slow to attempt in one piece. The sweep stops as soon as the gap closes.
The sweep runs off the gap, not off the measurement. A book whose chapters
all open with music measures nothing at all (see above), and it is exactly such a
book — jingles on most chapters, a bare pause in front of the one that went
missing — that the sweep exists for. So a gap is reason enough on its own; where
nothing was measured, the pauses are swept down to the shortest length this run
would ever have believed in. Only gaps, and only within a budget, so a chapter
that would otherwise have cost a full Scan is usually recovered for a handful
of probes instead. Nothing else about Probe changes: the pauses it was willing
to probe in the first place are the same either way, and an explicit
--min-silence-length value is honoured to the second — nothing below it is ever
looked at. See the -n reference for the knob itself.
A chapter turning up out of sequence puts the whole stretch since the previous
chapter back in question, not just the candidates that were passed over — and
that second look is a re-reading rather than a wider search. Every pause and
every jingle between the two chapters becomes a candidate again — including the
ones the first look ruled out because a jingle was thought to cover them, and the
ones that were never candidates at all for being shorter than the run demanded —
and each is framed a little differently from the first time: the window opens later and stops
sooner, which is what makes the recognizer read the same audio afresh instead of
returning the answer it already gave. The retry stops as soon as the gap is
closed. When there is nothing to retry — no candidate at all sits between the two
chapters — --verbose says so, and the gap goes straight to Scan.
When Probe is done, its finds are reconciled into one ascending sequence, since
chapter numbers rise through a book. Where a mark's number contradicts the marks
around it, that mark gives way rather than the rest of the book — a single
mishearing can cost its own mark but never the chapters behind it. And before it
is given up, the surrounding chapters get a say in what it should have been:
between a chapter 13 and a chapter 15 there is exactly one number the mark can
carry, so it is simply renumbered; where the neighbours leave several
possibilities, the audio is read again and held to that range. This is why the
step waits until Probe has finished — the chapters that settle the question are
often found long after the misreading. It also runs before the tool works out
which chapters are missing, so the passes below never go hunting for a chapter
that was never missing. --verbose reports each repair.
Re-probe — a cheap second try at a gap (only with a heavier --upgrade-model)#
A gap is often not a chapter the probing missed, but a number the probe model
misheard while probing the right spot. So when — and only when —
--upgrade-model names a better model than Probe's, the gap's regions are
first re-probed exactly as probing does, but with that better model. When it
finds the missing chapters, Scan never has to run for them at all; anything it
does not find falls through to Scan immediately afterward. The re-probe stops
the moment the last of the gap's missing chapters turns up: whatever is left of
the gap behind it is a chapter's worth of audio with no announcement in it.
A gap that survives the re-probe gets one more, differently aimed attempt first.
The other reason an announcement goes unfound is that nothing ever looked at it:
--min-silence-length decides which pauses are worth probing, and a narrator
whose chapter break lands just under the setting has every chapter of the book
below it. So the gap is swept for the pauses just short of that setting — a tenth
of a second at a time, longest first, down to half a second under it — and the
sweep stops the moment the missing chapters are accounted for. Where the gap is
long enough that this would end up costing more than transcribing it outright,
the sweep is abandoned and Scan takes over. --verbose reports each band it
sweeps.
Whether Re-probe pays off depends on the gap: the re-probe's cost grows with the
number of candidate silences inside it, not with its length, so a region dense
in candidates can spend about as long probing as Scan would have spent
transcribing it outright — and then Scan still follows. Expect it to help most
where a gap is long but quiet. With an equal or lighter --upgrade-model (the
default is equal), this step does not run at all. Marks are placed exactly as in
Probe.
Scan — reading a gap in full (only when needed)#
If the detected chapter numbers have sequence gaps (…7, 9…), the regions
where the missing chapters must be hiding are transcribed completely, in
roughly 10-minute chunks. This catches announcements that were not preceded
by a long-enough silence. Marks found here are placed the same way as in
Probe — and that includes a prologue, an epilogue or a --custom mark, which
are looked for in everything this pass reads, under the same position rules
and limits that apply anywhere else. If a chunk still leaves an expected chapter unaccounted for, a
stored silence (or, when the VAD pre-pass ran, a VAD non-speech region)
inside it that the chunk's own transcript skipped over entirely gets a
second, closer look before the chapter is given up as missing — documented
in the source.
A first detected chapter numbered above 1 is, by default, trusted outright:
there is no way to tell a legitimate split-book start from a spot Probe
simply missed, so guessing "1" and searching for it is never attempted (the
intro chapter covers the leading audio either way — see below).
--expected-start-chapter opts a file into that search instead, down to a
specific expected number rather than a blind guess — see
Detection behaviour — with the same 10-second grace
period: a first chapter found within 10 seconds of the file start is still
taken as-is, not searched past.
A detected prologue settles that question by itself: a book's prologue
sits in the file that holds its beginning, so a file that has one is expected
to start at chapter 1, and anything missing below the first chapter found is
searched for exactly as --expected-start-chapter 1 would have it — and, if
it stays missing, reported as missing. Passing --expected-start-chapter
overrules the implication, which is what a split-book part carrying its own
prologue wants (-e 12).
A chapter missing after the last one found is the one case none of this can
notice: a gap is a hole in the number sequence, which needs a known chapter on
either side of it, and there is nothing above the last one to compare against.
The trailing scan closes it by transcribing that stretch anyway — from the last
chapter found through to the end of the file — and it runs by default, at the
price of doing so on every file, every run, whether or not anything is wrong.
--no-trailing-scan switches it off. --chapter-count is the informed
alternative: told how many numbered chapters the book has, the run knows which
numbers are still owed, hunts only those, and does nothing at all when none are
— so giving a count suppresses the blind scan entirely. See
Detection behaviour.
Re-scan — the shifted second reading#
A gap that survives being transcribed end to end is a different problem from a gap nothing ever looked at: every second of it was read, so what is left to explain is a misreading. The likeliest one by far is a matter of framing — Whisper decodes in 30-second windows, and an announcement landing right on a window border can drop out of the transcript altogether while the sentences on either side of it come through perfectly, leaving text that reads as though nothing were missing.
So each still-open gap — or, where Scan closed part of one, each remaining
piece of it — is read once more with every decode shifted by 15 seconds, half a
window, which puts whatever sat on a border as far from one as it can get.
This runs unless --upgrade-model names a lighter model than --model: that is
the one setting which unambiguously says the stragglers are not worth more time.
The blind trailing scan is the exception in the other direction — it is read once
and never twice, because it already runs on every file and reading audio nothing
suspects a second time would double that standing cost. A trailing hunt that does
know what it is after (--chapter-count) goes by the same rule the gaps do.
If a gap between detected chapters (or, with --expected-start-chapter,
before the first one) still remains after Scan, the chapters that were
found are still written, but a warning is printed and the file is
renamed to <name>.missing-marks-<n>-<n>-…<ext> — the tag listing the
still-missing chapter numbers, --delimited (e.g.
My Book.missing-marks-3-7.m4b). This flags the file for attention and
preserves the partial work instead of discarding it, rather than committing a
silently-complete-looking but partially-wrong chapter list.
More than ten missing chapters are not spelled out — the tag is just
<name>.missing-marks<ext>, since the full list would make for an unwieldy
(and possibly over-long) file name. Such a file is also not picked up
automatically by a later run: a gap that wide usually means detection went
off the rails somewhere, which is worth a look before handing the file back
to another automatic attempt. See
--max-chapter-number for the most
common cause.
A later run over a numbered tagged file picks it up automatically (unless
--force or --ignore-chapter-numbers is given): the chapters already
committed are trusted outright,
and only the still-tagged gap(s) get their own Probe and, if needed, Scan,
exactly as after a failed --verify (see
--verify). If that completes the
sequence, the file is renamed back to its original name; if a gap is still
unresolved, it is re-tagged with the (possibly shorter) remaining list.
--force bypasses this and redoes the file from scratch instead, discarding
every existing mark including the partial ones.
An unnumbered tagged file is never picked up automatically, so redoing it means
--force (or --verify, or a --max-chapters low enough to condemn its
partial marks). Whichever way it happens, any run that ends with a
complete chapter sequence takes the tag off again and gives the file its own
name back — the tag records work still to be done, and there is none left.
With --debug, the log written beside the file follows it to that name,
replacing any log already sitting there from the run that left the tag.
--no-rename withholds the tag entirely, for a library whose file names are
not this tool's to change — a media server that keys its database off the path,
a seeded or hard-linked file, somebody else's naming scheme. The marks that were
found are still written, the warning is still printed and --summary still
lists the file as incomplete; only the name is left alone. What it costs is the
automatic resume above: with nothing on the name to say which chapters are
missing, the next run over that folder sees a file that already carries marks
and skips it, so finishing it takes --force. A tag an earlier run left behind
is still taken off once the file is complete — that gives the file its own name
back rather than imposing a new one, and it is what keeps a completed file from
being sent down the resume path by every later run. --no-rename cannot be
combined with --cleanup, --revert or --no-op, none of which detect
anything, and it cannot be set per folder.
Prologue and epilogue#
Alongside the numbered chapters, every run also listens for a prologue and an
epilogue announcement (default phrases /prolog/ / /epilog/, localized by
--lang) and gives each its own mark, titled --prologue-title /
--epilogue-title rather than "Chapter n".
Neither takes part in the chapter number sequence: a prologue between the
intro and chapter 1 does not make chapter 1 look like chapter 2, and no gap
hunt, --verify check or ".missing-marks" tag ever concerns itself with
them. At most one of each is written per file.
Because "prologue" and "epilogue" are ordinary words that also occur in ordinary prose — and sometimes inside longer words, Italian "riepilogo" containing "epilogo" — each is only accepted where it can plausibly be an announcement. Three things have to hold: the prologue is only looked for before the first chapter has been found and the epilogue only after at least one has; the match must be preceded by a real pause — roughly a second of silence or jingle — since a heading is spoken at a section boundary and never mid-sentence; and within that window the last occurrence wins — front matter frequently lists what is coming ("read by …, contains a prologue") before the narrator actually announces it.
Both are looked for in every stretch a run reads, not only in the sampling pass: where a gap or the file's tail is transcribed in full (see Scan), that transcript is read for these announcements too. It costs no extra time — the audio is being read anyway — and it matters most at the end of a book, which is both where an epilogue belongs and a stretch a run often reads in full while looking for one more chapter. An announcement already marked is not marked twice.
The epilogue is held to one more rule, checked once at the very end of the
file: it has to follow the book's last chapter. Nothing else can be an
epilogue — a match between two chapters is the word turning up in prose, or an
inner part of an omnibus ending, and either way the mark would be wrong. Such a
mark is dropped, and --verbose says so. If your books really do have a section
there and you want it marked, that is what --custom is for: a mapping like
--custom "/epilog/:Zwischenspiel" claims exactly the same announcements and is
bound by no position at all. A mapping of yours that matches the same words as
the built-in phrase also inherits a dropped epilogue mark, so the mark stays
where it was under your own title.
Nothing is required of what follows the announcement: narrators routinely read straight on from "Epilogue" into the epilogue's first sentence.
What may follow it is a second line of the same heading — a year, a date, a
place — and where that line is a number, it can look exactly like a chapter
announcement. A chapter mark landing within a few seconds of a prologue,
epilogue or --custom mark, and carrying a number that fits nowhere in the
book's sequence, is therefore taken as part of that same heading and dropped. A
real chapter that begins right after a short prologue keeps its mark, since its
number continues the sequence, and a book's first chapter is never dropped this
way.
Both are switched off by passing an empty phrase, e.g.
--prologue-phrase "" --epilogue-phrase "".
Custom marks#
--custom adds phrases of your own, each with the title its mark is written
under:
abchapterize --custom "zwischenspiel:Zwischenspiel;/zeit[- ]?tafel/:Zeittafel" book.m4b
A phrase is a plain word or a /regexp/, exactly as for --chapter-phrase,
and no number is parsed or expected. Unlike the prologue and epilogue, a
custom phrase is accepted at any point in the file and as often as it
occurs — a book with an interlude between every chapter gets a mark for each
of them — and it is exempt from the surrounding-pause requirement they are
held to. A custom mapping names whatever recurring element you say it does,
wherever you say it is.
What it is not is a full-text search: a custom phrase has to be announced,
and is held to exactly the same standard as a chapter phrase for deciding
whether it was — it has to turn up inside one of the windows probing actually
looks at, and those are anchored on the file's own pauses and jingles. A
narrator mentioning a timeline in the middle of a paragraph gets no mark; the
narrator announcing "Zeittafel" at a section boundary does. Titles may pull text
out of the phrase's own capturing groups — ${name}, ${number},
$roman{number} and the rest of it are in
Titles.
Syntax notes:
- Mappings are separated by
;, phrase and title by:. - Only the first
:separates, so a title may contain further ones ("time:Time: an interlude"). A/regexp/phrase instead ends at its closing slash, so a colon inside it is just a colon. - Write
\;for a semicolon inside a regexp. --custommay be repeated; every use adds to the list.--custom-file <path>reads mappings from a text file, one per line, with blank lines and#comment lines ignored. Semicolons need no escaping there, since line breaks separate the mappings.- Custom phrases are never localized by
--lang— they are taken exactly as written.
At most 100 custom marks are written per file. Beyond that the rest are
dropped and the file's summary line says so: a phrase that matches ordinary
prose (--custom "the:the") would otherwise pepper a whole book with marks.
Hints: telling a mapping what kind of thing it names#
By default a --custom mapping is as unrestricted as it can be: it applies to
every file, matches anywhere in it, and produces a mark for every occurrence.
That is the right default for the "Zwischenspiel" case it was built for, and
the wrong one for a mapping naming something a book has exactly once, or only
at one end of itself.
The [...] tag that already carried a language code takes a comma-separated
list, and any of these hints may sit in it alongside the code:
| Hint | Short form | What it does |
|---|---|---|
before-first-chapter |
before-first |
Matches only before the first chapter is found. |
after-first-chapter |
after-first |
Matches only once a chapter has been found. |
after-last-chapter |
after-last |
Only a match after the book's last chapter is kept. |
once |
At most one mark for this mapping per file. | |
max=<n> |
At most <n> marks for this mapping per file. |
--custom "[de,before-first-chapter,once]/vorwort/:Vorwort"
--custom "[after-last-chapter,once]/^nachwort/:Nachwort"
--custom "[max=3]/zwischenspiel/:Zwischenspiel"
To require a real pause in front of a match, write ^ at the start of the
phrase, as the second example does. There is no hint for it, deliberately:
^ already says exactly this — see "^ and $ — asking for the pauses" under
The phrase syntax — and one demand with two spellings is one spelling too many.
Nothing here is new machinery. The built-in prologue is
[before-first-chapter,once] with a ^, and the built-in epilogue is
[after-last-chapter,once] with one; what the hints do is let a mapping ask for
the same treatment. A mapping without a tag, or with a tag naming only a
language, keeps exactly the behaviour it had before hints existed.
Points worth knowing:
oncekeeps the last match, not the first. Front matter routinely mentions what is coming ("…gelesen von…; Vorwort") before the narrator actually announces it, so the later of two matches inside the scope is the real one. It follows thatonceon its own can never end a search early — only a scope that closes can.max=<n>works the other way round, keeping the first<n>and dropping the rest, which is whymax=1is rejected with an error pointing atoncerather than quietly meaning something else.- A leading
^is the check the prologue and epilogue always get: the match must be set off from what precedes it — see "^and$" for the three ways it can be — which is what tells a heading read aloud from the same word buried in a sentence.--customdoes not get it by default, because a mapping names whatever recurring element the user says it does, at whatever position — write the^when you want it. after-last-chapteris applied at the end of the run, not while probing. Which chapter is the last one is unknown until every pass has finished, so a match mid-book is heard, marked and then dropped — it buys precision, not time. The other two positions are free, being filters applied before a mark is ever placed.- A match dropped for being out of scope is noted once per mapping under
--verbose, and not per occurrence: an "epilogue" in the middle of a book is an ordinary word, and one line per match would drown the log. - A bracket run only counts as a tag when something in it is recognized.
Whisper writes bracketed non-speech tags into its transcripts —
[Musik],[Abspann],[BLANK_AUDIO]— so--custom "[Musik]:Zwischenmusik"is a plausible mapping and goes on matching those words. A typo beside a good keyword ([once,headnig]) is an error, since one token was recognized. The only residual is a phrase that is itself exactly a bracketed keyword. - The same tag on
--chapter-phrase,--chapter-titleand the other localized options names a language and nothing else; a hint there is an error rather than silently ignored.
Named marks that land beside a chapter#
A named mark — prologue, epilogue or --custom — sitting within
--named-mark-distance seconds of a chapter mark (10 by default) is not written
as an entry of its own. The chapter keeps its position, and the named mark
contributes its title in brackets:
0:00:00.000 Intro
2:14:07.500 Chapter 10 (Interlude)
Two entries a few seconds apart are worse than one: scrubbing to a chapter lands the listener either in the tail of the previous section or a little way into the new one, depending on which of the two they hit, and nobody asked for that choice. Nothing is lost — the title survives — and the chapter wins the position, being the mark people navigate by. Several named marks crowding one chapter are appended in file order, separated by commas.
This is also what settles a chapter announcement and a named phrase spoken in the same breath ("Chapter ten. Interlude."), which are found by two separate searches and can only be compared once both have their final positions.
--named-mark-distance 0 switches the whole thing off and writes every mark
separately, however close together they fall.
Detecting chapters without believing their numbers#
--ignore-chapter-numbers leaves detection working exactly as it normally
does — the chapter phrase is still searched for, every announcement still
becomes a mark, and the marks are still placed with the same silence, jingle
and refinement machinery — but the tool stops forming any opinion about the
numbers it hears.
Whatever number was spoken still ends up in the title (Chapter 7), and an
announcement with no number at all is marked too, titled with the bare word
(Chapter). Nothing checks that the numbers ascend, that none is missing, or
that the book starts at 1. Consequently no sequence gap is ever found or
filled, so Re-probe,
Scan and
Re-scan never run and no file is
ever tagged .missing-marks. A run finishes after Probe, which usually makes
it a good deal quicker than a normal one.
Use it for books whose numbering the tool cannot make sense of: one made of several novels bound together, one that announces "Chapter" and then simply reads on, or one whose parts restart their count in a way the automatic handling below cannot follow.
An ordinary run will usually tell you when a book wants this. Announcements numbered below the sequence are heard and understood, and then dropped for repeating numbers already used; when enough of them go that way without adding up to a new part, the file's summary line says how many were skipped and suggests this option.
The prologue and epilogue keep their usual positional rules — the prologue
before the first chapter heard, the epilogue after it — and --custom marks
behave as always. The per-file limit of 100 custom marks does not apply to
chapter announcements.
The options that reason in chapter numbers are rejected rather than silently
ignored: --upgrade-model, --expected-start-chapter, --max-chapter-number,
--chapter-count and --verify. --chapter-phrase and --chapter-title remain
perfectly useful and are accepted.
A file another run already tagged .missing-marks-… is not picked up either:
the tag is a statement about chapter numbers, which this run forms no opinion
about, so such a file is treated like any other one already carrying marks and
skipped unless --force asks for a detection from scratch. The blind scan after
the last chapter does not run here either — it lives in Scan, and Scan does
not run at all.
Books that count from one again in every part#
Some books are divided into parts, and each part starts its chapters over at one. ABChapterize follows that by itself: when it hears three consecutive chapters that sit below the numbering it has been building — "one", "two", "three" again after the last chapter of the part before — it accepts that a new part has begun and marks everything from there under the new count. Nothing is decided on less evidence than that, because a single announcement below the sequence is far more likely to be prose mentioning an earlier chapter ("as I said in chapter three") than the start of a part; those are still passed over, as they always were.
The numbering being built up is made of numbers the run could corroborate. One it could not — a misheard number it re-read and still could not place — keeps its mark but does not raise the count, so the ordinary chapters after it are not mistaken for a part starting over.
What changes in the output is the titles. Every chapter of such a file carries its part, including the first part's:
Intro
Part 1 - Chapter 1
…
Part 1 - Chapter 15
Part 2 - Chapter 1
…
The word is localized by --lang and can be set with --part-title. A file
with a single chapter sequence — virtually every book — is titled exactly as
before, with no part prefix anywhere.
Everything else follows the parts too. Each part's numbering is checked, gap-
hunted and reported on its own, so a chapter missing from part two is looked
for between part two's own chapters and never confused with the part-one
chapter of the same number; the boundary itself is not treated as a gap; and
--chapter-count, if given, describes the last part. The file's summary line
names the parts and the range each one covers. If a part is found to start
above one, its missing opening chapters are searched for like any other gap —
no --expected-start-chapter is needed for that, since counting from one is
what identified the part in the first place.
Two things are worth knowing. Marks written for such a file can be read back:
--verify and an interrupted run's auto-resume both understand the part prefix,
so a file this tool marked is picked up correctly. And if a book divides itself
in a way this cannot follow — parts of one or two chapters, say, or a first
part whose opening chapters were all missed — the fallback is
--ignore-chapter-numbers,
which marks every announcement it hears and never consults a number.
The intro chapter#
Audiobooks usually do not start with chapter one — there is a title announcement, credits, a prologue. Many players (and the MP4 muxer itself) force the first chapter mark to 0:00, which would move "Chapter 1" to the very beginning and misplace it.
Therefore, when the first detected mark (chapter or prologue) starts later
than 0:00, a synthetic intro chapter (default title: "Intro", localized by
--lang; customizable with --intro-title) is prepended at 0:00, and the
first real mark keeps its exact detected position — unless nothing precedes
that first announcement but silence, music or a jingle: with no actual
spoken prelude to give its own entry, no intro chapter is inserted, and the
muxer's own start-snapping folds that lead-in into the first real mark
instead, however many minutes long it runs.