MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / normalizeLanguageForSTT

Function normalizeLanguageForSTT

source code/hooks/useVoice.ts:123–136  ·  view source on GitHub ↗
(language: string | undefined)

Source from the content-addressed store, hash-verified

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