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:
+1
-1
@@ -12371,7 +12371,7 @@ function _initBrowserTtsVoices(selectedVoice) {
|
|||||||
sel.innerHTML = '<option value="">— Caricamento voci… —</option>';
|
sel.innerHTML = '<option value="">— Caricamento voci… —</option>';
|
||||||
|
|
||||||
const populate = () => {
|
const populate = () => {
|
||||||
const voices = window.speechSynthesis.getVoices();
|
const voices = (window.speechSynthesis.getVoices() || []).filter(v => v != null && v.lang);
|
||||||
if (!voices.length) return false;
|
if (!voices.length) return false;
|
||||||
// Italian voices first, then others
|
// Italian voices first, then others
|
||||||
const it = voices.filter(v => v.lang.startsWith('it'));
|
const it = voices.filter(v => v.lang.startsWith('it'));
|
||||||
|
|||||||
Reference in New Issue
Block a user