nerateAudio();
    }
});
textInput.addEventListener('input', updateTextStats);
clearHistoryBtn.addEventListener('click', clearHistory);
langZhOption.addEventListener('click', () => setLanguage('zh'));
langEnOption.addEventListener('click', () => setLanguage('en'));
(function init() {
    loadHistory();
    const preferredLanguage = localStorage.getItem('preferredLanguage') || (navigator.language.startsWith('zh') ? 'zh-CN' : 'en');
    setLanguage(preferredLanguage, true); // Pass true to avoid saving
    
 