stop method

Future<void> stop()

Stops audio recording and processing Throws a PorcupineException if there was a problem stopping audio recording.

Implementation

Future<void> stop() async {
  if (!_isListening) {
    return;
  }

  _voiceProcessor?.removeErrorListener(_errorListener);
  _voiceProcessor?.removeFrameListener(_frameListener);

  if (_voiceProcessor?.numFrameListeners == 0) {
    try {
      await _voiceProcessor?.stop();
    } on PlatformException catch (e) {
      throw PorcupineRuntimeException(
          "Failed to stop audio recording: ${e.message}");
    }
  }

  _isListening = false;
}