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
cooldoomsday
2023-05-06 10:20:46 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2023-05-06 10:20:46 +0800
Commit
0bc571f6ee25338cc9c295e11d8de9c87e072cff
0bc571f6
1 parent
8ce6fff9
Return timestamp info and tokens in offline ASR
Co-authored-by: zhangbaofeng@npnets.com <41259@Zbf>
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
14 行增加
和
4 行删除
sherpa-onnx/csrc/offline-stream.cc
sherpa-onnx/csrc/offline-stream.h
sherpa-onnx/csrc/offline-websocket-server-impl.cc
sherpa-onnx/csrc/sherpa-onnx-offline.cc
sherpa-onnx/csrc/offline-stream.cc
查看文件 @
0bc571f
...
...
@@ -8,7 +8,7 @@
#include <algorithm>
#include <cmath>
#include "nlohmann/json.hpp"
#include "kaldi-native-fbank/csrc/online-feature.h"
#include "sherpa-onnx/csrc/macros.h"
#include "sherpa-onnx/csrc/offline-recognizer.h"
...
...
@@ -214,5 +214,12 @@ void OfflineStream::SetResult(const OfflineRecognitionResult &r) {
const
OfflineRecognitionResult
&
OfflineStream
::
GetResult
()
const
{
return
impl_
->
GetResult
();
}
std
::
string
OfflineRecognitionResult
::
AsJsonString
()
const
{
nlohmann
::
json
j
;
j
[
"text"
]
=
text
;
j
[
"tokens"
]
=
tokens
;
j
[
"timestamps"
]
=
timestamps
;
return
j
.
dump
();
}
}
// namespace sherpa_onnx
...
...
sherpa-onnx/csrc/offline-stream.h
查看文件 @
0bc571f
...
...
@@ -27,6 +27,8 @@ struct OfflineRecognitionResult {
/// timestamps.size() == tokens.size()
/// timestamps[i] records the time in seconds when tokens[i] is decoded.
std
::
vector
<
float
>
timestamps
;
std
::
string
AsJsonString
()
const
;
};
struct
OfflineFeatureExtractorConfig
{
...
...
sherpa-onnx/csrc/offline-websocket-server-impl.cc
查看文件 @
0bc571f
...
...
@@ -100,10 +100,11 @@ void OfflineWebsocketDecoder::Decode() {
for
(
int32_t
i
=
0
;
i
!=
size
;
++
i
)
{
connection_hdl
hdl
=
handles
[
i
];
asio
::
post
(
server_
->
GetConnectionContext
(),
[
this
,
hdl
,
text
=
ss
[
i
]
->
GetResult
().
text
]()
{
[
this
,
hdl
,
result
=
ss
[
i
]
->
GetResult
()
]()
{
websocketpp
::
lib
::
error_code
ec
;
server_
->
GetServer
().
send
(
hdl
,
text
,
websocketpp
::
frame
::
opcode
::
text
,
ec
);
hdl
,
result
.
AsJsonString
(),
websocketpp
::
frame
::
opcode
::
text
,
ec
);
if
(
ec
)
{
server_
->
GetServer
().
get_alog
().
write
(
websocketpp
::
log
::
alevel
::
app
,
ec
.
message
());
...
...
sherpa-onnx/csrc/sherpa-onnx-offline.cc
查看文件 @
0bc571f
...
...
@@ -101,7 +101,7 @@ for a list of pre-trained models to download.
fprintf
(
stderr
,
"Done!
\n\n
"
);
for
(
int32_t
i
=
1
;
i
<=
po
.
NumArgs
();
++
i
)
{
fprintf
(
stderr
,
"%s
\n
%s
\n
----
\n
"
,
po
.
GetArg
(
i
).
c_str
(),
ss
[
i
-
1
]
->
GetResult
().
text
.
c_str
());
ss
[
i
-
1
]
->
GetResult
().
AsJsonString
()
.
c_str
());
}
float
elapsed_seconds
=
...
...
请
注册
或
登录
后发表评论