Functions
Utility functions for audio processing, logging, and more.
Utility functions for audio processing, logging, and more.
- applyFade — Applies linear fade-in and fade-out effects to audio samples.
- blobToArrayBuffer — Converts an audio Blob to an ArrayBuffer.
- calculateRMS — Calculates the RMS (Root Mean Square) volume level of audio samples.
- concatenateArrayBuffers — Concatenates multiple ArrayBuffer instances into a single contiguous buffer.
- configureSTTFromMetadata — Auto-configures an STT provider’s audio format settings from input metadata.
- crc32 — Compute the CRC32 checksum of a byte buffer.
- createAudioBlob — Creates a WAV audio Blob from raw 16-bit PCM data.
- createBlocklistGuardrail — Create a guardrail that blocks or redacts forbidden terms and patterns.
- createLogger — Factory function to create a new Logger instance.
- createModerationGuardrail — Create a guardrail backed by an async moderation classifier.
- createPatternRedactionGuardrail — Create a guardrail that rewrites every match of the supplied patterns.
- createPIIRedactionGuardrail — Create a guardrail that redacts common PII before it is spoken.
- createPronunciationGuardrail — Create a guardrail that swaps terms for their spoken form before synthesis.
- createWavHeader — Creates a standard 44-byte WAV (RIFF) header for raw PCM audio data.
- decodeEventStreamMessage — Decode a framed event-stream message, validating both CRCs.
- detectAudioFormat — Detects the audio container format from magic bytes in the buffer.
- downsampleAudio — Downsamples audio data from one sample rate to a lower sample rate.
- encodeEventStreamMessage — Encode an event-stream message with string headers.
- extractHeader — Extracts the container header from an audio buffer for a known format.
- floatTo16BitPCM — Converts a Float32Array of audio samples to a 16-bit signed integer PCM Int16Array.
- getAudioMimeType — Returns the MIME type string corresponding to an AudioFormat.
- getDetectedFormatMimeType — Returns the MIME type for a detected container format.
- int16ToFloat — Converts an Int16Array of 16-bit PCM samples to a Float32Array of normalized floats.
- isSilent — Detects whether an audio buffer contains silence.
- parseAudioMetadata — Parses audio format parameters out of a container header.
- presignAwsUrl — Presign a URL with SigV4 query parameters (X-Amz-* query style).
- resolveAwsCredentials — Resolve an AwsCredentialsProvider to a concrete credentials object, invoking the factory when one is supplied.
- resolveLanguageCode — Resolves a language string to an ISO 639-3 code for ElevenLabs Scribe V2.
- resolveProviders — Resolve a flat array of providers into a fully typed ResolvedPipeline.
- signAwsRequestHeaders — Sign an HTTP request with SigV4 headers (Authorization header style).
- textSimilarity — Compute a similarity score (0–1) between two transcript strings.