Merge pull request #134 from yaso-meth/QOL--Mzansi-Ai-before-loading-speech

add loading while processing speech
This commit is contained in:
yaso-meth 2025-04-09 14:55:11 +02:00 committed by GitHub
commit 65f575d92a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -500,11 +500,24 @@ class _AiChatState extends State<AiChat> {
); );
} }
static void loadingPopUp(BuildContext context) {
showDialog(
context: context,
builder: (context) {
return const Mihloadingcircle();
},
);
}
void _speakText(String text) async { void _speakText(String text) async {
try { try {
loadingPopUp(context);
await _flutterTts.stop(); // Stop any ongoing speech await _flutterTts.stop(); // Stop any ongoing speech
await _flutterTts.speak(text); // Speak the new text await _flutterTts.speak(text).then((value) {
Navigator.of(context).pop();
}); // Speak the new text
} catch (e) { } catch (e) {
Navigator.of(context).pop();
print("TTS Error: $e"); print("TTS Error: $e");
} }
} }