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
Wilson Wongso
2023-07-12 08:12:31 +0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2023-07-12 09:12:31 +0800
Commit
b2364b0374174ca67af916831fd66a8c5b5ffaf9
b2364b03
1 parent
0b5fa241
Implemented tokens and timestamps in Python API (#205)
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
12 行增加
和
1 行删除
sherpa-onnx/python/csrc/online-recognizer.cc
sherpa-onnx/python/sherpa_onnx/online_recognizer.py
sherpa-onnx/python/csrc/online-recognizer.cc
查看文件 @
b2364b0
...
...
@@ -14,7 +14,12 @@ namespace sherpa_onnx {
static
void
PybindOnlineRecognizerResult
(
py
::
module
*
m
)
{
using
PyClass
=
OnlineRecognizerResult
;
py
::
class_
<
PyClass
>
(
*
m
,
"OnlineRecognizerResult"
)
.
def_property_readonly
(
"text"
,
[](
PyClass
&
self
)
{
return
self
.
text
;
});
.
def_property_readonly
(
"text"
,
[](
PyClass
&
self
)
->
std
::
string
{
return
self
.
text
;
})
.
def_property_readonly
(
"tokens"
,
[](
PyClass
&
self
)
->
std
::
vector
<
std
::
string
>
{
return
self
.
tokens
;
})
.
def_property_readonly
(
"timestamps"
,
[](
PyClass
&
self
)
->
std
::
vector
<
float
>
{
return
self
.
timestamps
;
});
}
static
void
PybindOnlineRecognizerConfig
(
py
::
module
*
m
)
{
...
...
sherpa-onnx/python/sherpa_onnx/online_recognizer.py
查看文件 @
b2364b0
...
...
@@ -149,6 +149,12 @@ class OnlineRecognizer(object):
def
get_result
(
self
,
s
:
OnlineStream
)
->
str
:
return
self
.
recognizer
.
get_result
(
s
)
.
text
.
strip
()
def
tokens
(
self
,
s
:
OnlineStream
)
->
List
[
str
]:
return
self
.
recognizer
.
get_result
(
s
)
.
tokens
def
timestamps
(
self
,
s
:
OnlineStream
)
->
List
[
float
]:
return
self
.
recognizer
.
get_result
(
s
)
.
timestamps
def
is_endpoint
(
self
,
s
:
OnlineStream
)
->
bool
:
return
self
.
recognizer
.
is_endpoint
(
s
)
...
...
请
注册
或
登录
后发表评论