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

41 lines (40 loc) • 2.3 kB
/** * Code-mix analysis between two engines' readings of the same speech. * * An Indic engine writes English words phonetically in its own script * ("मीटिंग" for "meeting"); an English-oriented engine writes Indian-language * words as English-sounding guesses ("page dinner" for "भेज देना"). Brought * to one rough phonetic form — Indic text romanized, both reduced to a * consonant skeleton with voicing and aspiration folded — the two sequences * line up word for word wherever the speaker spoke English, and stop lining * up where they spoke an Indian language. The share of the Indic engine's * words that find a phonetic partner is therefore an estimate of how much of * the utterance was English, independent of either engine's own (accent- * sensitive) language score; the alignment itself is what a word-level * combination of the two readings is built on. * * @module voice/codeMix */ import type { STTCodeMixAnalysis, STTWordPair } from "../types/index.js"; /** Indic-script text in rough Latin letters; anything else passes through. */ export declare function romanizeIndic(text: string): string; /** * A word's consonant skeleton: digraphs folded, voicing pairs merged * (t/d, k/g, p/b are where an accent and a script disagree most), vowels and * h dropped, repeats collapsed. "meeting" and "मीटिंग" both give "mtnk". */ export declare function phoneticKey(word: string): string; /** Whether two skeletons sound alike: equal, or one edit apart on three or more consonants (two on six). */ export declare function soundsAlike(a: string, b: string): boolean; /** * Align two readings word by word (Needleman–Wunsch on skeletons): a pair * for every word of either side, matched where the words sound alike. */ export declare function alignReadings(indic: readonly string[], latin: readonly string[]): STTWordPair[]; /** * How much of an utterance two readings agree is English: the share of the * Indic engine's words with a phonetic partner in the English-oriented * engine's text. Near 1 for English an Indic engine wrote phonetically; well * under it for code-mixed speech, where the Indian-language words find none. */ export declare function analyzeCodeMix(indicText: string, latinText: string): STTCodeMixAnalysis;