Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
xuning
/
sherpaonnx
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Fangjun Kuang
2024-07-10 21:48:23 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2024-07-10 21:48:23 +0800
Commit
5a2603ff5c4315a77c7b03d88698eadbcf648d56
5a2603ff
1 parent
08c75852
Handle invalid utf8 sequence from Whisper for Dart API. (#1106)
Fixes #1104
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
33 行增加
和
2 行删除
CHANGELOG.md
flutter/sherpa_onnx/lib/src/offline_recognizer.dart
flutter/sherpa_onnx/lib/src/online_recognizer.dart
flutter/sherpa_onnx/lib/src/utils.dart
CHANGELOG.md
查看文件 @
5a2603f
## 1.10.14 (to-be-released)
*
Fix invalid utf8 sequence from Whisper for Dart API.
## 1.10.13
*
Update onnxruntime from 1.17.1 to 1.18.0
...
...
flutter/sherpa_onnx/lib/src/offline_recognizer.dart
查看文件 @
5a2603f
...
...
@@ -7,6 +7,7 @@ import 'package:ffi/ffi.dart';
import
'./feature_config.dart'
;
import
'./offline_stream.dart'
;
import
'./sherpa_onnx_bindings.dart'
;
import
'./utils.dart'
;
class
OfflineTransducerModelConfig
{
const
OfflineTransducerModelConfig
({
...
...
@@ -287,7 +288,7 @@ class OfflineRecognizer {
return
OfflineRecognizerResult
(
text:
''
,
tokens:
[],
timestamps:
[]);
}
final
parsedJson
=
jsonDecode
(
json
.
toDartString
(
));
final
parsedJson
=
jsonDecode
(
toDartString
(
json
));
SherpaOnnxBindings
.
destroyOfflineStreamResultJson
?.
call
(
json
);
...
...
flutter/sherpa_onnx/lib/src/online_recognizer.dart
查看文件 @
5a2603f
...
...
@@ -7,6 +7,7 @@ import 'package:ffi/ffi.dart';
import
'./feature_config.dart'
;
import
'./online_stream.dart'
;
import
'./sherpa_onnx_bindings.dart'
;
import
'./utils.dart'
;
class
OnlineTransducerModelConfig
{
const
OnlineTransducerModelConfig
({
...
...
@@ -268,7 +269,7 @@ class OnlineRecognizer {
return
OnlineRecognizerResult
(
text:
''
,
tokens:
[],
timestamps:
[]);
}
final
parsedJson
=
jsonDecode
(
json
.
toDartString
(
));
final
parsedJson
=
jsonDecode
(
toDartString
(
json
));
SherpaOnnxBindings
.
destroyOnlineStreamResultJson
?.
call
(
json
);
...
...
flutter/sherpa_onnx/lib/src/utils.dart
0 → 100644
查看文件 @
5a2603f
// Copyright (c) 2024 Xiaomi Corporation
import
'dart:convert'
;
import
'dart:ffi'
;
import
'dart:typed_data'
;
import
'package:ffi/ffi.dart'
;
int
_strLen
(
Pointer
<
Uint8
>
codeUnits
)
{
// this function is copied from
// https://github.com/dart-archive/ffi/blob/main/lib/src/utf8.dart#L52
var
length
=
0
;
while
(
codeUnits
[
length
]
!=
0
)
{
length
++;
}
return
length
;
}
// This function is modified from
// https://github.com/dart-archive/ffi/blob/main/lib/src/utf8.dart#L41
// It ignores invalid utf8 sequence
String
toDartString
(
Pointer
<
Utf8
>
s
)
{
final
codeUnits
=
s
.
cast
<
Uint8
>();
final
length
=
_strLen
(
codeUnits
);
return
utf8
.
decode
(
codeUnits
.
asTypedList
(
length
),
allowMalformed:
true
);
}
...
...
请
注册
或
登录
后发表评论