From 6bc896b9b0771d03a1d4e8da3c9732e489a20595 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Sun, 9 Nov 2025 15:32:38 -0500 Subject: [PATCH] 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. --- templates/chat.html | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/templates/chat.html b/templates/chat.html index 0f169e3..f58f057 100644 --- a/templates/chat.html +++ b/templates/chat.html @@ -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();