I use the flutter_tts plugin in a little Flutter app. It worked but now (since I upgraded Xcode?), text to speech does not work anymore in IOS Simulator.
I upgraded Xcode to Xcode 15 and use the IOS 17.0 simulator.
My code:
@override
void initState() {
// TODO: implement initState
getLanguages();
getVoices();
initTts();
choixQuestion();
super.initState();
}
with
void initTts()async {
await flutterTts.setVolume(1.0);
await flutterTts.setPitch(1.0);
await flutterTts.setSpeechRate(1.0);
await flutterTts.setLanguage("fr-FR");
await flutterTts.setIosAudioCategory(IosTextToSpeechAudioCategory.playback, [
IosTextToSpeechAudioCategoryOptions.defaultToSpeaker
]);
}
Future getLanguages() async {
languages = List<String>.from(await flutterTts.getLanguages);
for(var element in languages!){
print(element);
}
}
Future getVoices() async {
voices = List<Object>.from(await flutterTts.getVoices);
for(var element in voices!){
print(element);
}
}
void lectureQuestion(question)async {
await flutterTts.speak(question);
await flutterTts.awaitSpeakCompletion(true);
setState(() {
premierBuild = false;
});
}
and
Future<void> choixQuestion()async{
await onPrendListeQuestion(); // On charge les questions de la variable questionQuelquechose (qui avait été populée dans homepage) dans la variable questionnaire
numeroQuestion = Random().nextInt(questionnaire.keys.length);
print("longueur questionnaire avant : ${questionnaire.keys.length}");
setState(() {
question = questionnaire.keys.elementAt(numeroQuestion);
reponse = questionnaire.values.elementAt(numeroQuestion);
questionnaire.remove(question);
nombreQuestion = nombreQuestion + 1;
});
await onAdapteQuestionnaireBase(); // On efface la variable questionQqchose et on la re-rempli avec la variable questionnaire
lectureQuestion(question);
print("longueur questionnaire après : ${questionnaire.keys.length}");
}
It works with the Android simulator but not with the iOS simulator.
I red what follows on GitHub:
You need to download languages for it to work inside of simulators.
For IOS 16 simulator, go settings -> Spoken content -> Voices ->
Select any language and download.
But don’t find Spoken content on the IOS 17 simulator.
Thanks for your Help !




