('Error synthesizing audio:', err);
                showError(err.toString());
                audioContainer.style.display = 'none';
            } finally {
                submitBtn.disabled = false;
                btnText.textContent = 'Convert to Speech';
                loadingSpinner.style.display = 'none';
            }
        });

        function showError(message) {
            errorText.textContent = message;
            errorText.style.display = 'block';
        }

        function clearError(