fix(file-transcription): stop a Whisper repetition loop from spreading to every following chunk
Each 30-second chunk received the previous chunk's text as initial_prompt, so once one chunk looped on a word the loop became the next chunk's hint and the rest of the file was the same word. A looping chunk is now re-transcribed without the hint, looped text is never carried forward, and runs of 4+ identical phrases or segments are collapsed to one.
This commit is contained in:
parent
a14bb52b7f
commit
45d8b1ddb1
4 changed files with 236 additions and 6 deletions
|
|
@ -0,0 +1,47 @@
|
|||
// Whisper 반복 루프 정리 — 파일 전사에서 같은 단어만 되풀이되던 버그
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
collapseRepeatedSegments,
|
||||
collapseRepeats,
|
||||
isDegenerateTranscript,
|
||||
} from '../../../../src/main/services/file-transcription/repetition'
|
||||
|
||||
describe('collapseRepeats', () => {
|
||||
it('4번 이상 이어진 같은 단어·구절을 한 번으로 줄인다', () => {
|
||||
expect(collapseRepeats('회의를 시작합니다. 감사합니다 감사합니다 감사합니다 감사합니다 감사합니다')).toBe(
|
||||
'회의를 시작합니다. 감사합니다',
|
||||
)
|
||||
expect(collapseRepeats('그래서 우리는 그래서 우리는 그래서 우리는 그래서 우리는 다음 주에')).toBe('그래서 우리는 다음 주에')
|
||||
expect(collapseRepeats('네.네.네.네.네.네.')).toBe('네.')
|
||||
})
|
||||
|
||||
it('실제 말에 나올 만한 짧은 반복(3번 이하)은 남긴다', () => {
|
||||
expect(collapseRepeats('네 네 네 알겠습니다')).toBe('네 네 네 알겠습니다')
|
||||
expect(collapseRepeats('정말 정말 좋았어요')).toBe('정말 정말 좋았어요')
|
||||
})
|
||||
})
|
||||
|
||||
describe('isDegenerateTranscript', () => {
|
||||
it('반복이 대부분이면 망가진 결과로 본다', () => {
|
||||
expect(isDegenerateTranscript(Array(20).fill('자막 제공').join(' '))).toBe(true)
|
||||
expect(isDegenerateTranscript('오늘 안건은 예산과 일정입니다. 먼저 예산부터 보겠습니다.')).toBe(false)
|
||||
expect(isDegenerateTranscript('')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('collapseRepeatedSegments', () => {
|
||||
it('같은 문장의 연속 구간을 하나로 합치고 끝 시각을 늘린다', () => {
|
||||
const segments = [
|
||||
{ text: '시작하겠습니다', start: 0, end: 2 },
|
||||
{ text: '감사합니다', start: 2, end: 4 },
|
||||
{ text: '감사합니다.', start: 4, end: 6 },
|
||||
{ text: '감사합니다', start: 6, end: 8 },
|
||||
{ text: '다음 안건입니다', start: 8, end: 10 },
|
||||
]
|
||||
expect(collapseRepeatedSegments(segments)).toEqual([
|
||||
{ text: '시작하겠습니다', start: 0, end: 2 },
|
||||
{ text: '감사합니다', start: 2, end: 8 },
|
||||
{ text: '다음 안건입니다', start: 8, end: 10 },
|
||||
])
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue