stopStreamingAudio method

Future<void> stopStreamingAudio()

Stops streaming audio data to the WebSocket server.

This method cancels the audio stream subscription, stops the audio recorder, and sets the serving audio flag to false.

Implementation

Future<void> stopStreamingAudio() async {
  await _audioSubscription?.cancel(); // Cancel the audio stream subscription
  await _record.stop(); // Stop the audio recorder
  _isServingAudio = false; // Update the flag to indicate streaming has stopped
  debugPrint('Audio streaming stopped'); // Log the stop event
}