@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
29 lines (28 loc) • 1.31 kB
TypeScript
/**
* Provider-neutral speaker turns.
*
* Diarizing STT providers disagree about where the speaker label lives:
* Deepgram and Google put it on every word, ElevenLabs Scribe puts it on
* every token, the diarization sidecar puts it on each segment. Callers want
* one shape — a list of turns, each with a speaker, a time range and text —
* so `STTProcessor` derives it here whenever a provider returned speaker
* labels on words but no speaker-labelled segments of its own.
*
* @module utils/speakerTurns
*/
import type { TranscriptionSegment, WordTiming } from "../types/index.js";
/**
* Merge consecutive same-speaker words into turns.
*
* A word without a speaker continues the current turn (providers emit
* unlabelled punctuation and spacing tokens); a word with a different
* speaker starts a new one. Words are joined with single spaces and the
* result trimmed, so text built from punctuated words reads naturally.
* Returns `[]` when no word carries a speaker, so callers can tell "no
* diarization" apart from "one speaker".
*/
export declare function buildSpeakerTurns(words: WordTiming[]): TranscriptionSegment[];
/** Distinct speaker labels in order of first appearance. */
export declare function listSpeakers(items: ReadonlyArray<{
speaker?: string;
}>): string[];