toggle method

Toggle listening state.

Implementation

Future<TranscriptionResult?> toggle() async {
  if (_state == VoiceState.listening) {
    return stopListening();
  } else if (_state == VoiceState.idle) {
    await startListening();
    return null;
  } else if (_state == VoiceState.speaking) {
    await stopSpeaking();
    return null;
  }
  return null;
}