Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
e1fc57de
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
11 个月 前同步成功
通知
204
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,发现更多精彩内容 >>
提交
e1fc57de
编写于
10月 09, 2022
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add math and rename ds2 nnet
上级
75c57880
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
42 addition
and
27 deletion
+42
-27
speechx/speechx/base/common.h
speechx/speechx/base/common.h
+5
-0
speechx/speechx/decoder/ctc_prefix_beam_search_decoder_main.cc
...hx/speechx/decoder/ctc_prefix_beam_search_decoder_main.cc
+1
-1
speechx/speechx/decoder/recognizer.h
speechx/speechx/decoder/recognizer.h
+1
-1
speechx/speechx/decoder/tlg_decoder_main.cc
speechx/speechx/decoder/tlg_decoder_main.cc
+1
-1
speechx/speechx/nnet/CMakeLists.txt
speechx/speechx/nnet/CMakeLists.txt
+3
-5
speechx/speechx/nnet/ds2_nnet.cc
speechx/speechx/nnet/ds2_nnet.cc
+1
-1
speechx/speechx/nnet/ds2_nnet.h
speechx/speechx/nnet/ds2_nnet.h
+0
-0
speechx/speechx/nnet/ds2_nnet_main.cc
speechx/speechx/nnet/ds2_nnet_main.cc
+1
-1
speechx/speechx/utils/math.cc
speechx/speechx/utils/math.cc
+23
-14
speechx/speechx/utils/math.h
speechx/speechx/utils/math.h
+6
-3
未找到文件。
speechx/speechx/base/common.h
浏览文件 @
e1fc57de
...
...
@@ -14,19 +14,24 @@
#pragma once
#include <algorithm>
#include <condition_variable>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <istream>
#include <map>
#include <memory>
#include <mutex>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <thread>
#include <unordered_map>
...
...
speechx/speechx/decoder/ctc_prefix_beam_search_decoder_main.cc
浏览文件 @
e1fc57de
...
...
@@ -20,7 +20,7 @@
#include "frontend/audio/data_cache.h"
#include "kaldi/util/table-types.h"
#include "nnet/decodable.h"
#include "nnet/
paddle
_nnet.h"
#include "nnet/
ds2
_nnet.h"
DEFINE_string
(
feature_rspecifier
,
""
,
"test feature rspecifier"
);
DEFINE_string
(
result_wspecifier
,
""
,
"test result wspecifier"
);
...
...
speechx/speechx/decoder/recognizer.h
浏览文件 @
e1fc57de
...
...
@@ -20,7 +20,7 @@
#include "decoder/ctc_tlg_decoder.h"
#include "frontend/audio/feature_pipeline.h"
#include "nnet/decodable.h"
#include "nnet/
paddle
_nnet.h"
#include "nnet/
ds2
_nnet.h"
namespace
ppspeech
{
...
...
speechx/speechx/decoder/tlg_decoder_main.cc
浏览文件 @
e1fc57de
...
...
@@ -20,7 +20,7 @@
#include "frontend/audio/data_cache.h"
#include "kaldi/util/table-types.h"
#include "nnet/decodable.h"
#include "nnet/
paddle
_nnet.h"
#include "nnet/
ds2
_nnet.h"
DEFINE_string
(
feature_rspecifier
,
""
,
"test feature rspecifier"
);
DEFINE_string
(
result_wspecifier
,
""
,
"test result wspecifier"
);
...
...
speechx/speechx/nnet/CMakeLists.txt
浏览文件 @
e1fc57de
...
...
@@ -2,13 +2,11 @@ project(nnet)
add_library
(
nnet STATIC
decodable.cc
paddle
_nnet.cc
ds2
_nnet.cc
)
target_link_libraries
(
nnet absl::strings
)
set
(
bin_name
nnet_forward
_main
)
set
(
bin_name
ds2_nnet
_main
)
add_executable
(
${
bin_name
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
bin_name
}
.cc
)
target_include_directories
(
${
bin_name
}
PRIVATE
${
SPEECHX_ROOT
}
${
SPEECHX_ROOT
}
/kaldi
)
target_link_libraries
(
${
bin_name
}
utils kaldi-util kaldi-matrix gflags glog nnet
${
DEPS
}
)
target_link_libraries
(
${
bin_name
}
utils kaldi-util kaldi-matrix gflags glog nnet
${
DEPS
}
)
\ No newline at end of file
speechx/speechx/nnet/
paddle
_nnet.cc
→
speechx/speechx/nnet/
ds2
_nnet.cc
浏览文件 @
e1fc57de
...
...
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "nnet/
paddle
_nnet.h"
#include "nnet/
ds2
_nnet.h"
#include "absl/strings/str_split.h"
namespace
ppspeech
{
...
...
speechx/speechx/nnet/
paddle
_nnet.h
→
speechx/speechx/nnet/
ds2
_nnet.h
浏览文件 @
e1fc57de
文件已移动
speechx/speechx/nnet/
nnet_forward
_main.cc
→
speechx/speechx/nnet/
ds2_nnet
_main.cc
浏览文件 @
e1fc57de
...
...
@@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "nnet/ds2_nnet.h"
#include "base/flags.h"
#include "base/log.h"
#include "frontend/audio/assembler.h"
#include "frontend/audio/data_cache.h"
#include "kaldi/util/table-types.h"
#include "nnet/decodable.h"
#include "nnet/paddle_nnet.h"
DEFINE_string
(
feature_rspecifier
,
""
,
"test feature rspecifier"
);
DEFINE_string
(
nnet_prob_wspecifier
,
""
,
"nnet porb wspecifier"
);
...
...
speechx/speechx/utils/math.cc
浏览文件 @
e1fc57de
// Copyright (c) 2021 Mobvoi Inc (Zhendong Peng)
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
...
...
@@ -17,10 +18,10 @@
#include "base/common.h"
#include <cmath>
#include <algorithm>
#include <
utility
>
#include <
cmath
>
#include <queue>
#include <utility>
namespace
ppspeech
{
...
...
@@ -36,28 +37,36 @@ float LogSumExp(float x, float y) {
// greater compare for smallest priority_queue
template
<
typename
T
>
struct
ValGreaterComp
{
bool
operator
()(
const
std
::
pair
<
T
,
int32_t
>&
lhs
,
const
std
::
pair
<
T
,
int32_
>&
rhs
)
const
{
return
lhs
.
first
>
rhs
.
first
||
(
lhs
.
first
==
rhs
.
first
&&
lhs
.
second
<
rhs
.
second
);
bool
operator
()(
const
std
::
pair
<
T
,
int32_t
>&
lhs
,
const
std
::
pair
<
T
,
int32_
>&
rhs
)
const
{
return
lhs
.
first
>
rhs
.
first
||
(
lhs
.
first
==
rhs
.
first
&&
lhs
.
second
<
rhs
.
second
);
}
}
template
<
typename
T
>
void
TopK
(
const
std
::
vector
<
T
>&
data
,
int32_t
k
,
std
::
vector
<
T
>*
values
,
std
::
vector
<
int
>*
indices
)
{
int
n
=
data
.
size
();
int
min_k_n
=
std
::
min
(
k
,
n
);
template
<
typename
T
>
void
TopK
(
const
std
::
vector
<
T
>&
data
,
int32_t
k
,
std
::
vector
<
T
>*
values
,
std
::
vector
<
int
>*
indices
)
{
int
n
=
data
.
size
();
int
min_k_n
=
std
::
min
(
k
,
n
);
// smallest heap, (val, idx)
std
::
vector
<
std
::
pair
<
T
,
int32_t
>>
smallest_heap
;
for
(
int
i
=
0
;
i
<
min_k_n
;
i
++
){
std
::
vector
<
std
::
pair
<
T
,
int32_t
>>
smallest_heap
;
for
(
int
i
=
0
;
i
<
min_k_n
;
i
++
)
{
smallest_heap
.
emplace_back
(
data
[
i
],
i
);
}
// smallest priority_queue
std
::
priority_queue
<
std
::
pair
<
T
,
int32_t
>
,
std
::
vector
<
std
::
pair
<
T
,
int32_t
>>
,
ValGreaterComp
<
T
>>
pq
(
ValGreaterComp
<
T
>
(),
std
::
move
(
smallest_heap
));
std
::
priority_queue
<
std
::
pair
<
T
,
int32_t
>
,
std
::
vector
<
std
::
pair
<
T
,
int32_t
>>
,
ValGreaterComp
<
T
>>
pq
(
ValGreaterComp
<
T
>
(),
std
::
move
(
smallest_heap
));
// top k
for
(
int
i
=
k
;
i
<
n
;
i
++
)
{
if
(
pq
.
top
().
first
<
data
[
i
]){
for
(
int
i
=
k
;
i
<
n
;
i
++
)
{
if
(
pq
.
top
().
first
<
data
[
i
])
{
pq
.
pop
();
pq
.
emplace_back
(
data
[
i
],
i
);
}
...
...
@@ -68,7 +77,7 @@ void TopK(const std::vector<T>& data, int32_t k, std::vector<T>* values, std::ve
// from largest to samllest
int
cur
=
values
->
size
()
-
1
;
while
(
!
pq
.
empty
())
{
while
(
!
pq
.
empty
())
{
const
auto
&
item
=
pq
.
top
();
pq
.
pop
();
...
...
speechx/speechx/utils/math.h
浏览文件 @
e1fc57de
...
...
@@ -14,15 +14,18 @@
#pragma once
#include <vector>
#include <cstdint>
#include <vector>
namespace
ppspeech
{
// Sum in log scale
float
LogSumExp
(
float
x
,
float
y
);
template
<
typename
T
>
void
TopK
(
const
std
::
vector
<
T
>&
data
,
int32_t
k
,
std
::
vector
<
T
>*
values
,
std
::
vector
<
int
>*
indices
);
template
<
typename
T
>
void
TopK
(
const
std
::
vector
<
T
>&
data
,
int32_t
k
,
std
::
vector
<
T
>*
values
,
std
::
vector
<
int
>*
indices
);
}
// namespace ppspeech
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录