fix(tts): filter null/undefined voices to handle Brave anti-fingerprinting

Brave browser's anti-fingerprinting user-script (makeFakeVoiceFromVoice)
intercepts the SpeechSynthesis voices array and crashes with
'undefined is not an object (evaluating Object.getPrototypeOf(voice))'
when iterating over null voice entries.

Defensive fix: filter null/undefined/no-lang entries from getVoices()
before processing, so Brave's proxy never receives invalid objects.

Fixes #58
This commit is contained in:
dadaloop82
2026-05-16 07:38:15 +00:00
parent e75b004ebc
commit 3cd439e068
+1 -1
View File
@@ -12371,7 +12371,7 @@ function _initBrowserTtsVoices(selectedVoice) {
sel.innerHTML = '<option value="">— Caricamento voci… —</option>';
const populate = () => {
const voices = window.speechSynthesis.getVoices();
const voices = (window.speechSynthesis.getVoices() || []).filter(v => v != null && v.lang);
if (!voices.length) return false;
// Italian voices first, then others
const it = voices.filter(v => v.lang.startsWith('it'));