Committed by
GitHub
flutter: add lang, emotion, event to OfflineRecognizerResult (#1268)
正在显示
1 个修改的文件
包含
21 行增加
和
4 行删除
| @@ -186,16 +186,24 @@ class OfflineRecognizerConfig { | @@ -186,16 +186,24 @@ class OfflineRecognizerConfig { | ||
| 186 | 186 | ||
| 187 | class OfflineRecognizerResult { | 187 | class OfflineRecognizerResult { |
| 188 | OfflineRecognizerResult( | 188 | OfflineRecognizerResult( |
| 189 | - {required this.text, required this.tokens, required this.timestamps}); | 189 | + {required this.text, |
| 190 | + required this.tokens, | ||
| 191 | + required this.timestamps, | ||
| 192 | + required this.lang, | ||
| 193 | + required this.emotion, | ||
| 194 | + required this.event}); | ||
| 190 | 195 | ||
| 191 | @override | 196 | @override |
| 192 | String toString() { | 197 | String toString() { |
| 193 | - return 'OfflineRecognizerResult(text: $text, tokens: $tokens, timestamps: $timestamps)'; | 198 | + return 'OfflineRecognizerResult(text: $text, tokens: $tokens, timestamps: $timestamps, lang: $lang, emotion: $emotion, event: $event)'; |
| 194 | } | 199 | } |
| 195 | 200 | ||
| 196 | final String text; | 201 | final String text; |
| 197 | final List<String> tokens; | 202 | final List<String> tokens; |
| 198 | final List<double> timestamps; | 203 | final List<double> timestamps; |
| 204 | + final String lang; | ||
| 205 | + final String emotion; | ||
| 206 | + final String event; | ||
| 199 | } | 207 | } |
| 200 | 208 | ||
| 201 | class OfflineRecognizer { | 209 | class OfflineRecognizer { |
| @@ -319,7 +327,13 @@ class OfflineRecognizer { | @@ -319,7 +327,13 @@ class OfflineRecognizer { | ||
| 319 | SherpaOnnxBindings.getOfflineStreamResultAsJson?.call(stream.ptr) ?? | 327 | SherpaOnnxBindings.getOfflineStreamResultAsJson?.call(stream.ptr) ?? |
| 320 | nullptr; | 328 | nullptr; |
| 321 | if (json == nullptr) { | 329 | if (json == nullptr) { |
| 322 | - return OfflineRecognizerResult(text: '', tokens: [], timestamps: []); | 330 | + return OfflineRecognizerResult( |
| 331 | + text: '', | ||
| 332 | + tokens: [], | ||
| 333 | + timestamps: [], | ||
| 334 | + lang: '', | ||
| 335 | + emotion: '', | ||
| 336 | + event: ''); | ||
| 323 | } | 337 | } |
| 324 | 338 | ||
| 325 | final parsedJson = jsonDecode(toDartString(json)); | 339 | final parsedJson = jsonDecode(toDartString(json)); |
| @@ -329,7 +343,10 @@ class OfflineRecognizer { | @@ -329,7 +343,10 @@ class OfflineRecognizer { | ||
| 329 | return OfflineRecognizerResult( | 343 | return OfflineRecognizerResult( |
| 330 | text: parsedJson['text'], | 344 | text: parsedJson['text'], |
| 331 | tokens: List<String>.from(parsedJson['tokens']), | 345 | tokens: List<String>.from(parsedJson['tokens']), |
| 332 | - timestamps: List<double>.from(parsedJson['timestamps'])); | 346 | + timestamps: List<double>.from(parsedJson['timestamps']), |
| 347 | + lang: parsedJson['lang'], | ||
| 348 | + emotion: parsedJson['emotion'], | ||
| 349 | + event: parsedJson['event']); | ||
| 333 | } | 350 | } |
| 334 | 351 | ||
| 335 | Pointer<SherpaOnnxOfflineRecognizer> ptr; | 352 | Pointer<SherpaOnnxOfflineRecognizer> ptr; |
-
请 注册 或 登录 后发表评论