Prefer natural voices for read aloud
Rank platform voice quality and select the most natural automatic voice while keeping explicit voice choices intact. Surface natural labels, hide novelty voices in the picker, and guide Apple users to download enhanced voices when needed.
This commit is contained in:
@@ -165,4 +165,37 @@ void main() {
|
||||
expect(speech.rate, defaultSpeechRate);
|
||||
expect(store.saved, (rate: defaultSpeechRate, voice: null));
|
||||
});
|
||||
|
||||
testWidgets('an explicitly selected voice does not require voice inventory', (
|
||||
tester,
|
||||
) async {
|
||||
engine = FakeSpeechEngine(voiceFailure: true);
|
||||
reader();
|
||||
const voice = SpeechVoice(name: 'Daniel', locale: 'en-GB');
|
||||
|
||||
// The saved selection is passed directly to the engine, even if querying
|
||||
// the platform voice inventory is unavailable.
|
||||
await speech.setVoice(voice);
|
||||
await speech.read('a', ['Hello']);
|
||||
|
||||
expect(engine.voice, voice);
|
||||
expect(engine.spoken, ['Hello']);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'automatic voice selects the most natural device-language voice',
|
||||
(tester) async {
|
||||
engine = FakeSpeechEngine(
|
||||
available: const [
|
||||
SpeechVoice(name: 'Compact', locale: 'en-US', qualityRank: 1),
|
||||
SpeechVoice(name: 'Enhanced', locale: 'en-US', qualityRank: 2),
|
||||
SpeechVoice(name: 'French Natural', locale: 'fr-FR', qualityRank: 3),
|
||||
],
|
||||
);
|
||||
reader();
|
||||
await speech.read('a', ['Hello']);
|
||||
expect(engine.voice?.name, 'Enhanced');
|
||||
expect(speech.voice, isNull);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user