stopVoiceInteraction method
If the provider is listening to the microphone, it stops recording.
If the provider is speaking sentences from the AI, it stop speaking them.
Implementation
Future<void> stopVoiceInteraction() async {
var status = getStatus();
switch (status) {
case ChatStatus.listeningToUser:
await _stopListening();
case ChatStatus.answeringAndSpeaking:
case ChatStatus.speaking:
logger.info('Stopped AI speaking');
_speaker?.dispose();
_speaker = null;
default:
break;
}
}