Fix TTS voice selection validation breaking API calls

Remove obsolete VALID_VOICES validation that was rejecting the new
"model:voice" format from the voices endpoint integration. The old
validation expected simple voice names like "onyx" but the new format
uses "tts-1:onyx", causing validation to fail and produce malformed
API requests that returned HTTP 400 errors.

Changes:
- Remove VALID_VOICES constant (no longer needed)
- Update syncInputsAndQueryString() to accept any voice value from dropdown
- Default to "tts-1:onyx" format if no value present

Fixes the TTS errors seen in production where voice selection was
failing with HTTP 400 status.
This commit is contained in:
Russell Ballestrini 2025-11-09 15:32:38 -05:00
parent 33a6eaa215
commit 6bc896b9b0

View file

@ -103,9 +103,6 @@ if (!urlParams.get("username")) {
}
const room_name = "{{ room_name }}";
// Global constants for valid voices
const VALID_VOICES = ['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'];
// Configuration for DOMPurify to specify which tags and attributes are allowed
const dompurify_config = {
ADD_TAGS: ["iframe", "img", "video"],
@ -164,7 +161,7 @@ function syncInputsAndQueryString() {
// Get current values
const currentUsername = usernameInputDesktop?.value || username || "guest";
const currentModel = modelSelectDesktop.value;
const currentVoice = VALID_VOICES.includes(voiceSelectDesktop.value) ? voiceSelectDesktop.value : 'onyx';
const currentVoice = voiceSelectDesktop.value || 'tts-1:onyx';
// Update global username variable
username = currentUsername;
@ -183,14 +180,14 @@ function syncInputsAndQueryString() {
// Save to localStorage for persistence
localStorage.setItem('selectedModel', currentModel);
localStorage.setItem('selectedVoice', currentVoice);
// Update URL
const newUrl = new URL(window.location.href);
newUrl.searchParams.set("username", sanitizedUsername);
newUrl.searchParams.set("model", currentModel);
newUrl.searchParams.set("voice", currentVoice);
window.history.replaceState({}, '', newUrl);
// Update room links with new parameters
if (typeof updateRoomLinksWithCurrentParams === 'function') {
updateRoomLinksWithCurrentParams();