feat(caption): stream live captions and polish finished lines in context
Replaces the fixed six-second batches with a streaming track per audio source: the uncommitted audio is re-recognised every second and sent as a partial with its agreed (stable) prefix, a short pause finalises the line, and long unbroken speech is committed at Whisper segment boundaries. Idle audio is trimmed so silence cannot produce invented sentences. Finished lines are corrected by the local model against the previous lines and replaced in place; edits that change too much are rejected. The behaviour can be switched off in Settings.
This commit is contained in:
parent
db8d9448a3
commit
39b8e7448e
28 changed files with 827 additions and 217 deletions
|
|
@ -253,3 +253,32 @@ export function buildSuggestionPrompt(input: SuggestionPromptInput): {
|
|||
}
|
||||
|
||||
export { SUGGESTION_SYSTEM_PROMPT }
|
||||
|
||||
/**
|
||||
* 실시간 자막 문맥 다듬기 — 확정된 자막 한 줄을 앞 문맥에 맞게 고친다.
|
||||
*
|
||||
* 받아 적기의 오류(띄어쓰기·문장부호·잘못 들은 단어)만 고친다. 요약·의역·추가는
|
||||
* 금지이며, 호출자는 `acceptCaptionRefinement` 로 변화량을 다시 검사한다.
|
||||
*/
|
||||
const CAPTION_REFINE_SYSTEM_PROMPT = `실시간 음성 인식으로 받아 적은 자막 한 줄을 다듬습니다.
|
||||
|
||||
규칙:
|
||||
- 띄어쓰기, 문장부호, 앞 문맥으로 볼 때 명백하게 잘못 들은 단어만 고치세요.
|
||||
- 뜻을 바꾸거나, 요약하거나, 말을 더하거나 빼지 마세요.
|
||||
- 원문과 같은 언어, 같은 말투(존댓말/반말, 구어체)를 유지하세요.
|
||||
- 고친 문장 한 줄만 출력하세요. 설명, 따옴표, 번호를 붙이지 마세요.
|
||||
- 고칠 것이 없으면 원문을 그대로 출력하세요.`
|
||||
|
||||
export function buildCaptionRefinePrompt(input: {
|
||||
text: string
|
||||
previous: readonly string[]
|
||||
}): { systemPrompt: string; text: string } {
|
||||
const sections: string[] = []
|
||||
const previous = input.previous.filter((line) => line.trim().length > 0).slice(-2)
|
||||
if (previous.length > 0) sections.push('[앞 문맥]', ...previous, '')
|
||||
sections.push('[다듬을 자막]', input.text.trim())
|
||||
return {
|
||||
systemPrompt: `${SUGGESTION_NO_THINK_PREFIX}\n${CAPTION_REFINE_SYSTEM_PROMPT}`,
|
||||
text: sections.join('\n')
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue