From 76bd27bea86cd4c5d47b0d5e01c93f11a484fcb0 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Thu, 3 Jul 2025 19:31:52 -0400 Subject: [PATCH] feat: generate smart filenames for TTS downloads using Hermes - Use generateTitleForTTS to create dash-separated filenames based on textarea content - Hermes analyzes the text and generates descriptive filenames like 'hello-world-tts.mp3' - Fallback to default filename if generation fails --- src/tts-modal.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/tts-modal.js b/src/tts-modal.js index 1b00d4e..2a11c12 100644 --- a/src/tts-modal.js +++ b/src/tts-modal.js @@ -1,7 +1,7 @@ // TTS Modal functionality import { initializeChunkFiveFont } from "./ui-themes.js"; import { getUIText } from "./ui-translations.js"; -import { handleTTS, downloadAudio } from "./tts.js"; +import { handleTTS, downloadAudio, generateTitleForTTS } from "./tts.js"; // Get USE_CUSTOM_STYLING from window or default const USE_CUSTOM_STYLING = window.UNCLOSEAI_CUSTOM_STYLING !== false; @@ -403,7 +403,17 @@ export function openTTSModal() { padding: 8px 16px; `; } - downloadBtn.onclick = () => downloadAudio(result.blobUrl, "tts-audio.mp3"); + downloadBtn.onclick = async () => { + try { + // Generate filename based on textarea content + const filename = await generateTitleForTTS(text); + downloadAudio(result.blobUrl, `${filename}.mp3`); + } catch (error) { + console.error("Error generating filename:", error); + // Fallback to default filename + downloadAudio(result.blobUrl, "tts-audio.mp3"); + } + }; // Assemble controls controlsContainer.appendChild(playPauseBtn);