fix(caption): unload the caption-only STT model when a start is cancelled or fails

stop() during model loading saw no aux model yet and skipped the unload, and
the failure path (e.g. no microphone) never unloaded it, so the caption model
kept VRAM alongside the dictation model until the next session ended.
This commit is contained in:
Yun Chan 2026-10-21 00:25:35 +09:00
parent c46713536d
commit 8d003c8fca
2 changed files with 105 additions and 0 deletions

View file

@ -256,6 +256,8 @@ class CaptionService extends EventEmitter {
// 기다리는 사이 stop()(또는 새 start)이 세션을 가져갔다 — 공유 상태는 건드리지 않고
// 이 시도가 연 자원만 돌려준다(release 는 멱등).
await ownAudio?.release()
// stop() 이 내릴 때 아직 로딩 중이던 보조 모델이 뒤늦게 올라왔을 수 있다. 새 시작이 없을 때만 내린다.
if (this._captionModelId && this._state === 'inactive') void getLocalSTTService().releaseAuxModel()
logger.info('캡션 시작 취소: 로딩 중 정지됨')
throw new D3ROError(ErrorCode.CaptionStartFailed, '캡션 시작이 취소되었습니다')
}
@ -267,6 +269,8 @@ class CaptionService extends EventEmitter {
this._systemTrack = null
await this._audio.release()
this._hideOverlaySafely()
// 시작 실패(오디오 장치 없음 등)에도 올려 둔 보조 모델을 내린다 — 안 그러면 다음 세션 종료까지 VRAM 을 잡는다.
if (this._captionModelId) void getLocalSTTService().releaseAuxModel()
this._session = { ...DEFAULT_START_OPTIONS }
this._setState('inactive')
const d3roErr =