Skip to content

feat(tools): make the "Remove silences" threshold user-adjustable - #114

Open
bluzername wants to merge 1 commit into
wassgha:mainfrom
bluzername:feat/silence-threshold
Open

bluzername wants to merge 1 commit into
wassgha:mainfrom
bluzername:feat/silence-threshold

Conversation

@bluzername

Copy link
Copy Markdown

What

For #97 (the "custom silence removal" part).

The gap length that count as removable silence was a hardcoded MIN_SILENCE_DURATION = 0.3 in lib/silences.ts. findSilenceRanges() already take a minDuration parameter, it was just never reached from the UI, so there was no way for a user to ask for e.g. "cut anything over 0.1s" the way the issue want.

  • lib/silenceThreshold.ts (new): a pure clampSilenceThreshold() (range 0.1s–2s, the floor the issue ask for) plus a thin localStorage load/save wrapper, same split as lib/theme.ts so the clamping is unit-testable without mocking window.
  • hooks/useSilenceThreshold.ts (new): wires it to React state, same shape as useAppearance / useTelemetryPref.
  • components/TranscriptToolsMenu.tsx: read the user's threshold instead of the constant for both findSilenceRanges() and the tool's tooltip text.
  • components/SettingsMenu.tsx: a small range input for it, under the language picker, with the current value shown live ("1.2s").

Why

This is a real ask in the issue, and the underlying function already support it, so wiring a setting through is a small, low-risk change — no new cutting logic, just exposing what is already parameterized.

Tests

tests/silence-threshold-test.ts is new: it check clampSilenceThreshold() keeps in-range values, clamps below/at/above the floor and ceiling, and falls back to the default (not the floor) for NaN / non-finite input. Before lib/silenceThreshold.ts existed this failed with "Cannot find module"; after, it passes.

tests/silences-test.ts gets one more case proving a custom threshold reaches findSilenceRanges() end to end: the same 1.0s gap is included at the default 0.3s threshold and excluded once the threshold is raised to 1.5s.

npx tsx tests/silence-threshold-test.ts   # ALL SILENCE THRESHOLD TESTS PASSED
npx tsx tests/silences-test.ts            # ALL SILENCE TESTS PASSED (incl. new case)
npm run test:i18n                          # ALL I18N TESTS PASSED (new keys in all 9 locales)
npx next typegen && npx tsc --noEmit       # clean
npm run typecheck:electron                 # clean
npm run lint                                # clean
npm run build                                # compiles, prerenders

Also manually exercised in the running dev app (screenshots on request): the slider updates the Tools menu's live count/tooltip immediately, clamps at 2.0s, and the value survive a page reload.

Not run: test:ffmpeg / test:timeline are unaffected by this change but I ran test:timeline anyway as a smoke check and it also pass.

Checklist

For wassgha#97.

The gap length that counts as a removable silence was a hardcoded
0.3s (MIN_SILENCE_DURATION). findSilenceRanges() already took it as a
parameter, it was just never reached from the UI, so short-form
creators could not ask for e.g. "cut anything over 0.1s" like the
issue want.

Add lib/silenceThreshold.ts: a clamp/load/save module for the
preference (range 0.1s to 2s, same floor the issue ask for), kept as
a pure clampSilenceThreshold() function plus a thin localStorage
wrapper, same split as the existing theme/telemetry prefs so the
clamping logic is unit-testable without mocking window. A
hooks/useSilenceThreshold.ts hook wires it to React state, and
TranscriptToolsMenu now read the user's threshold instead of the
constant when it compute silenceRanges and when it format the tool's
tooltip. SettingsMenu gets a small range input for it, under the
language picker.

Tests: tests/silence-threshold-test.ts is new (RED before
lib/silenceThreshold.ts existed: "Cannot find module"; GREEN after)
and check the clamp behavior including the NaN/Infinity fallback.
tests/silences-test.ts gets one more case proving a custom threshold
actually reach findSilenceRanges() end to end (same gap, included at
the default, excluded once the threshold is raised past it).

New settings.silenceThreshold / settings.silenceThresholdHelp keys
are translated in all nine existing UI locales (not just English),
matching this repo's i18n completeness check in tests/i18n-test.ts,
which still pass.

Also manually verified in the running dev app: the slider updates the
tool's live count and tooltip, and the value survives a reload.

Signed-off-by: bluzername <bluzerasi@gmail.com>

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 12, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the wassgha's projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant