I am working on a Flutter app that uses the TTS library.
The available voice objects returned from flutterTts.getVoices()
is device/OS specific.
In the app, for a given TTS language, I would like to give users the option to select from a set of available voices for that language.
Functional Objective: Solved for Android
When running Flutter TTS on Android, the list of voices returned are strings that indicate which language-code that a voice corresponds to. For example:
- for language-code
en-US
- there is:
en-US-language
,en-us-x-sfg#male_1-local
This built-in meta data allows to create a Map<String, List<String>>
with the following type of key/value pairs:
- key:
en-us
- value:
['en-US-language', 'en-us-x-sfg#male_1-local']
Then having this map, when user selects say English
from the list of available languages, there can be a drop down list like so:
Map<String, String> labelToVoiceMap = {
'Voice1' : 'en-US-language',
'Voice2' : 'en-us-x-sfg#male_1-local'
}
Question
When running Flutter TTS on iOS, the list of voices returned is just human names.
- For example:
Aaron
,Fred
Is there a way in Flutter to determine what the associated language is for a particular voice returned from the flutterTts
object?
Here is a post - unrelated to Flutter - describing the voice objects on an iOS device, that shows there is a field/property for language/locale code: How to get a list of ALL voices on iOS 9?
eg: [AVSpeechSynthesisVoice 0x28266fb40] Language: en-US, Name: Fred, Quality: Default [com.apple.speech.synthesis.voice.Fred]
Option 1: .. any way to get at that in Flutter?
~~ ~~~~~ ~~~~~ ~~~~~ ~~~~~ ~~~
Option 2: Alternatively - for a given name on iOS (eg, 'Fred'), if that voice is available on the current device, is there some official listing that guarantees what the associated language code will be for that voice name?