stopVoiceInteraction method

  1. @override
Future<void> stopVoiceInteraction()
override

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

@override
Future<void> stopVoiceInteraction() async {
  var status = getStatus();

  switch (status) {
    case ChatStatus.listeningToUser:
      await _stopListening();
    case ChatStatus.answeringAndSpeaking:
    case ChatStatus.speaking:
      _logger.i('Stopped AI speaking');
      _speaker?.dispose();
      _speaker = null;
    default:
      break;
  }
}