⚡ Implement in-memory caching for TTS API#25
⚡ Implement in-memory caching for TTS API#25google-labs-jules[bot] wants to merge 1 commit intomainfrom
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
💡 What:
Implemented an in-memory LRU-like cache for the Voice Proxy API (
api/proxy-voice.ts).Mapto store generated base64 audio keyed by input text.🎯 Why:
The Google GenAI TTS API is an expensive operation (both in latency and potentially cost). Since the system prompts for a specific "neutral, calm, cold, mechanical robotic British voice", the output for a given text input is deterministic and highly cacheable. This reduces latency from ~500ms+ (API dependent) to <1ms for repeated requests (e.g., users re-playing a message or concurrent users hitting common system phrases).
📊 Measured Improvement:
A synthetic benchmark (
scripts/perf-test-cache.ts) was created to simulate the API latency (500ms) and measure the impact of the caching strategy.Results (5 Iterations):
Note: As this is a serverless function, the cache persists only as long as the container is "warm". This is a standard optimization pattern for Vercel functions (also used in
api/admin-stats.ts) to handle burst traffic efficiently without external infrastructure overhead.PR created automatically by Jules for task 11748698826946078814 started by @cjo93