feat(input,voice): instant first-word-after-focus PC layout fix and speech disfluency post-processing (INPUT-04, INPUT-19, AI-03, AI-05)
This commit is contained in:
parent
dbed97c348
commit
7a86afa7b0
22 changed files with 359 additions and 39 deletions
|
|
@ -34,6 +34,21 @@ type CreateInput = Omit<
|
|||
// ============================================================
|
||||
|
||||
const BUILTIN_INSTRUCTIONS: ReadonlyArray<Omit<CustomInstruction, 'createdAt' | 'updatedAt'>> = [
|
||||
{
|
||||
id: 'builtin-clean-speech',
|
||||
name: '구어·추임새·중복 정리',
|
||||
description: '어·음·아 추임새, 말 바꾸기, 불필요한 중복 표현을 제거하고 원래 말투(반말·존댓말) 유지',
|
||||
prompt: `다음 음성 받아쓰기 텍스트에서 구어 군더더기와 음성 인식 오류를 정리해 읽기 좋은 문장으로 다듬어주세요.
|
||||
1. 화자의 원래 말투(반말·해요체·합쇼체)는 절대 바꾸지 말고 그대로 유지하세요.
|
||||
2. 무의미한 추임새('어', '음', '아', '그', '뭐', '막', '저기' 등)는 제거하되, 추임새 자체를 예시로 언급한 표현('어라든가 아라든가' 등)은 유지하세요.
|
||||
3. 말하다가 고쳐 말한 부분('검색 아니 검색이 아니라 타이핑' → '타이핑')은 취소한 앞부분을 지우고 최종 의도만 남기세요.
|
||||
4. 의미 중복('쓸데없는 의미없는' → '불필요한')과 같은 구절 반복은 한 번만 남기고 간결하게 정리하세요.
|
||||
5. 문맥상 명백한 음성 인식 동음이의어 오인식('PC' 문맥의 '스시/피씨' → 'PC')과 구어 어미('~하면은' → '~하면', '예를 들자면은' → '예를 들어')를 바로잡으세요.
|
||||
정리된 텍스트만 출력하세요.`,
|
||||
icon: 'AutoFixHigh',
|
||||
isBuiltin: true,
|
||||
order: 0
|
||||
},
|
||||
{
|
||||
id: 'builtin-translate',
|
||||
name: '번역',
|
||||
|
|
@ -41,7 +56,7 @@ const BUILTIN_INSTRUCTIONS: ReadonlyArray<Omit<CustomInstruction, 'createdAt' |
|
|||
prompt: '다음 텍스트를 {{targetLanguage}}로 번역해주세요.\n자연스럽고 정확한 번역만 출력하세요.',
|
||||
icon: 'Translate',
|
||||
isBuiltin: true,
|
||||
order: 0
|
||||
order: 1
|
||||
},
|
||||
{
|
||||
id: 'builtin-summarize',
|
||||
|
|
@ -50,7 +65,7 @@ const BUILTIN_INSTRUCTIONS: ReadonlyArray<Omit<CustomInstruction, 'createdAt' |
|
|||
prompt: '다음 텍스트의 핵심 내용을 3줄 이내로 요약해주세요.\n요약문만 출력하세요.',
|
||||
icon: 'Summarize',
|
||||
isBuiltin: true,
|
||||
order: 1
|
||||
order: 2
|
||||
},
|
||||
{
|
||||
id: 'builtin-formal',
|
||||
|
|
@ -59,7 +74,7 @@ const BUILTIN_INSTRUCTIONS: ReadonlyArray<Omit<CustomInstruction, 'createdAt' |
|
|||
prompt: '다음 텍스트를 격식 있는 비즈니스 문체로 다시 작성해주세요.\n원래 의미를 유지하면서 전문적인 톤으로 변환하세요.\n다시 작성된 텍스트만 출력하세요.',
|
||||
icon: 'Business',
|
||||
isBuiltin: true,
|
||||
order: 2
|
||||
order: 3
|
||||
},
|
||||
{
|
||||
id: 'builtin-explain-code',
|
||||
|
|
@ -68,7 +83,7 @@ const BUILTIN_INSTRUCTIONS: ReadonlyArray<Omit<CustomInstruction, 'createdAt' |
|
|||
prompt: '다음 코드를 한국어로 설명해주세요.\n각 부분이 무엇을 하는지 간결하게 설명하세요.',
|
||||
icon: 'Code',
|
||||
isBuiltin: true,
|
||||
order: 3
|
||||
order: 4
|
||||
},
|
||||
{
|
||||
id: 'builtin-free-prompt',
|
||||
|
|
@ -77,7 +92,7 @@ const BUILTIN_INSTRUCTIONS: ReadonlyArray<Omit<CustomInstruction, 'createdAt' |
|
|||
prompt: '{{userPrompt}}',
|
||||
icon: 'Edit',
|
||||
isBuiltin: true,
|
||||
order: 4
|
||||
order: 5
|
||||
}
|
||||
]
|
||||
|
||||
|
|
@ -151,9 +166,11 @@ function loadInstructions(scopeId: string): CustomInstruction[] {
|
|||
}
|
||||
const now = Date.now()
|
||||
if (!stored || stored.length === 0) return builtinDefaults(now)
|
||||
// 가져온 목록에 프리셋이 빠져 있으면 채운다(프리셋은 지울 수 없다).
|
||||
// 가져온 목록에 새로 추가된 프리셋이 빠져 있으면 맨 앞에 채우고 순서를 정렬한다(프리셋은 지울 수 없다).
|
||||
const ids = new Set(stored.map((i) => i.id))
|
||||
return [...stored, ...builtinDefaults(now).filter((b) => !ids.has(b.id))]
|
||||
const missing = builtinDefaults(now).filter((b) => !ids.has(b.id))
|
||||
if (missing.length === 0) return stored
|
||||
return [...missing, ...stored].map((item, idx) => ({ ...item, order: idx }))
|
||||
}
|
||||
|
||||
function saveInstructions(): void {
|
||||
|
|
|
|||
|
|
@ -225,6 +225,9 @@ class InputTelemetryService extends EventEmitter {
|
|||
private _rebaseFocusText = false
|
||||
/** 포커스 깜빡임 뒤 돌아온 칸 — 키보드로 친 채 돌아왔으므로 이미 편집한 칸으로 본다 */
|
||||
private _typedIntoFocus = false
|
||||
/** 현재 포커스/클릭 이후 실제로 글자 키를 쳤는가 (첫 스냅샷 전 빠른 입력 보존) */
|
||||
private _typedInCurrentFocus = false
|
||||
private _lastTypedHwnd: number | null = null
|
||||
/** 직전 스냅샷이 편집 가능한 칸이었는가 / 어느 창이었는가 (포커스 깜빡임 판정) */
|
||||
private _prevSnapshotEditable = false
|
||||
private _lastFocusHwnd: number | null = null
|
||||
|
|
@ -553,7 +556,13 @@ class InputTelemetryService extends EventEmitter {
|
|||
|
||||
this._lastKeyAt = Date.now()
|
||||
this._lastKeyClass = keyClass
|
||||
if (TYPING_KEY_CLASSES.has(keyClass)) this._lastTypedAt = this._lastKeyAt
|
||||
if (TYPING_KEY_CLASSES.has(keyClass)) {
|
||||
this._lastTypedAt = this._lastKeyAt
|
||||
this._typedInCurrentFocus = true
|
||||
this._lastTypedHwnd = this._foreground.hwnd
|
||||
} else if (keyClass === 'shortcut') {
|
||||
this._typedInCurrentFocus = false
|
||||
}
|
||||
// 진단: 키 값이 아니라 종류·수정자만 남긴다 (typed 판정이 왜 틀리는지 로그로 보이게)
|
||||
this._lastKeyDiag = `${keyClass}${vk === null ? `?${event.keycode}` : ''}${this._modifiers.ctrl ? '+C' : ''}${this._modifiers.alt ? '+A' : ''}${this._modifiers.meta ? '+M' : ''}`
|
||||
|
||||
|
|
@ -605,6 +614,7 @@ class InputTelemetryService extends EventEmitter {
|
|||
this._lastClickPos = position
|
||||
// 클릭은 다른 칸으로 옮겨 갔을 수 있다 — 다음 스냅샷의 텍스트를 새 기준으로 삼는다.
|
||||
this._rebaseFocusText = true
|
||||
this._typedInCurrentFocus = false
|
||||
this._terminalTracker.onPointerOrFocusChange(this._foreground.hwnd)
|
||||
}
|
||||
|
||||
|
|
@ -656,7 +666,10 @@ class InputTelemetryService extends EventEmitter {
|
|||
|
||||
if (isKeyboard) this._lastActiveTickAt = now
|
||||
this._lastEventAt = now
|
||||
this._sampleForeground(now, isKeyboard && gap >= 250)
|
||||
this._sampleForeground(
|
||||
now,
|
||||
isKeyboard && (gap >= 250 || this._rebaseFocusText || this._lastKeyClass === 'shortcut')
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -684,6 +697,9 @@ class InputTelemetryService extends EventEmitter {
|
|||
|
||||
const info = getForegroundWindowInfo()
|
||||
if (info) {
|
||||
if (info.hwnd !== this._foreground.hwnd) {
|
||||
this._typedInCurrentFocus = false
|
||||
}
|
||||
this._foreground = {
|
||||
appName: info.appName || null,
|
||||
windowTitle: info.title || null,
|
||||
|
|
@ -883,19 +899,27 @@ class InputTelemetryService extends EventEmitter {
|
|||
// 방금 친 글이 "들어올 때부터 있던 글" 이 되어 제안이 영영 안 뜬다. 클릭 없이 키보드로 치다가
|
||||
// 읽을 수 없는 요소를 거쳐 같은 창의 입력칸으로 돌아온 것이면 이미 편집한 칸으로 본다.
|
||||
const now = Date.now()
|
||||
this._typedIntoFocus =
|
||||
!this._rebaseFocusText &&
|
||||
!clearedByEnter &&
|
||||
const typedAfterFocus =
|
||||
this._typedInCurrentFocus &&
|
||||
this._foreground.hwnd !== null &&
|
||||
this._foreground.hwnd === this._lastFocusHwnd &&
|
||||
!this._prevSnapshotEditable &&
|
||||
this._lastTypedAt > this._lastClickAt &&
|
||||
this._foreground.hwnd === this._lastTypedHwnd &&
|
||||
this._lastTypedAt >= this._lastClickAt &&
|
||||
now - this._lastTypedAt <= SUGGESTION_DEFAULTS.recentTypingWindowMs
|
||||
this._typedIntoFocus =
|
||||
!clearedByEnter &&
|
||||
(typedAfterFocus ||
|
||||
(!this._rebaseFocusText &&
|
||||
this._foreground.hwnd !== null &&
|
||||
this._foreground.hwnd === this._lastFocusHwnd &&
|
||||
!this._prevSnapshotEditable &&
|
||||
this._lastTypedAt > this._lastClickAt &&
|
||||
now - this._lastTypedAt <= SUGGESTION_DEFAULTS.recentTypingWindowMs))
|
||||
this._lastFocusKey = focusKey
|
||||
this._textAtFocus = textForFocus
|
||||
this._rebaseFocusText = false
|
||||
if (clearedByEnter) {
|
||||
this._lastTypedAt = 0
|
||||
this._typedInCurrentFocus = false
|
||||
context.typedRecently = false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1300,7 +1300,7 @@ class MeetingModeService extends EventEmitter {
|
|||
const polished = await this._rewriteTranscriptInChunks(
|
||||
llm,
|
||||
transcript,
|
||||
'다음 음성 전사 텍스트를 다듬어주세요. 필러 단어(음, 어, 그, 아 등)를 제거하고, 문장 구조를 자연스럽게 교정하되, 원래 의미와 내용은 절대 변경하지 마세요. 타임스탬프 형식 [MM:SS]과 화자 표기([화자 N] 등)는 그대로 유지하세요.',
|
||||
'다음 음성 전사 텍스트를 다듬어주세요. 필러 단어(음, 어, 그, 아, 뭐 등), 말 바꾸기(A 아니 A가 아니라 B → B), 불필요한 어절·의미 중복을 제거하고 문장 구조를 자연스럽게 교정하되, 화자의 원래 말투(반말/존댓말)와 의미·내용은 절대 변경하지 마세요. 타임스탬프 형식 [MM:SS]과 화자 표기([화자 N] 등)는 그대로 유지하세요.',
|
||||
ErrorCode.MeetingPolishFailed,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import { getLocalLLMService } from './LocalLLMService'
|
|||
import { getLlmGateway } from './llm/LlmGateway'
|
||||
import { buildInstructionInvocation, resolveTargetLanguage } from './llm-prompts'
|
||||
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
|
||||
import { cleanDictatedText } from '@d3ro/core/dictation-cleaner'
|
||||
import { TIMING } from '@d3ro/core/constants'
|
||||
import { RecognitionState, AudioState } from '@d3ro/core/types'
|
||||
import type { KeyBindingActionId, VoiceMode, VoiceState, LLMAction } from '@d3ro/core/types'
|
||||
|
|
@ -948,6 +949,9 @@ class VoiceModeService extends EventEmitter {
|
|||
}
|
||||
if (!this._isCurrent(run)) return
|
||||
|
||||
// 결정적 구어 군더더기·추임새·말바꾸기·중복·동음이의어 1차 정리 (LLM 유무와 무관하게 0ms 즉시 적용)
|
||||
effectiveText = cleanDictatedText(effectiveText)
|
||||
|
||||
const route = this._resolveLlmRoute(overrideInstructionId)
|
||||
if (route.kind === 'insert-raw') {
|
||||
if (route.reason === 'llm-unavailable') {
|
||||
|
|
|
|||
|
|
@ -26,9 +26,15 @@ const logger = getLogger('llm-prompts')
|
|||
* PremiumLLMService는 NO_THINK prefix 없이 바로 사용.
|
||||
*/
|
||||
const BASE_SYSTEM_PROMPTS: Record<string, string> = {
|
||||
refine: `다음 음성 전사 텍스트를 자연스럽고 격식 있는 문어체로 다듬어주세요.
|
||||
원래 의미를 유지하면서 문법 오류를 수정하고, 불필요한 반복이나 필러를 제거하세요.
|
||||
다듬어진 텍스트만 출력하세요. 설명이나 부가 문구를 붙이지 마세요.`,
|
||||
refine: `다음 음성 받아쓰기 텍스트에서 구어 군더더기와 음성 인식 오류를 정리해 읽기 좋은 문장으로 다듬어주세요.
|
||||
|
||||
규칙:
|
||||
1. 말투(반말·해요체·합쇼체)는 화자가 말한 그대로 유지하세요. 반말을 존댓말로 바꾸거나 존댓말을 반말로 바꾸지 마세요.
|
||||
2. 추임새와 무의미한 간투사('어', '음', '아', '그', '뭐', '막', '저기' 등)는 모두 제거하세요. 단, 문장 안에서 그런 표현 자체를 예시로 언급한 경우('어라든가 아라든가 같은 추임새')는 지우지 마세요.
|
||||
3. 말하다가 고쳐 말한 부분('검색 아니 검색이 아니라 타이핑' → '타이핑', '내일 아니 모레' → '모레')은 취소한 앞부분을 지우고 최종 의도만 남기세요.
|
||||
4. 같은 뜻이나 구절의 중복('쓸데없는 의미없는' → '불필요한', 'PC라고 타이핑했을 때 PC라고 타이핑하면' → 'PC라고 타이핑하면')은 한 번만 남기고 간결하게 정리하세요.
|
||||
5. 문맥상 명백한 음성 인식(STT) 동음이의어 오인식(예: 'PC' 문맥의 '스시/피씨' → 'PC')과 어색한 구어 어미('~하면은' → '~하면', '예를 들자면은' → '예를 들어')를 자연스럽게 바로잡으세요.
|
||||
6. 다듬어진 텍스트만 출력하세요. 설명이나 따옴표, 머리말을 절대 붙이지 마세요.`,
|
||||
|
||||
translate: `다음 텍스트를 {{targetLanguage}}로 번역해주세요.
|
||||
자연스럽고 정확한 번역만 출력하세요. 원문이나 설명을 붙이지 마세요.`,
|
||||
|
|
|
|||
|
|
@ -76,6 +76,17 @@ export const DEFAULT_VOICE_COMMAND_KEYWORDS: ReadonlyArray<DefaultKeywordEntry>
|
|||
'explain this'
|
||||
]),
|
||||
priority: 3
|
||||
},
|
||||
{
|
||||
instructionId: 'builtin-clean-speech',
|
||||
keywords: prefixKeywords([
|
||||
'정리해 주세요',
|
||||
'정리해주세요',
|
||||
'정리해 줘',
|
||||
'정리해줘',
|
||||
'clean this up'
|
||||
]),
|
||||
priority: 4
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue