Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots 📖

fix(voice): make blocklist entries reachable after normalisation

Luis Ortiz660014cec6ab
diff --git a/src/core/capture/voice/__tests__/filter.test.ts b/src/core/capture/voice/__tests__/filter.test.ts
index c90d734..f4dfde9 100644
--- a/src/core/capture/voice/__tests__/filter.test.ts
+++ b/src/core/capture/voice/__tests__/filter.test.ts
@@ -48,4 +48,20 @@ describe('rejectReason', () => {
it('keeps a filler word appearing inside a real sentence', () => {
expect(rejectReason(scored('You should click save.'))).toBeNull();
});
+
+ it('rejects a blocklisted phrase containing an apostrophe', () => {
+ expect(rejectReason(scored("Don't forget to subscribe"))).toContain('blocklist');
+ });
+
+ it('rejects a blocklisted phrase containing a hyphen and accents', () => {
+ expect(rejectReason(scored("Sous-titres réalisés par la communauté d'Amara.org"))).toContain('blocklist');
+ });
+
+ it('rejects a filler word terminated by an ellipsis', () => {
+ expect(rejectReason(scored('Hmm...'))).toContain('solo-filler');
+ });
+
+ it('rejects a bracketed sound marker', () => {
+ expect(rejectReason(scored('[Music]'))).toContain('blocklist');
+ });
});
diff --git a/src/core/capture/voice/filter.ts b/src/core/capture/voice/filter.ts
index 2296744..6dca24b 100644
--- a/src/core/capture/voice/filter.ts
+++ b/src/core/capture/voice/filter.ts
@@ -1,37 +1,39 @@
import type { ScoredTranscriptSegment, TranscriptSegment } from './types';
-export const BLOCKLIST = new Set([
- 'thank you',
- 'thanks for watching',
- 'thank you for watching',
- 'thanks for listening',
- 'please subscribe',
- "don't forget to subscribe",
- 'like and subscribe',
- 'subtitles by the amara.org community',
- 'transcription by castingwords',
- 'amara.org',
- '[music]',
- '[applause]',
- 'music',
- 'applause',
- 'продолжение следует',
- 'субтитры сделал dimatorzok',
- "sous-titres réalisés par la communauté d'amara.org",
- '由 amara.org 社群提供的字幕',
-]);
-
-export const SOLO_ONLY = new Set(['you', 'so', 'the', 'oh', 'okay', 'ok', 'yeah', 'hmm']);
-
export function normalise(text: string): string {
return text
.toLowerCase()
.replace(/[^\p{L}\p{N}\s.]/gu, '')
.replace(/\s+/g, ' ')
.trim()
- .replace(/\.$/, '');
+ .replace(/\.+$/, '');
}
+export const BLOCKLIST = new Set(
+ [
+ 'thank you',
+ 'thanks for watching',
+ 'thank you for watching',
+ 'thanks for listening',
+ 'please subscribe',
+ "don't forget to subscribe",
+ 'like and subscribe',
+ 'subtitles by the amara.org community',
+ 'transcription by castingwords',
+ 'amara.org',
+ '[music]',
+ '[applause]',
+ 'music',
+ 'applause',
+ 'продолжение следует',
+ 'субтитры сделал dimatorzok',
+ "sous-titres réalisés par la communauté d'amara.org",
+ '由 amara.org 社群提供的字幕',
+ ].map(normalise),
+);
+
+export const SOLO_ONLY = new Set(['you', 'so', 'the', 'oh', 'okay', 'ok', 'yeah', 'hmm']);
+
export function isScored(segment: TranscriptSegment): segment is ScoredTranscriptSegment {
return (
typeof segment.no_speech_prob === 'number' &&