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:
parent
f3624c0806
commit
6edcb8c215
1 changed files with 5 additions and 9 deletions
|
|
@ -159,13 +159,9 @@
|
||||||
var ttsSelect = document.getElementById('tts-voice-select');
|
var ttsSelect = document.getElementById('tts-voice-select');
|
||||||
var voice = ttsSelect ? ttsSelect.value : null;
|
var voice = ttsSelect ? ttsSelect.value : null;
|
||||||
|
|
||||||
if (!voice || voice === '') {
|
// Allow "Server default" (empty value) to preview
|
||||||
showToast('Please select a voice from the dropdown first', 'info');
|
var displayVoice = voice || 'server default';
|
||||||
return;
|
var text = 'Hello, this is a preview of the ' + displayVoice + ' voice. This is how your read-aloud feature will sound.';
|
||||||
}
|
|
||||||
|
|
||||||
// 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.';
|
|
||||||
|
|
||||||
var btnPreview = document.getElementById('btn-preview-voice');
|
var btnPreview = document.getElementById('btn-preview-voice');
|
||||||
if (btnPreview) {
|
if (btnPreview) {
|
||||||
|
|
@ -173,11 +169,11 @@
|
||||||
btnPreview.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Loading...';
|
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', {
|
fetch('/api/user/preferences', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: getAuthHeaders(),
|
headers: getAuthHeaders(),
|
||||||
body: JSON.stringify({ tts_voice: voice })
|
body: JSON.stringify({ tts_voice: voice || null })
|
||||||
})
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
// Generate audio with new voice
|
// Generate audio with new voice
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue