Skip to content

Commit

Permalink
rev
Browse files Browse the repository at this point in the history
  • Loading branch information
ksyeo1010 committed Aug 9, 2023
1 parent e63679f commit ee61510
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions binding/unity/Assets/Porcupine/PorcupineManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ private PorcupineManager(Porcupine porcupine, Action<int> wakeWordCallback, Acti
_porcupine = porcupine;
_wakeWordCallback = wakeWordCallback;
_processErrorCallback = processErrorCallback;

VoiceProcessor.Instance.AddFrameListener(OnFrameCaptured);
}

/// <summary>
Expand Down Expand Up @@ -126,6 +124,7 @@ public void Start()
{
throw new ObjectDisposedException("Porcupine", "Cannot start PorcupineManager - resources have already been released");
}
VoiceProcessor.Instance.AddFrameListener(OnFrameCaptured);
VoiceProcessor.Instance.StartRecording(_porcupine.FrameLength, _porcupine.SampleRate);
}

Expand All @@ -138,22 +137,20 @@ public void Stop()
{
throw new ObjectDisposedException("Porcupine", "Stop called after PorcupineManager resources were released.");
}
VoiceProcessor.Instance.StopRecording();
VoiceProcessor.Instance.RemoveFrameListener(OnFrameCaptured);
if (VoiceProcessor.Instance.NumFrameListeners == 0) {
VoiceProcessor.Instance.StopRecording();
}
}

/// <summary>
/// Free resources that were allocated to Porcupine and the voice processor
/// </summary>
public void Delete()
{
VoiceProcessor.Instance.RemoveFrameListener(OnFrameCaptured);
if (VoiceProcessor.Instance.IsRecording)
{
VoiceProcessor.Instance.StopRecording();
}

if (_porcupine != null)
{
Stop();
_porcupine.Dispose();
_porcupine = null;
}
Expand Down
Binary file not shown.
Binary file removed binding/unity/porcupine-2.2.1.unitypackage
Binary file not shown.
Binary file modified binding/unity/porcupine-2.2.2-Apple-silicon.unitypackage
Binary file not shown.
Binary file modified binding/unity/porcupine-2.2.2.unitypackage
Binary file not shown.

0 comments on commit ee61510

Please sign in to comment.