Phase 1+2 구현: Electron 뼈대 + STT/핫키/오케스트레이터
Phase 1: - 프로젝트 초기화 (TypeScript strict, electron-vite, ESLint, Prettier) - shared 타입 (ipc-channels 113채널, types, errors, constants) - 메인 프로세스 뼈대 (bootstrap, lifecycle, 단일 인스턴스) - LoggerService, ConfigService (electron-store ESM dynamic import) - React 19 + MUI 7 Dashboard, 시스템 트레이 Phase 2: - AudioCaptureService (node-record-lpcm16, PCM16 16kHz mono) - HotkeyService (uiohook-napi, 더블프레스, holdMode/toggleMode) - LocalSTTService (faster-whisper Python sidecar, 이중 조건 플러시) - VoiceModeService 오케스트레이터 (이중 상태머신, Action Queue) - Python sidecar (FastAPI: health/load/transcribe/shutdown) - IPC 핸들러 (voice, stt, hotkey) + Preload API 확장
This commit is contained in:
parent
e24bb8378c
commit
1d152d01a1
46 changed files with 10828 additions and 4 deletions
53
src/main/ipc/voice-handlers.ts
Normal file
53
src/main/ipc/voice-handlers.ts
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
// src/main/ipc/voice-handlers.ts
|
||||
|
||||
import { ipcMain } from 'electron'
|
||||
import { IPC_CHANNELS } from '@shared/ipc-channels'
|
||||
import { ipcSuccess, ipcError, ErrorCode } from '@shared/errors'
|
||||
import { getVoiceModeService } from '../services/VoiceModeService'
|
||||
import type { StartRecordingParams, StopRecordingParams, CancelRecordingParams, SetVoiceModeParams } from '@shared/types'
|
||||
|
||||
export function registerVoiceHandlers(): void {
|
||||
ipcMain.handle(IPC_CHANNELS.VOICE.START_RECORDING, async (_event, params: StartRecordingParams) => {
|
||||
try {
|
||||
const voice = getVoiceModeService()
|
||||
await voice.startSession('dictation')
|
||||
const session = voice.currentSession
|
||||
return ipcSuccess({ sessionId: session?.id ?? params.sessionId ?? '' })
|
||||
} catch {
|
||||
return ipcError(ErrorCode.AudioCaptureStartFailed, 'Failed to start recording')
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.VOICE.STOP_RECORDING, async (_event, params: StopRecordingParams) => {
|
||||
try {
|
||||
const voice = getVoiceModeService()
|
||||
await voice.stopSession()
|
||||
return ipcSuccess({
|
||||
sessionId: params.sessionId,
|
||||
text: voice.currentSession?.transcription ?? '',
|
||||
durationMs: voice.currentSession ? Date.now() - voice.currentSession.startedAt : 0
|
||||
})
|
||||
} catch {
|
||||
return ipcError(ErrorCode.STTTranscriptionFailed, 'Failed to stop recording')
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.VOICE.CANCEL_RECORDING, async (_event, _params: CancelRecordingParams) => {
|
||||
getVoiceModeService().cancelSession()
|
||||
return ipcSuccess(undefined)
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.VOICE.GET_STATE, async () => {
|
||||
return ipcSuccess(getVoiceModeService().getState())
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.VOICE.SET_MODE, async (_event, params: SetVoiceModeParams) => {
|
||||
// Phase 2: 모드만 설정에 저장 (실제 모드 전환은 핫키에서 처리)
|
||||
return ipcSuccess(undefined)
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.VOICE.GET_MODE, async () => {
|
||||
const voice = getVoiceModeService()
|
||||
return ipcSuccess(voice.currentSession?.mode ?? 'dictation')
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue