コード例 #1
0
ファイル: RhinoManager.cs プロジェクト: yyht/rhino
        /// <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());
                }
            }
        }
コード例 #2
0
 /// <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();
 }
コード例 #3
0
ファイル: PorcupineManager.cs プロジェクト: xzw168/porcupine
 /// <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();
 }
コード例 #4
0
        /// <summary>
        /// Stops audio capture and Picovoice processing
        /// </summary>
        public void Stop()
        {
            if (_voiceProcessor.IsRecording)
            {
                _voiceProcessor.StopRecording();
            }
            _voiceProcessor.OnFrameCaptured -= OnFrameCaptured;

            _picovoice?.Dispose();
            _picovoice = null;
        }