static void RunGame() { // init picovoice platform string keywordPath = $"pico_chess_{_platform}.ppn"; string contextPath = $"chess_{_platform}.rhn"; using Picovoice picovoice = new Picovoice(keywordPath, WakeWordCallback, contextPath, InferenceCallback); DrawBoard("\n"); // create and start recording short[] recordingBuffer = new short[picovoice.FrameLength]; ALCaptureDevice captureDevice = ALC.CaptureOpenDevice(null, picovoice.SampleRate, ALFormat.Mono16, picovoice.FrameLength * 2); { ALC.CaptureStart(captureDevice); while (!_quitGame) { int samplesAvailable = ALC.GetAvailableSamples(captureDevice); if (samplesAvailable > picovoice.FrameLength) { ALC.CaptureSamples(captureDevice, ref recordingBuffer[0], picovoice.FrameLength); picovoice.Process(recordingBuffer); } Thread.Yield(); } // stop and clean up resources Console.WriteLine("Bye!"); ALC.CaptureStop(captureDevice); ALC.CaptureCloseDevice(captureDevice); } }
public void TestProcess() { string testAudioPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "resources/audio_samples/picovoice-coffee.wav"); List <short> data = GetPcmFromFile(testAudioPath, _pv.SampleRate); int framecount = (int)Math.Floor((float)(data.Count / _pv.FrameLength)); var results = new List <int>(); for (int i = 0; i < framecount; i++) { int start = i * _pv.FrameLength; int count = _pv.FrameLength; List <short> frame = data.GetRange(start, count); _pv.Process(frame.ToArray()); } Assert.IsTrue(_isWakeWordDetected); Assert.AreEqual(_inference.Intent, "orderBeverage"); Dictionary <string, string> expectedSlotValues = new Dictionary <string, string>() { { "size", "large" }, { "beverage", "coffee" } }; Assert.IsTrue(_inference.Slots.All((keyValuePair) => expectedSlotValues.ContainsKey(keyValuePair.Key) && expectedSlotValues[keyValuePair.Key] == keyValuePair.Value)); }