Routes and detects languages for audio and text input, applying confidence thresholds and warning when audio uses unsupported ASR languages. Reuse for multilingual voice pipelines needing language selection.
// Source: https://github.com/drakulavich/kesha-voice-kit | License: MIT | Copyright 2026 drakulavich
// Provided via justclaw.it.com; keep this notice with the code.
import { detectAll } from "tinyld";
import type { LangDetectResult } from "./engine";
import type { TextLangDetectResult } from "./types";
/** A guess scoring below this is kept in its raw field but never names the top-level `lang` (Exploratory S11-2, S11-4). */
export const LANG_CONFIDENCE_FLOOR = 0.5;
/** The speech-to-text languages in docs/languages.md; keep the two in step. */
const ASR_LANGUAGES = new Set([
"bg", "hr", "cs", "da", "nl", "en", "et", "fi", "fr", "de", "el", "hu", "it",
"lv", "lt", "mt", "pl", "pt", "ro", "ru", "sk", "sl", "es", "sv", "uk",
]);
/** Audio lang-id this sure of a non-ASR language outra
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key