@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
33 lines (32 loc) • 1.75 kB
TypeScript
/**
* Audio decoding for the Whistle engine: anything in, 16 kHz mono Float32 out.
*
* WAV (PCM 8/16/24/32-bit integer or 32/64-bit float, any sample rate and
* channel count, including WAVE_FORMAT_EXTENSIBLE) and raw `pcm16` (PCM16LE
* mono at `options.sampleRate`, default 16 kHz) are decoded here with no
* dependencies. Compressed formats (mp3, m4a, ogg/opus, webm, flac, mp4 …) go
* through ffmpeg — `FFMPEG_PATH`, then the optional `ffmpeg-static` package,
* then `ffmpeg` on `PATH` — and are refused with a clear error when none of
* those exists.
*
* @module voice/whistle/audio
*/
import type { TTSAudioFormat } from "../../types/index.js";
/** Formats Whistle decodes without any external tool. */
export declare const WHISTLE_NATIVE_FORMATS: readonly TTSAudioFormat[];
/** Formats Whistle decodes through ffmpeg when it is available. */
export declare const WHISTLE_FFMPEG_FORMATS: readonly TTSAudioFormat[];
/** The engine's fixed input rate. */
export declare const WHISTLE_SAMPLE_RATE = 16000;
/**
* Decode `audio` to 16 kHz mono Float32 samples in [-1, 1]. `format` is a
* hint; a RIFF/WAVE header is recognised whatever it says.
*/
export declare function decodeToWhistlePcm(audio: Buffer, format: TTSAudioFormat | undefined, sampleRate: number | undefined): Promise<Float32Array>;
/** PCM16LE frames (as streamed by microphones and the chunked adapter) → 16 kHz Float32. */
export declare function decodePcm16(buf: Buffer, sampleRate: number): Float32Array;
/**
* Resample to 16 kHz: a box filter over each output sample's footprint when
* downsampling (a cheap anti-alias), linear interpolation when upsampling.
*/
export declare function resampleTo16k(input: Float32Array, rate: number): Float32Array;