flutter: add lang, emotion, event to OfflineRecognizerResult (#1268)
This commit is contained in:
committed by
GitHub
parent
88809753ab
commit
8c087d9110
@@ -186,16 +186,24 @@ class OfflineRecognizerConfig {
|
|||||||
|
|
||||||
class OfflineRecognizerResult {
|
class OfflineRecognizerResult {
|
||||||
OfflineRecognizerResult(
|
OfflineRecognizerResult(
|
||||||
{required this.text, required this.tokens, required this.timestamps});
|
{required this.text,
|
||||||
|
required this.tokens,
|
||||||
|
required this.timestamps,
|
||||||
|
required this.lang,
|
||||||
|
required this.emotion,
|
||||||
|
required this.event});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineRecognizerResult(text: $text, tokens: $tokens, timestamps: $timestamps)';
|
return 'OfflineRecognizerResult(text: $text, tokens: $tokens, timestamps: $timestamps, lang: $lang, emotion: $emotion, event: $event)';
|
||||||
}
|
}
|
||||||
|
|
||||||
final String text;
|
final String text;
|
||||||
final List<String> tokens;
|
final List<String> tokens;
|
||||||
final List<double> timestamps;
|
final List<double> timestamps;
|
||||||
|
final String lang;
|
||||||
|
final String emotion;
|
||||||
|
final String event;
|
||||||
}
|
}
|
||||||
|
|
||||||
class OfflineRecognizer {
|
class OfflineRecognizer {
|
||||||
@@ -319,7 +327,13 @@ class OfflineRecognizer {
|
|||||||
SherpaOnnxBindings.getOfflineStreamResultAsJson?.call(stream.ptr) ??
|
SherpaOnnxBindings.getOfflineStreamResultAsJson?.call(stream.ptr) ??
|
||||||
nullptr;
|
nullptr;
|
||||||
if (json == nullptr) {
|
if (json == nullptr) {
|
||||||
return OfflineRecognizerResult(text: '', tokens: [], timestamps: []);
|
return OfflineRecognizerResult(
|
||||||
|
text: '',
|
||||||
|
tokens: [],
|
||||||
|
timestamps: [],
|
||||||
|
lang: '',
|
||||||
|
emotion: '',
|
||||||
|
event: '');
|
||||||
}
|
}
|
||||||
|
|
||||||
final parsedJson = jsonDecode(toDartString(json));
|
final parsedJson = jsonDecode(toDartString(json));
|
||||||
@@ -329,7 +343,10 @@ class OfflineRecognizer {
|
|||||||
return OfflineRecognizerResult(
|
return OfflineRecognizerResult(
|
||||||
text: parsedJson['text'],
|
text: parsedJson['text'],
|
||||||
tokens: List<String>.from(parsedJson['tokens']),
|
tokens: List<String>.from(parsedJson['tokens']),
|
||||||
timestamps: List<double>.from(parsedJson['timestamps']));
|
timestamps: List<double>.from(parsedJson['timestamps']),
|
||||||
|
lang: parsedJson['lang'],
|
||||||
|
emotion: parsedJson['emotion'],
|
||||||
|
event: parsedJson['event']);
|
||||||
}
|
}
|
||||||
|
|
||||||
Pointer<SherpaOnnxOfflineRecognizer> ptr;
|
Pointer<SherpaOnnxOfflineRecognizer> ptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user