UNPKG

@juspay/neurolink

Version:

The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002

34 lines (33 loc) • 945 B
/** * Shared utility: infer a `TTSAudioFormat` from a file path. * * Used by the CLI generate/stream handlers (m2) to set `stt.format` so * `STTProcessor.transcribe()` can fail fast on incompatible provider/format * combinations (e.g. MP3 to azure-stt). Pulled into a single helper to * avoid duplicating the 11-element format list across two CLI handlers. */ const VALID_FORMATS = [ "mp3", "wav", "ogg", "opus", "m4a", "flac", "webm", "mp4", "mpeg", "mpga", "pcm16", ]; /** * Returns the `TTSAudioFormat` that matches the file extension of `path`, * or `undefined` when the path is missing or its extension isn't a known * audio format. The check is case-insensitive. */ export function inferAudioFormatFromPath(path) { if (!path) { return undefined; } const ext = path.toLowerCase().split(".").pop(); return ext && VALID_FORMATS.includes(ext) ? ext : undefined; }