updateLocale method
Implementation
Future<void> updateLocale(String newLocale) async {
if (newLocale != _currentLocaleId) {
// Stop any ongoing speech recognition
if (_speechListening) {
_stopListening();
}
setState(() {
_currentLocaleId = newLocale;
});
// Reinitialize speech service with new locale
try {
await _speechService.updateLocale(newLocale);
print("Speech service updated with new locale: $newLocale");
} catch (e) {
print("Error updating speech service locale: $e");
}
}
}