getTTSCacheKey (utils/ttscache.ts)

librechat · client/src/utils/ttscache.ts · typescript · MIT
voice

In-memory cache for TTS audio with size and entry limits.

// Source: https://github.com/danny-avila/librechat | License: MIT | Copyright 2026 LibreChat
// Provided via justclaw.it.com; keep this notice with the code.
/** Cache Storage names earlier builds persisted read-aloud audio under (the first keyed by the
 *  message text). Audio is now held only in this tab's memory, so these are just deleted. */
const LEGACY_TTS_CACHE_NAMES = ['tts-responses', 'tts-responses-v1', 'tts-responses-v1:pending'];
const MAX_ENTRIES = 50;
/** Long replies make large recordings, so the cache is bounded by size as well as count. */
const MAX_BYTES = 32 * 1024 * 1024;

/** Spoken audio by hashed key, oldest first; it never leaves this tab and dies with it. */
const audioByKey = new Map<string, Blob>();
let totalBytes = 0;
/** Bumped on every clear, so a request tha

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

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

Get a free API key