import { type RecordingTrackSource } from "@opengeni/contracts"; import { type Database } from "./database.js"; import type { recordingVoiceChannelValues } from "./recordings-schema.js"; export type RecordingVoiceChannel = (typeof recordingVoiceChannelValues)[number]; /** A diarized speaker's voice in a finished transcript. */ export type RecordingSpeakerVoice = { label: string; channel: RecordingVoiceChannel; /** The speaker model that made the vector; vectors only compare within one. */ model: string; embedding: readonly number[]; speechMilliseconds: number; }; /** * Cosine similarity a voice needs before its best match is suggested. On * meeting audio the same person scores about 0.85 to 0.97 across meetings * and different people stay below 0.5, so 0.6 leaves room both ways. */ export declare const VOICE_SUGGESTION_THRESHOLD = 0.6; /** Less speech than this gives too rough a vector to suggest or learn from. */ export declare const MIN_VOICE_SPEECH_MILLISECONDS = 4000; /** The kind of audio a track carries, for keeping voiceprints apart. */ export declare function recordingVoiceChannel(source: RecordingTrackSource): RecordingVoiceChannel; export declare function cosineSimilarity(left: readonly number[], right: readonly number[]): number; export type KnownVoice = { personId: string; model: string; embedding: readonly number[]; }; /** * Who each voice probably is. A voice takes its closest person when the * similarity reaches the threshold; each person and each label is used at * most once, strongest pairs first. People someone turned down for a similar * voice in this recording, and labels or people already named, are skipped. */ export declare function suggestSpeakersByVoice(input: { voices: readonly RecordingSpeakerVoice[]; known: readonly KnownVoice[]; rejected: readonly KnownVoice[]; namedLabels: ReadonlySet; namedPeople: ReadonlySet; }): Map; /** * Which of the voices diarized in one call is a known person's: the one most * like their voiceprints, when it reaches the suggestion threshold and has * enough speech to judge. Null when none does. */ export declare function voiceMatchingVoiceprints(input: { voices: ReadonlyArray<{ speaker: string; speechMilliseconds: number; embedding: readonly number[]; }>; model: string; known: readonly KnownVoice[]; }): string | null; /** * A workspace member's voiceprints, when they agreed to be remembered: how * the person recording is found among the voices on their own microphone. */ export declare function memberVoiceprints(db: Database, input: { workspaceId: string; memberSubjectId: string; }): Promise; /** Whether the workspace recognizes voices. */ export declare function workspaceRecognizesVoices(tx: Database, workspaceId: string): Promise; /** Voiceprints of the people in the workspace who agreed to be remembered. */ export declare function consentedVoiceprints(tx: Database, workspaceId: string): Promise; export declare function rejectedVoices(tx: Database, workspaceId: string, recordingId: string): Promise; /** * Keep voiceprints in step with who a version's speaker is. Confirming a * remembered person teaches their voiceprint; naming the label someone else, * or clearing it, takes the voice back out of whoever learned it. */ export declare function syncSpeakerVoice(tx: Database, input: { workspaceId: string; versionId: string; label: string; personId: string | null; }): Promise; /** * Take a recording's voices out of every voiceprint they taught, and drop * them, as the recording is deleted: a voiceprint only holds the speakers * currently named as the person in recordings that still exist. Nothing is * left to learn from or subtract again, so repeating it changes nothing. */ export declare function releaseRecordingVoices(tx: Database, input: { workspaceId: string; recordingId: string; }): Promise; /** * Remember that a suggested person is not this voice, for this recording. * Returns whether the label had a suggestion to turn down. */ export declare function rejectVoiceSuggestion(tx: Database, input: { accountId: string; workspaceId: string; recordingId: string; versionId: string; label: string; subjectId: string; }): Promise; /** * Learn a newly remembered person's voice from every speaker already * confirmed as them, in the recordings the caller can see. */ export declare function learnConfirmedVoices(tx: Database, input: { workspaceId: string; personId: string; }): Promise; /** Forget one person's voice: their voiceprints and what taught them. */ export declare function forgetPersonVoice(tx: Database, input: { workspaceId: string; personId: string; }): Promise;