processAnnotated 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 CheetahTranscriptAnnotated object.
Implementation
Future<CheetahTranscriptAnnotated> processAnnotated(List<int>? frame) async {
try {
Map<String, dynamic> transcript = Map<String, dynamic>.from(await _channel
.invokeMethod(_NativeFunctions.PROCESS_ANNOTATED.name, {'handle': _handle, 'frame': frame}));
if (transcript['transcript'] == null) {
throw CheetahInvalidStateException("field 'transcript' must be always present");
} else if (transcript['words'] == null) {
throw CheetahInvalidStateException("field 'words' must be always present");
}
List<CheetahWord> words = (transcript['words'] as List).map(
(obj) {
Map<String, dynamic> word = Map<String, dynamic>.from(obj as Map);
return CheetahWord(word["word"], word["startSeconds"], word["endSeconds"], word["confidence"]);
}
).toList();
return CheetahTranscriptAnnotated(transcript['transcript'], words, transcript['isEndpoint']);
} on PlatformException catch (error) {
throw cheetahStatusToException(error.code, error.message);
} on Exception catch (error) {
throw CheetahException(error.toString());
}
}