Try not to return bad voices by random

This commit is contained in:
Brandon Thomas committed 2023-01-30 20:05:31 -05:00
1 parent fab8b14bec
commit c5aa6529a9
1 file changed
+11 -2
@@ -50,8 +50,17 @@ export function VoiceCountLabel(props: Props) {
});
const selectRandomVoice = () => {
// TODO: Prefer to select a random *good* voice or *popular* voice.
const randomVoice = GetRandomArrayValue(possibleVoices);
let randomVoice = undefined;
for (let i = 0; i < 10; i++) {
// We're going to try to find a *good* voice.
randomVoice = GetRandomArrayValue(possibleVoices);
if (randomVoice.user_ratings.positive_count > randomVoice.user_ratings.negative_count) {
break; // First "mostly good" voice is good.
}
if (i % 3 === 2 && randomVoice.user_ratings.total_count === 0) {
break; // Sometimes we'll return a voice that hasn't been rated.
}
}
if (randomVoice !== undefined) {
props.setMaybeSelectedTtsModel(randomVoice);
}