Repository navigation
feat(tools): make the "Remove silences" threshold user-adjustable - #114
Open
bluzername wants to merge 1 commit into
Open
bluzername wants to merge 1 commit into
bluzername wants to merge 1 commit into
Conversation
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>
|
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
For #97 (the "custom silence removal" part).
The gap length that count as removable silence was a hardcoded
MIN_SILENCE_DURATION = 0.3inlib/silences.ts.findSilenceRanges()already take aminDurationparameter, 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 pureclampSilenceThreshold()(range 0.1s–2s, the floor the issue ask for) plus a thinlocalStorageload/save wrapper, same split aslib/theme.tsso the clamping is unit-testable without mockingwindow.hooks/useSilenceThreshold.ts(new): wires it to React state, same shape asuseAppearance/useTelemetryPref.components/TranscriptToolsMenu.tsx: read the user's threshold instead of the constant for bothfindSilenceRanges()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.tsis new: it checkclampSilenceThreshold()keeps in-range values, clamps below/at/above the floor and ceiling, and falls back to the default (not the floor) forNaN/ non-finite input. Beforelib/silenceThreshold.tsexisted this failed with "Cannot find module"; after, it passes.tests/silences-test.tsgets one more case proving a custom threshold reachesfindSilenceRanges()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.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:timelineare unaffected by this change but I rantest:timelineanyway as a smoke check and it also pass.Checklist