d3ro-voice/docs/phases/phase-2.md
Yun Chan e24bb8378c 초기 프로젝트 설정: 하네스 시스템 + 설계서 + RE 노하우
- CLAUDE.md: 프로젝트 규칙, 기술 스택, 코딩 규칙, 페이즈 로드맵
- .claude/settings.json: 권한, 강제 훅 (매 프롬프트 설계서 규칙 주입)
- .claude/skills/: implement-phase, review-phase, scaffold, test-commit, debug
- .claude/agents/: electron-architect, voice-pipeline-expert, ui-specialist
- docs/design/00-09: 마스터 아키텍처, 서비스 명세(16개), IPC(113채널),
  DB스키마, UI컴포넌트, 검증리포트, 외부엔진연동, 갭분석,
  VoiceMode패턴, 디자인시스템, 히스토리팝업
- docs/phases/1-7+3.5: 전체 구현 페이즈 문서
- docs/re-findings/: Speakly RE 노하우 5개 문서
2026-04-05 01:03:03 +09:00

46 lines
1.8 KiB
Markdown

# Phase 2: 로컬 STT 연동 (Whisper) + 핫키
## 목표
마이크 캡처된 오디오를 로컬 Whisper 모델로 전사하고, 글로벌 핫키로 녹음을 제어할 수 있는 상태.
## 태스크
### 2.1 LocalSTTService
- `src/main/services/LocalSTTService.ts`
- faster-whisper Python sidecar 관리 (spawn/kill)
- 또는 whisper.cpp Node addon 직접 호출
- PCM 16kHz mono → Whisper → 텍스트
- Speakly 패턴: 이중 조건 플러시 (모델 로딩 + 오디오 버퍼링 병렬)
- EventEmitter: 'transcription-delta', 'transcription-complete'
### 2.2 VoiceModeService (오케스트레이터)
- `src/main/services/VoiceModeService.ts`
- Speakly 패턴 적용:
- RecognitionState 상태 머신 (IDLE→PREPARING→READY→RECOGNIZING→COMPLETED)
- AudioState 별도 추적
- _isInTerminalState() 체크
- errorEmitted 플래그
- 오디오 무손실 버퍼링 (STT 준비 전 버퍼)
- 모드: dictation (hold-to-talk), hands-free (toggle)
### 2.3 글로벌 핫키
- uiohook-napi로 글로벌 키보드 후킹
- 기본 트리거: Right Alt (Windows)
- Speakly 패턴: pressed/released 이벤트, 더블프레스 감지 (300ms), 최소 700ms
- HotkeyService + HotkeyConfig
### 2.4 IPC 채널 추가
- `voice:startRecording`, `voice:stopRecording`
- `stt:getStatus`, `stt:getModels`
- `hotkey:getDictationShortcut`, `hotkey:setDictationShortcut`
## Speakly RE 참조
- VoiceRecognitionService: 상태 머신, 이중 조건 플러시, 재연결 3계층
- VoiceModeService: 오케스트레이션, 모드별 핫키 처리
- HotkeyConfig: 키코드 맵, 시스템 예약 단축키 블랙리스트
## 완료 조건
- [ ] 핫키로 녹음 시작/종료 가능
- [ ] Whisper로 한국어 음성 전사 작동
- [ ] 상태 머신 정상 전이
- [ ] 오디오 버퍼링/플러시 정상 작동