process method
Process a frame of pcm audio with the speech-to-text engine.
frame
frame of 16-bit integers of 16kHz linear PCM mono audio.
The specific array length is obtained from Cheetah via the frameLength field.
returns CheetahTranscript object.
Implementation
Future<CheetahTranscript> process(List<int>? frame) async {
try {
Map<String, dynamic> transcript = Map<String, dynamic>.from(await _channel
.invokeMethod(_NativeFunctions.PROCESS.name,
{'handle': _handle, 'frame': frame}));
if (transcript['transcript'] == null) {
throw CheetahInvalidStateException(
"field 'transcript' must be always present");
}
return CheetahTranscript(
transcript['transcript'], transcript['isEndpoint']);
} on PlatformException catch (error) {
throw cheetahStatusToException(error.code, error.message);
} on Exception catch (error) {
throw CheetahException(error.toString());
}
}