process method
Process a frame of pcm audio with the speech-to-intent engine.
frame
frame of 16-bit integers of 16kHz linear PCM mono audio.
The specific array length is obtained from Rhino via the frameLength field.
returns RhinoInference object.
Implementation
Future<RhinoInference> process(List<int>? frame) async {
if (_handle == null) {
throw RhinoInvalidStateException(
"Unable to process with Rhino - resources have already been released");
}
try {
Map<String, dynamic> inference = Map<String, dynamic>.from(await _channel
.invokeMethod(_NativeFunctions.PROCESS.name, {'handle': _handle, 'frame': frame}));
if (inference['isFinalized'] == null) {
throw RhinoInvalidStateException(
"field 'isFinalized' must be always present");
}
if (inference['slots'] != null) {
inference['slots'] = Map<String, String>.from(inference['slots']);
}
return RhinoInference(inference['isFinalized'], inference['isUnderstood'],
inference['intent'], inference['slots']);
} on PlatformException catch (error) {
throw rhinoStatusToException(error.code, error.message);
} on Exception catch (error) {
throw RhinoException(error.toString());
}
}