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
This commit is contained in:
Russell Ballestrini 2025-07-03 19:31:52 -04:00
parent 69fd142004
commit 76bd27bea8

View file

@ -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);