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-23 09:26:36 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2024-07-23 09:26:36 +0800
Commit
299f1a852bfaf4f686f7ff5dad84910c502b38dc
299f1a85
1 parent
d32a4616
Fix style issues reported by clang-tidy (#1167)
隐藏空白字符变更
内嵌
并排对比
正在显示
7 个修改的文件
包含
21 行增加
和
22 行删除
sherpa-onnx/csrc/jieba-lexicon.cc
sherpa-onnx/csrc/lexicon.cc
sherpa-onnx/csrc/melo-tts-lexicon.cc
sherpa-onnx/csrc/offline-tts-character-frontend.cc
sherpa-onnx/csrc/offline-tts-frontend.h
sherpa-onnx/csrc/onnx-utils.cc
sherpa-onnx/csrc/piper-phonemize-lexicon.cc
sherpa-onnx/csrc/jieba-lexicon.cc
查看文件 @
299f1a8
...
...
@@ -102,13 +102,13 @@ class JiebaLexicon::Impl {
this_sentence
.
push_back
(
blank
);
if
(
w
==
"。"
||
w
==
"!"
||
w
==
"?"
||
w
==
","
)
{
ans
.
push
_back
(
std
::
move
(
this_sentence
));
ans
.
emplace
_back
(
std
::
move
(
this_sentence
));
this_sentence
=
{};
}
}
// for (const auto &w : words)
if
(
!
this_sentence
.
empty
())
{
ans
.
push
_back
(
std
::
move
(
this_sentence
));
ans
.
emplace
_back
(
std
::
move
(
this_sentence
));
}
return
ans
;
...
...
sherpa-onnx/csrc/lexicon.cc
查看文件 @
299f1a8
...
...
@@ -253,7 +253,7 @@ std::vector<TokenIDs> Lexicon::ConvertTextToTokenIdsChinese(
if
(
eos
!=
-
1
)
{
this_sentence
.
push_back
(
eos
);
}
ans
.
push
_back
(
std
::
move
(
this_sentence
));
ans
.
emplace
_back
(
std
::
move
(
this_sentence
));
this_sentence
=
{};
if
(
sil
!=
-
1
)
{
...
...
@@ -283,7 +283,7 @@ std::vector<TokenIDs> Lexicon::ConvertTextToTokenIdsChinese(
if
(
eos
!=
-
1
)
{
this_sentence
.
push_back
(
eos
);
}
ans
.
push
_back
(
std
::
move
(
this_sentence
));
ans
.
emplace
_back
(
std
::
move
(
this_sentence
));
return
ans
;
}
...
...
@@ -324,7 +324,7 @@ std::vector<TokenIDs> Lexicon::ConvertTextToTokenIdsNotChinese(
if
(
w
!=
","
)
{
this_sentence
.
push_back
(
blank
);
ans
.
push
_back
(
std
::
move
(
this_sentence
));
ans
.
emplace
_back
(
std
::
move
(
this_sentence
));
this_sentence
=
{};
}
...
...
@@ -348,7 +348,7 @@ std::vector<TokenIDs> Lexicon::ConvertTextToTokenIdsNotChinese(
}
if
(
!
this_sentence
.
empty
())
{
ans
.
push
_back
(
std
::
move
(
this_sentence
));
ans
.
emplace
_back
(
std
::
move
(
this_sentence
));
}
return
ans
;
...
...
sherpa-onnx/csrc/melo-tts-lexicon.cc
查看文件 @
299f1a8
...
...
@@ -91,7 +91,6 @@ class MeloTtsLexicon::Impl {
std
::
vector
<
TokenIDs
>
ans
;
TokenIDs
this_sentence
;
int32_t
blank
=
token2id_
.
at
(
"_"
);
for
(
const
auto
&
w
:
words
)
{
auto
ids
=
ConvertWordToIds
(
w
);
if
(
ids
.
tokens
.
empty
())
{
...
...
sherpa-onnx/csrc/offline-tts-character-frontend.cc
查看文件 @
299f1a8
...
...
@@ -136,7 +136,7 @@ std::vector<TokenIDs> OfflineTtsCharacterFrontend::ConvertTextToTokenIds(
this_sentence
.
push_back
(
eos_id
);
}
ans
.
push
_back
(
std
::
move
(
this_sentence
));
ans
.
emplace
_back
(
std
::
move
(
this_sentence
));
this_sentence
=
{};
// re-initialize this_sentence
...
...
@@ -152,7 +152,7 @@ std::vector<TokenIDs> OfflineTtsCharacterFrontend::ConvertTextToTokenIds(
}
if
(
static_cast
<
int32_t
>
(
this_sentence
.
size
())
>
1
+
use_eos_bos
)
{
ans
.
push
_back
(
std
::
move
(
this_sentence
));
ans
.
emplace
_back
(
std
::
move
(
this_sentence
));
}
}
else
{
// not adding blank
...
...
@@ -171,7 +171,7 @@ std::vector<TokenIDs> OfflineTtsCharacterFrontend::ConvertTextToTokenIds(
this_sentence
.
push_back
(
eos_id
);
}
ans
.
push
_back
(
std
::
move
(
this_sentence
));
ans
.
emplace
_back
(
std
::
move
(
this_sentence
));
this_sentence
=
{};
// re-initialize this_sentence
...
...
@@ -182,7 +182,7 @@ std::vector<TokenIDs> OfflineTtsCharacterFrontend::ConvertTextToTokenIds(
}
if
(
this_sentence
.
size
()
>
1
)
{
ans
.
push
_back
(
std
::
move
(
this_sentence
));
ans
.
emplace
_back
(
std
::
move
(
this_sentence
));
}
}
...
...
sherpa-onnx/csrc/offline-tts-frontend.h
查看文件 @
299f1a8
...
...
@@ -15,12 +15,12 @@ namespace sherpa_onnx {
struct
TokenIDs
{
TokenIDs
()
=
default
;
/*implicit*/
TokenIDs
(
const
std
::
vector
<
int64_t
>
&
tokens
)
// NOLINT
:
tokens
{
tokens
}
{}
/*implicit*/
TokenIDs
(
std
::
vector
<
int64_t
>
tokens
)
// NOLINT
:
tokens
{
std
::
move
(
tokens
)}
{}
TokenIDs
(
const
std
::
vector
<
int64_t
>
&
tokens
,
const
std
::
vector
<
int64_t
>
&
tones
)
:
tokens
{
tokens
},
tones
{
tones
}
{}
TokenIDs
(
std
::
vector
<
int64_t
>
tokens
,
// NOLINT
std
::
vector
<
int64_t
>
tones
)
// NOLINT
:
tokens
{
std
::
move
(
tokens
)},
tones
{
std
::
move
(
tones
)}
{}
std
::
string
ToString
()
const
;
...
...
sherpa-onnx/csrc/onnx-utils.cc
查看文件 @
299f1a8
...
...
@@ -157,8 +157,8 @@ Ort::Value View(Ort::Value *v) {
float
ComputeSum
(
const
Ort
::
Value
*
v
,
int32_t
n
/*= -1*/
)
{
std
::
vector
<
int64_t
>
shape
=
v
->
GetTensorTypeAndShapeInfo
().
GetShape
();
auto
size
=
static_cast
<
int32_t
>
(
std
::
accumulate
(
shape
.
begin
(),
shape
.
end
(),
1
,
std
::
multiplies
<
int64_t
>
()));
auto
size
=
static_cast
<
int32_t
>
(
std
::
accumulate
(
shape
.
begin
(),
shape
.
end
(),
1
,
std
::
multiplies
<>
()));
if
(
n
!=
-
1
&&
n
<
size
&&
n
>
0
)
{
size
=
n
;
}
...
...
@@ -170,8 +170,8 @@ float ComputeSum(const Ort::Value *v, int32_t n /*= -1*/) {
float
ComputeMean
(
const
Ort
::
Value
*
v
,
int32_t
n
/*= -1*/
)
{
std
::
vector
<
int64_t
>
shape
=
v
->
GetTensorTypeAndShapeInfo
().
GetShape
();
auto
size
=
static_cast
<
int32_t
>
(
std
::
accumulate
(
shape
.
begin
(),
shape
.
end
(),
1
,
std
::
multiplies
<
int64_t
>
()));
auto
size
=
static_cast
<
int32_t
>
(
std
::
accumulate
(
shape
.
begin
(),
shape
.
end
(),
1
,
std
::
multiplies
<>
()));
if
(
n
!=
-
1
&&
n
<
size
&&
n
>
0
)
{
size
=
n
;
...
...
sherpa-onnx/csrc/piper-phonemize-lexicon.cc
查看文件 @
299f1a8
...
...
@@ -239,12 +239,12 @@ std::vector<TokenIDs> PiperPhonemizeLexicon::ConvertTextToTokenIds(
if
(
meta_data_
.
is_piper
||
meta_data_
.
is_icefall
)
{
for
(
const
auto
&
p
:
phonemes
)
{
phoneme_ids
=
PiperPhonemesToIds
(
token2id_
,
p
);
ans
.
push
_back
(
std
::
move
(
phoneme_ids
));
ans
.
emplace
_back
(
std
::
move
(
phoneme_ids
));
}
}
else
if
(
meta_data_
.
is_coqui
)
{
for
(
const
auto
&
p
:
phonemes
)
{
phoneme_ids
=
CoquiPhonemesToIds
(
token2id_
,
p
,
meta_data_
);
ans
.
push
_back
(
std
::
move
(
phoneme_ids
));
ans
.
emplace
_back
(
std
::
move
(
phoneme_ids
));
}
}
else
{
...
...
请
注册
或
登录
后发表评论