Skip to content

Add subtitle statistics and reading-speed warnings #34

@laubonghaudoi

Description

@laubonghaudoi

Summary

Add local statistics and reading-speed warnings so users can quickly see whether subtitles are readable. This closes a practical gap with desktop tools while staying lightweight and browser-only.

Why this is in scope

The app already computes duration, word count, and character count in the subtitle list. This issue turns that into useful subtitling feedback: CPS, WPM, line length, repeated lines, and track-level summary stats.

Implementation plan

  1. Add a pure metrics module.

    • Create lib/subtitle-metrics.ts.
    • Compute per-cue metrics: duration, word count, character count, characters per second, words per minute, line count, max line length, gap before, gap after.
    • Compute track-level metrics: total cues, total words, total characters, total subtitle display time, average duration, max CPS, max WPM, most repeated lines.
  2. Define warning thresholds.

    • Use conservative defaults: max CPS 20, max WPM 180, max line length 42, max lines 2, min duration 1.0s, max duration 7.0s.
    • Keep thresholds in one exported config object so the QA tool can reuse them.
    • Avoid language-specific presets in the first version.
  3. Add inline cue warnings.

    • Extend the optional stats column or add compact warning badges on subtitle rows.
    • Keep the default UI quiet: warnings should be visible but not dominate editing.
    • Tooltip or popover should explain the reason, e.g. 24 CPS exceeds 20 CPS.
  4. Add a statistics dialog.

    • Add a header action, likely near Settings / Find Replace / Bulk Offset.
    • Show track summary, worst offenders, repeated lines, and most frequent words.
    • Provide a simple Download report action as plain text or CSV if straightforward.
  5. Keep it integrated with future QA work.

    • Reuse lib/subtitle-metrics.ts from the QA rules engine.
    • Do not duplicate duration/word/char logic inside React components.
  6. Tests.

    • Add tests/subtitle-metrics.test.ts.
    • Cover CPS/WPM math, line splitting, repeated lines, empty text, and zero-duration safety.

Acceptance criteria

  • Users can inspect track-level statistics without leaving the editor.
  • Cue rows can show reading-speed/line-length warnings when enabled.
  • Metrics are computed by pure utility functions with unit tests.
  • No backend, account, or media-processing dependency is introduced.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions