VoiceEnrollment (voice/voice-enrollment.ts)

airi · packages/stage-ui/src/libs/voice/voice-enrollment.ts · typescript · MIT
voice

VoiceEnrollment class records speech, detects voice activity, and enrolls a voiceprint for authentication.

// Source: https://github.com/moeru-ai/airi | License: MIT | Copyright 2024-PRESENT Neko Ayaka
// Provided via justclaw.it.com; keep this notice with the code.
import type { AudioInput, AudioWindow, Capture } from '@proj-airi/pipelines-audio'

import { errorMessageFrom } from '@moeru/std'
import { audioWindows, capture } from '@proj-airi/pipelines-audio'

import { toMonoSamples } from './mono-samples'

/** Sherpaw enrolls a speaker only from this much speech or more. */
export const MIN_ENROLLMENT_SPEECH_SECONDS = 5

/** Recording stops after this much audio, speech or not. The Sherpaw sandbox uses the same limit. */
const MAX_RECORDING_SECONDS = 30

// NOTICE:
// Silero VAD reads 512 samples at 16 kHz, so each window lasts 32 ms.
// The constraint is in workers/vad/silero-vad.ts. The voic

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key