MCPcopy
hub / github.com/codeaashu/claude-code / normalizeLanguageForSTT

Function normalizeLanguageForSTT

src/hooks/useVoice.ts:121–134  ·  view source on GitHub ↗
(language: string | undefined)

Source from the content-addressed store, hash-verified

119// non-empty but unsupported, fellBackFrom is set to the original input so
120// callers can surface a warning.
121export function normalizeLanguageForSTT(language: string | undefined): {
122 code: string
123 fellBackFrom?: string
124} {
125 if (!language) return { code: DEFAULT_STT_LANGUAGE }
126 const lower = language.toLowerCase().trim()
127 if (!lower) return { code: DEFAULT_STT_LANGUAGE }
128 if (SUPPORTED_LANGUAGE_CODES.has(lower)) return { code: lower }
129 const fromName = LANGUAGE_NAME_TO_CODE[lower]
130 if (fromName) return { code: fromName }
131 const base = lower.split('-')[0]
132 if (base && SUPPORTED_LANGUAGE_CODES.has(base)) return { code: base }
133 return { code: DEFAULT_STT_LANGUAGE, fellBackFrom: language }
134}
135
136// Lazy-loaded voice module. We defer importing voice.ts (and its native
137// audio-capture-napi dependency) until voice input is actually activated.

Callers 3

callFunction · 0.85
finishRecordingFunction · 0.85
startRecordingSessionFunction · 0.85

Calls 1

hasMethod · 0.45

Tested by

no test coverage detected