diff --git a/modules/voices.js b/modules/voices.js index f98cda3e..e33d7ffd 100644 --- a/modules/voices.js +++ b/modules/voices.js @@ -29,23 +29,40 @@ export const getVoices = imports => { return } success = true - const filterFirstOccurenceOfUniqueVoiceURIData = ({data, voiceURISet}) => data.filter(x => { + // https://github.com/brave/brave-core/blob/master/chromium_src/third_party/blink/renderer/modules/speech/speech_synthesis.cc#L41-L44 + const knownFake = [ + 'Hubert', + 'Vernon', + 'Rudolph', + 'Clayton', + 'Irving', + 'Wilson', + 'Alva', + 'Harley', + 'Beauregard', + 'Cleveland', + 'Cecil', + 'Reuben', + 'Sylvester', + 'Jasper' + ] + const getTrustedData = ({data, voiceURISet}) => data.filter(x => { const { voiceURI, name } = x - if (!voiceURISet.has(voiceURI)) { - voiceURISet.add(voiceURI) - return true + if (voiceURISet.has(voiceURI) && knownFake.includes(name)) { + sendToTrash(`speechSynthesis`, `'${name}' is a known fake name w/o a unique voiceURI`) + return false } - sendToTrash(`speechSynthesis`, `'${name}' does not have a unique voiceURI`) - return false + voiceURISet.add(voiceURI) + return true }) - const dataUnique = filterFirstOccurenceOfUniqueVoiceURIData({ data, voiceURISet: new Set() }) + const dataTrusted = getTrustedData({ data, voiceURISet: new Set() }) // https://wicg.github.io/speech-api/#speechsynthesisvoice-attributes - const local = dataUnique.filter(x => x.localService).map(x => x.name) - const remote = dataUnique.filter(x => !x.localService).map(x => x.name) - const languages = [...new Set(dataUnique.map(x => x.lang))] - const defaults = dataUnique.filter(x => x.default).map(x => x.name) + const local = dataTrusted.filter(x => x.localService).map(x => x.name) + const remote = dataTrusted.filter(x => !x.localService).map(x => x.name) + const languages = [...new Set(dataTrusted.map(x => x.lang))] + const defaults = dataTrusted.filter(x => x.default).map(x => x.name) logTestResult({ start, test: 'speech', passed: true }) return resolve({