Automated Video Processing Pipeline: Filler Word Removal, Silence Trimming, and Subtitle Repair

    This article presents a practical, five-stage pipeline for turning raw ASR subtitles into deliverable video content. It covers adaptive silence detection with minimum-duration and padding constraints, a three-layer approach to fixing split technical terms (protected lexicon, context-based correction, and new-word discovery), careful filler word cleanup driven by whitelists and context rules, and subtitle reconstruction with timeline remapping and alignment checks. All thresholds are kept as external configuration, and a dry-run mode is recommended before any irreversible rendering. The goal is a pipeline that is orchestrable, rollback-friendly, and measurable.

    1. Problem Background and Goals

    Subtitles generated by automatic speech recognition (ASR) are often “usable but not deliverable” in real content production workflows. Three defects stand out: technical terms are split incorrectly (for example, a technical noun broken into two ordinary words), spoken filler words remain in large numbers, and long stretches of silence are left untrimmed, making the pacing sluggish. These three problems are coupled: term errors break sentence segmentation, filler words pollute silence detection, and silence cuts shift the entire subtitle timeline.

    The more reliable engineering approach is therefore not to patch each issue in isolation, but to build a pipeline that is orchestrable, rollback-friendly, and measurable. The goals can be quantified in four ways:

    • Term accuracy: zero segmentation errors for entries in a protected lexicon;
    • Redundancy rate: the proportion of filler words drops below an acceptable threshold;
    • Pacing: no single silence segment exceeds a configured limit, and speech segments are not damaged;
    • Consistency: the subtitle timeline stays strictly aligned with the final audio/video, with error kept within tens of milliseconds.

    It is worth stressing that all thresholds should be externalized as configuration rather than hard-coded in scripts. Only then can the same workflow be reused across different material types (tutorials, interviews, courses).

    2. Overall Pipeline Design

    The recommended design splits the workflow into five stages, where the output of each stage becomes the input of the next, and all intermediate artifacts are written to disk so failed runs can be restarted:

    1. Preprocessing: normalize sample rate and channels, and extract the audio energy envelope;
    2. Silence detection and trimming: produce a list of segments to keep;
    3. Term correction: repair segmentation in the recognized text;
    4. Filler word cleanup: remove redundant elements based on part-of-speech and context rules;
    5. Subtitle reconstruction: recompute the timeline based on kept segments, re-segment lines, and output.

    The key design principle is trim first, then rebuild the timeline, and trimming decisions should depend only on audio features, not on text, so that text errors cannot feed back into editing decisions.

    3. Silence Trimming: From Thresholds to Constraints

    Judging silence with a fixed energy threshold alone produces many false positives when there is background noise, background music, or breathing sounds. A more robust approach uses three layers of judgment:

    • Adaptive threshold: use a quantile of the whole audio’s energy (such as a lower quantile) as the noise baseline instead of a hand-tuned constant;
    • Minimum duration constraint: silences shorter than the lower bound are not cut, avoiding rapid subtitle flickering;
    • Boundary padding: keep a small buffer before and after each speech segment to avoid clipping consonant tails.

    Illustrative logic:

    1. def keep_ranges(env, hop, noise_base, ratio=1.5,
    2. min_sil=0.35, pad=0.08):
    3. thr = noise_base * ratio
    4. sil = env < thr
    5. ranges, i, n = [], 0, len(sil)
    6. while i < n:
    7. if sil[i]:
    8. j = i
    9. while j < n and sil[j]:
    10. j += 1
    11. if (j - i) * hop >= min_sil:
    12. ranges.append((i, j)) # segments to cut
    13. i = j
    14. else:
    15. i += 1
    16. # Derive keep ranges from cut segments, with boundary padding
    17. keep, cur = [], 0
    18. for s, e in ranges:
    19. keep.append((cur, max(cur, s - pad)))
    20. cur = min(n, e + pad)
    21. keep.append((cur, n))
    22. return [(s * hop, e * hop) for s, e in keep if e > s]

    In practice, it is advisable to keep a “mark only, do not cut” dry-run mode that first outputs an editing decision list for manual spot checks. Only after confirmation should actual rendering run, which significantly reduces irreversible loss.

    4. Automated Repair of Term Segmentation Errors

    The root cause of split technical terms is that the language model assigns low probability to rare combinations. There are three feasible layers of automation, ordered from low to high cost:

    The first layer is a protected lexicon. Maintain a term list containing standard spellings and common erroneous variants, and perform longest-match replacement during the correction stage. The lexicon should support case-insensitive matching and word-boundary constraints to avoid damaging ordinary words.

    1. LEXICON = {"deepseek": "DeepSeek", "forkjoinpool": "ForkJoinPool"}
    2. def protect(text, lexicon=LEXICON):
    3. for bad, good in lexicon.items():
    4. text = re.sub(rf"\b{bad}\b", good, text, flags=re.I)
    5. return text

    The second layer is context-based correction. Use the surrounding words as context to score candidate segmentations and pick the one with the better overall probability. This layer can handle new terms not covered by the lexicon, but inference cost must be controlled, so it is usually triggered only for sentences containing suspicious fragments.

    The third layer is new word discovery and lexicon feedback. Run high-frequency fragment statistics over the corpus, turn repeatedly occurring but unregistered combinations into candidates, and write them back into the lexicon after manual confirmation, forming a closed loop. The lexicon thus becomes a continuously accumulated asset rather than a one-off configuration.

    5. Exercising Restraint in Filler Word Cleanup

    Removing filler words carries higher risk than silence trimming, because it directly changes meaning and the speaker’s style. The recommendation is a “whitelist + context conditions” approach rather than crude regular expressions:

    • Remove only high-frequency, low-information filler elements;
    • Prioritize redundant elements at the beginning and end of sentences, and keep those in the middle;
    • Do not remove elements in questions or emphatic sentences, to avoid distorting tone;
    • After removal, run a readability regression to avoid leaving fragments without a predicate.

    A cleanup log should also be output, recording the position and rationale of each removal for traceability and manual review.

    6. Subtitle Reconstruction and Alignment

    After trimming, subtitles must be recomputed against the new time base. Key points include: build a mapping function from old time to new time for each kept segment; split or merge subtitle entries that cross a cut point; ensure the length and display duration of each subtitle stay within a comfortable reading range; and finally unify encoding and line-break conventions to avoid parsing issues in some players.

    Alignment verification should be automated: sample several known speech start points and compare the offset of subtitle start times; measure the proportion of overly long and overly short entries as a quality gate.

    7. Implementation Recommendations

    For batch processing, containerize each stage, drive task distribution with a message queue, store intermediate artifacts in object storage, and connect logs and metrics to logging services and monitoring/alerting to form an observable pipeline; on Baidu AI Cloud, such general capabilities can be composed on demand without binding to a specific implementation. The recommended rollout order is: first enable silence trimming and subtitle reconstruction (high benefit, low risk), then gradually turn on term correction and filler word cleanup, using the spot-check pass rate at each step as the basis for scaling up.