Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
e23b173c
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
大约 1 年 前同步成功
通知
206
Star
8425
Fork
1598
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
245
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DeepSpeech
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
245
Issue
245
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e23b173c
编写于
5月 27, 2022
作者:
Y
Yang Zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add partial result
上级
1d01c5b5
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
35 addition
and
5 deletion
+35
-5
speechx/examples/ds2_ol/websocket/websocket_server.sh
speechx/examples/ds2_ol/websocket/websocket_server.sh
+1
-1
speechx/speechx/decoder/ctc_tlg_decoder.cc
speechx/speechx/decoder/ctc_tlg_decoder.cc
+20
-0
speechx/speechx/decoder/ctc_tlg_decoder.h
speechx/speechx/decoder/ctc_tlg_decoder.h
+1
-0
speechx/speechx/decoder/recognizer.cc
speechx/speechx/decoder/recognizer.cc
+4
-0
speechx/speechx/decoder/recognizer.h
speechx/speechx/decoder/recognizer.h
+1
-0
speechx/speechx/websocket/websocket_client.cc
speechx/speechx/websocket/websocket_client.cc
+3
-0
speechx/speechx/websocket/websocket_client.h
speechx/speechx/websocket/websocket_client.h
+2
-0
speechx/speechx/websocket/websocket_client_main.cc
speechx/speechx/websocket/websocket_client_main.cc
+0
-1
speechx/speechx/websocket/websocket_server.cc
speechx/speechx/websocket/websocket_server.cc
+3
-2
speechx/speechx/websocket/websocket_server.h
speechx/speechx/websocket/websocket_server.h
+0
-1
未找到文件。
speechx/examples/ds2_ol/websocket/websocket_server.sh
浏览文件 @
e23b173c
...
...
@@ -45,7 +45,7 @@ export GLOG_logtostderr=1
# 3. gen cmvn
cmvn
=
$data
/cmvn.ark
cmvn
-json2kaldi
--json_file
=
$ckpt_dir
/data/mean_std.json
--cmvn_write_path
=
$cmvn
cmvn
_json2kaldi_main
--json_file
=
$ckpt_dir
/data/mean_std.json
--cmvn_write_path
=
$cmvn
wfst
=
$data
/wfst/
...
...
speechx/speechx/decoder/ctc_tlg_decoder.cc
浏览文件 @
e23b173c
...
...
@@ -47,6 +47,26 @@ void TLGDecoder::Reset() {
return
;
}
std
::
string
TLGDecoder
::
GetPartialResult
()
{
if
(
frame_decoded_size_
==
0
)
{
// Assertion failed: (this->NumFramesDecoded() > 0 && "You cannot call
// BestPathEnd if no frames were decoded.")
return
std
::
string
(
""
);
}
kaldi
::
Lattice
lat
;
kaldi
::
LatticeWeight
weight
;
std
::
vector
<
int
>
alignment
;
std
::
vector
<
int
>
words_id
;
decoder_
->
GetBestPath
(
&
lat
,
false
);
fst
::
GetLinearSymbolSequence
(
lat
,
&
alignment
,
&
words_id
,
&
weight
);
std
::
string
words
;
for
(
int32
idx
=
0
;
idx
<
words_id
.
size
();
++
idx
)
{
std
::
string
word
=
word_symbol_table_
->
Find
(
words_id
[
idx
]);
words
+=
word
;
}
return
words
;
}
std
::
string
TLGDecoder
::
GetFinalBestPath
()
{
if
(
frame_decoded_size_
==
0
)
{
// Assertion failed: (this->NumFramesDecoded() > 0 && "You cannot call
...
...
speechx/speechx/decoder/ctc_tlg_decoder.h
浏览文件 @
e23b173c
...
...
@@ -38,6 +38,7 @@ class TLGDecoder {
std
::
string
GetBestPath
();
std
::
vector
<
std
::
pair
<
double
,
std
::
string
>>
GetNBestPath
();
std
::
string
GetFinalBestPath
();
std
::
string
GetPartialResult
();
int
NumFrameDecoded
();
int
DecodeLikelihoods
(
const
std
::
vector
<
std
::
vector
<
BaseFloat
>>&
probs
,
std
::
vector
<
std
::
string
>&
nbest_words
);
...
...
speechx/speechx/decoder/recognizer.cc
浏览文件 @
e23b173c
...
...
@@ -44,6 +44,10 @@ std::string Recognizer::GetFinalResult() {
return
decoder_
->
GetFinalBestPath
();
}
std
::
string
Recognizer
::
GetPartialResult
()
{
return
decoder_
->
GetPartialResult
();
}
void
Recognizer
::
SetFinished
()
{
feature_pipeline_
->
SetFinished
();
input_finished_
=
true
;
...
...
speechx/speechx/decoder/recognizer.h
浏览文件 @
e23b173c
...
...
@@ -43,6 +43,7 @@ class Recognizer {
void
Accept
(
const
kaldi
::
Vector
<
kaldi
::
BaseFloat
>&
waves
);
void
Decode
();
std
::
string
GetFinalResult
();
std
::
string
GetPartialResult
();
void
SetFinished
();
bool
IsFinished
();
void
Reset
();
...
...
speechx/speechx/websocket/websocket_client.cc
浏览文件 @
e23b173c
...
...
@@ -67,6 +67,9 @@ void WebSocketClient::ReadLoopFunc() {
if
(
obj
[
"type"
]
==
"final_result"
)
{
result_
=
obj
[
"result"
].
as_string
().
c_str
();
}
if
(
obj
[
"type"
]
==
"partial_result"
)
{
partial_result_
=
obj
[
"partial_result"
].
as_string
().
c_str
();
}
if
(
obj
[
"type"
]
==
"speech_end"
)
{
done_
=
true
;
break
;
...
...
speechx/speechx/websocket/websocket_client.h
浏览文件 @
e23b173c
...
...
@@ -41,11 +41,13 @@ class WebSocketClient {
void
SendDataEnd
();
bool
Done
()
const
{
return
done_
;
}
std
::
string
GetResult
()
{
return
result_
;
}
std
::
string
GetPartialResult
()
{
return
partial_result_
;
}
private:
void
Connect
();
std
::
string
host_
;
std
::
string
result_
;
std
::
string
partial_result_
;
int
port_
;
bool
done_
=
false
;
asio
::
io_context
ioc_
;
...
...
speechx/speechx/websocket/websocket_client_main.cc
浏览文件 @
e23b173c
...
...
@@ -59,7 +59,6 @@ int main(int argc, char* argv[]) {
client
.
SendBinaryData
(
wav_chunk
.
data
(),
wav_chunk
.
size
()
*
sizeof
(
int16
));
sample_offset
+=
cur_chunk_size
;
LOG
(
INFO
)
<<
"Send "
<<
cur_chunk_size
<<
" samples"
;
std
::
this_thread
::
sleep_for
(
...
...
speechx/speechx/websocket/websocket_server.cc
浏览文件 @
e23b173c
...
...
@@ -75,9 +75,10 @@ void ConnectionHandler::OnSpeechData(const beast::flat_buffer& buffer) {
CHECK
(
recognizer_
!=
nullptr
);
recognizer_
->
Accept
(
pcm_data
);
// TODO: return lpartial result
std
::
string
partial_result
=
recognizer_
->
GetPartialResult
();
json
::
value
rv
=
{
{
"status"
,
"ok"
},
{
"type"
,
"partial_result"
},
{
"
result"
,
"TODO"
}};
{
"status"
,
"ok"
},
{
"type"
,
"partial_result"
},
{
"
partial_result"
,
partial_result
}};
ws_
.
text
(
true
);
ws_
.
write
(
asio
::
buffer
(
json
::
serialize
(
rv
)));
}
...
...
speechx/speechx/websocket/websocket_server.h
浏览文件 @
e23b173c
...
...
@@ -44,7 +44,6 @@ class ConnectionHandler {
void
OnFinish
();
void
OnSpeechData
(
const
beast
::
flat_buffer
&
buffer
);
void
OnError
(
const
std
::
string
&
message
);
void
OnPartialResult
(
const
std
::
string
&
result
);
void
OnFinalResult
(
const
std
::
string
&
result
);
void
DecodeThreadFunc
();
std
::
string
SerializeResult
(
bool
finish
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录