fix(stt): gate local fallback on installed engine and extract SidecarSupervisor
This commit is contained in:
parent
4588b65dfa
commit
2cd462333f
7 changed files with 1057 additions and 343 deletions
|
|
@ -24,6 +24,7 @@ import { GoogleDriver } from './drivers/GoogleDriver'
|
|||
import { CustomDriver } from './drivers/CustomDriver'
|
||||
import { D3ROCloudDriver } from './drivers/D3ROCloudDriver'
|
||||
import { normalizeLoopbackUrl } from '../../utils/loopback'
|
||||
import { isRecoverableByLocalFallback } from './fallbackPolicy'
|
||||
|
||||
const logger = getLogger('STTManager')
|
||||
|
||||
|
|
@ -250,7 +251,8 @@ export class STTManager extends EventEmitter implements STTEngine {
|
|||
const errorMsg = error instanceof Error ? error.message : String(error)
|
||||
logger.warn(`Cloud STT (${provider}) failed: ${errorMsg}`)
|
||||
|
||||
if (fallbackToLocal) {
|
||||
// 무음/취소처럼 로컬로 다시 해도 결과가 같은 실패는 폴백하지 않는다
|
||||
if (fallbackToLocal && isRecoverableByLocalFallback(error)) {
|
||||
logger.info(`Auto-fallback: executing Local Whisper transcription...`)
|
||||
this.emit('fallback-to-local', { provider, reason: errorMsg })
|
||||
try {
|
||||
|
|
@ -270,13 +272,15 @@ export class STTManager extends EventEmitter implements STTEngine {
|
|||
* 클라우드 공급자를 쓰는 동안에는 아무도 로컬 모델을 올리지 않는다 — LocalSTTService.transcribe가
|
||||
* 설정된 모델을 스스로 올린 뒤 전사하고(실패하면 reject), 여기서는 전체에 상한 시간을 두어
|
||||
* 받아쓰기 액션 큐가 굳지 않게 한다.
|
||||
* requireInstalled: 모델·엔진이 이미 로컬에 있을 때만 쓴다. 없으면 폴백이 엔진(~100MB)과
|
||||
* 모델(최대 수 GB)을 조용히 내려받기 시작하고 그동안 핫키 큐가 멈춘다.
|
||||
*/
|
||||
private _transcribeLocalFallback(
|
||||
audioBuffer: Buffer,
|
||||
options?: TranscribeOptions,
|
||||
): Promise<TranscriptionResult> {
|
||||
return withTimeout(
|
||||
getLocalSTTService().transcribe(audioBuffer, options),
|
||||
getLocalSTTService().transcribe(audioBuffer, { ...options, requireInstalled: true }),
|
||||
LOCAL_FALLBACK_TIMEOUT_MS,
|
||||
`Local STT fallback timed out after ${LOCAL_FALLBACK_TIMEOUT_MS}ms`,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue