Skip to content

Commit

Permalink
Prefer high quality browser voices by default
Browse files Browse the repository at this point in the history
  • Loading branch information
cdrini committed Nov 7, 2023
1 parent 99aa371 commit 422aade
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/plugins/tts/AbstractTTSEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,16 @@ export default class AbstractTTSEngine {
// Chrome Android was returning voice languages like `en_US` instead of `en-US`
const matchingVoices = voices.filter(v => v.lang.replace('_', '-').startsWith(lang));
if (matchingVoices.length) {
return matchingVoices.find(v => v.default) || matchingVoices[0];
return (
// Prefer Microsoft 'Natural' voices
matchingVoices.find(v => v.voiceURI.match(/Microsoft.*\(Natural\)/g))
// Prefer Google voices
|| matchingVoices.find(v => v.voiceURI.match(/Google/g))
// Prefer default if one is specified. This seems to be kind of random though,
// and is usually one of the lower quality voices.
|| matchingVoices.find(v => v.default)
|| matchingVoices[0]
);
}
}
}
Expand Down

0 comments on commit 422aade

Please sign in to comment.