/// <summary> /// Action to catch audio frames as voice processor produces them /// </summary> /// <param name="pcm">Frame of pcm audio</param> private void OnFrameCaptured(short[] pcm) { try { bool _isFinalized = _rhino.Process(pcm); if (_isFinalized) { Inference inference = _rhino.GetInference(); if (_inferenceCallback != null) { _inferenceCallback.Invoke(inference); } _voiceProcessor.StopRecording(); } } catch (Exception ex) { if (_errorCallback != null) { _errorCallback(ex); } else { Debug.LogError(ex.ToString()); } } }
/// <summary> /// Stops audio capture and Picovoice processing /// </summary> public void Stop() { if (_picovoice == null || _voiceProcessor == null) { throw new ObjectDisposedException("Picovoice", "Cannot start PicovoiceManager - resources have already been released"); } _voiceProcessor.StopRecording(); }
/// <summary> /// Stops audio capture and wake word detection /// </summary> public void Stop() { if (_porcupine == null || _voiceProcessor == null) { throw new ObjectDisposedException("Porcupine", "Stop called after PorcupineManager resources were released."); } _voiceProcessor.StopRecording(); }
/// <summary> /// Stops audio capture and Picovoice processing /// </summary> public void Stop() { if (_voiceProcessor.IsRecording) { _voiceProcessor.StopRecording(); } _voiceProcessor.OnFrameCaptured -= OnFrameCaptured; _picovoice?.Dispose(); _picovoice = null; }