Fix TTS preview for 'Server default' voice option

- Allow empty voice value to preview server default
- Display 'server default' in preview text
- Clears user preference (sets to null) when testing default
This commit is contained in:
ifedan-ed 2026-03-31 16:15:41 +00:00
parent f3624c0806
commit 6edcb8c215

View file

@ -159,13 +159,9 @@
var ttsSelect = document.getElementById('tts-voice-select');
var voice = ttsSelect ? ttsSelect.value : null;
if (!voice || voice === '') {
showToast('Please select a voice from the dropdown first', 'info');
return;
}
// Temporarily save preference, generate preview, then restore
var text = 'Hello, this is a preview of the ' + voice + ' voice. This is how your read-aloud feature will sound.';
// Allow "Server default" (empty value) to preview
var displayVoice = voice || 'server default';
var text = 'Hello, this is a preview of the ' + displayVoice + ' voice. This is how your read-aloud feature will sound.';
var btnPreview = document.getElementById('btn-preview-voice');
if (btnPreview) {
@ -173,11 +169,11 @@
btnPreview.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Loading...';
}
// Save current preference temporarily
// Save current preference temporarily (or clear it if "server default" selected)
fetch('/api/user/preferences', {
method: 'POST',
headers: getAuthHeaders(),
body: JSON.stringify({ tts_voice: voice })
body: JSON.stringify({ tts_voice: voice || null })
})
.then(function() {
// Generate audio with new voice