process method
Process a frame of audio with the wake word engine.
frame
is a frame of frame of audio samples to be assessed by Porcupine. The required audio format is found by
calling .sampleRate
to get the required sample rate and .frameLength
to get the required frame size.
Audio must be single-channel and 16-bit linearly-encoded.
Index of the detected keyword, or -1 if no detection occurred
Implementation
Future<int> process(List<int>? frame) async {
try {
int keywordIndex = await _channel
.invokeMethod('process', {'handle': _handle, 'frame': frame});
return keywordIndex;
} on PlatformException catch (error) {
throw porcupineStatusToException(error.code, error.message);
} on Exception catch (error) {
throw porcupineStatusToException("PorcupineException", error.toString());
}
}