Fix style issues reported by clang-tidy (#1167)
This commit is contained in:
@@ -102,13 +102,13 @@ class JiebaLexicon::Impl {
|
|||||||
this_sentence.push_back(blank);
|
this_sentence.push_back(blank);
|
||||||
|
|
||||||
if (w == "。" || w == "!" || w == "?" || w == ",") {
|
if (w == "。" || w == "!" || w == "?" || w == ",") {
|
||||||
ans.push_back(std::move(this_sentence));
|
ans.emplace_back(std::move(this_sentence));
|
||||||
this_sentence = {};
|
this_sentence = {};
|
||||||
}
|
}
|
||||||
} // for (const auto &w : words)
|
} // for (const auto &w : words)
|
||||||
|
|
||||||
if (!this_sentence.empty()) {
|
if (!this_sentence.empty()) {
|
||||||
ans.push_back(std::move(this_sentence));
|
ans.emplace_back(std::move(this_sentence));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ans;
|
return ans;
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ std::vector<TokenIDs> Lexicon::ConvertTextToTokenIdsChinese(
|
|||||||
if (eos != -1) {
|
if (eos != -1) {
|
||||||
this_sentence.push_back(eos);
|
this_sentence.push_back(eos);
|
||||||
}
|
}
|
||||||
ans.push_back(std::move(this_sentence));
|
ans.emplace_back(std::move(this_sentence));
|
||||||
this_sentence = {};
|
this_sentence = {};
|
||||||
|
|
||||||
if (sil != -1) {
|
if (sil != -1) {
|
||||||
@@ -283,7 +283,7 @@ std::vector<TokenIDs> Lexicon::ConvertTextToTokenIdsChinese(
|
|||||||
if (eos != -1) {
|
if (eos != -1) {
|
||||||
this_sentence.push_back(eos);
|
this_sentence.push_back(eos);
|
||||||
}
|
}
|
||||||
ans.push_back(std::move(this_sentence));
|
ans.emplace_back(std::move(this_sentence));
|
||||||
|
|
||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
@@ -324,7 +324,7 @@ std::vector<TokenIDs> Lexicon::ConvertTextToTokenIdsNotChinese(
|
|||||||
|
|
||||||
if (w != ",") {
|
if (w != ",") {
|
||||||
this_sentence.push_back(blank);
|
this_sentence.push_back(blank);
|
||||||
ans.push_back(std::move(this_sentence));
|
ans.emplace_back(std::move(this_sentence));
|
||||||
this_sentence = {};
|
this_sentence = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,7 +348,7 @@ std::vector<TokenIDs> Lexicon::ConvertTextToTokenIdsNotChinese(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this_sentence.empty()) {
|
if (!this_sentence.empty()) {
|
||||||
ans.push_back(std::move(this_sentence));
|
ans.emplace_back(std::move(this_sentence));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ans;
|
return ans;
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ class MeloTtsLexicon::Impl {
|
|||||||
std::vector<TokenIDs> ans;
|
std::vector<TokenIDs> ans;
|
||||||
TokenIDs this_sentence;
|
TokenIDs this_sentence;
|
||||||
|
|
||||||
int32_t blank = token2id_.at("_");
|
|
||||||
for (const auto &w : words) {
|
for (const auto &w : words) {
|
||||||
auto ids = ConvertWordToIds(w);
|
auto ids = ConvertWordToIds(w);
|
||||||
if (ids.tokens.empty()) {
|
if (ids.tokens.empty()) {
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ std::vector<TokenIDs> OfflineTtsCharacterFrontend::ConvertTextToTokenIds(
|
|||||||
this_sentence.push_back(eos_id);
|
this_sentence.push_back(eos_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
ans.push_back(std::move(this_sentence));
|
ans.emplace_back(std::move(this_sentence));
|
||||||
this_sentence = {};
|
this_sentence = {};
|
||||||
|
|
||||||
// re-initialize 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) {
|
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 {
|
} else {
|
||||||
// not adding blank
|
// not adding blank
|
||||||
@@ -171,7 +171,7 @@ std::vector<TokenIDs> OfflineTtsCharacterFrontend::ConvertTextToTokenIds(
|
|||||||
this_sentence.push_back(eos_id);
|
this_sentence.push_back(eos_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
ans.push_back(std::move(this_sentence));
|
ans.emplace_back(std::move(this_sentence));
|
||||||
this_sentence = {};
|
this_sentence = {};
|
||||||
|
|
||||||
// re-initialize this_sentence
|
// re-initialize this_sentence
|
||||||
@@ -182,7 +182,7 @@ std::vector<TokenIDs> OfflineTtsCharacterFrontend::ConvertTextToTokenIds(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this_sentence.size() > 1) {
|
if (this_sentence.size() > 1) {
|
||||||
ans.push_back(std::move(this_sentence));
|
ans.emplace_back(std::move(this_sentence));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ namespace sherpa_onnx {
|
|||||||
struct TokenIDs {
|
struct TokenIDs {
|
||||||
TokenIDs() = default;
|
TokenIDs() = default;
|
||||||
|
|
||||||
/*implicit*/ TokenIDs(const std::vector<int64_t> &tokens) // NOLINT
|
/*implicit*/ TokenIDs(std::vector<int64_t> tokens) // NOLINT
|
||||||
: tokens{tokens} {}
|
: tokens{std::move(tokens)} {}
|
||||||
|
|
||||||
TokenIDs(const std::vector<int64_t> &tokens,
|
TokenIDs(std::vector<int64_t> tokens, // NOLINT
|
||||||
const std::vector<int64_t> &tones)
|
std::vector<int64_t> tones) // NOLINT
|
||||||
: tokens{tokens}, tones{tones} {}
|
: tokens{std::move(tokens)}, tones{std::move(tones)} {}
|
||||||
|
|
||||||
std::string ToString() const;
|
std::string ToString() const;
|
||||||
|
|
||||||
|
|||||||
@@ -157,8 +157,8 @@ Ort::Value View(Ort::Value *v) {
|
|||||||
|
|
||||||
float ComputeSum(const Ort::Value *v, int32_t n /*= -1*/) {
|
float ComputeSum(const Ort::Value *v, int32_t n /*= -1*/) {
|
||||||
std::vector<int64_t> shape = v->GetTensorTypeAndShapeInfo().GetShape();
|
std::vector<int64_t> shape = v->GetTensorTypeAndShapeInfo().GetShape();
|
||||||
auto size = static_cast<int32_t>(std::accumulate(
|
auto size = static_cast<int32_t>(
|
||||||
shape.begin(), shape.end(), 1, std::multiplies<int64_t>()));
|
std::accumulate(shape.begin(), shape.end(), 1, std::multiplies<>()));
|
||||||
if (n != -1 && n < size && n > 0) {
|
if (n != -1 && n < size && n > 0) {
|
||||||
size = n;
|
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*/) {
|
float ComputeMean(const Ort::Value *v, int32_t n /*= -1*/) {
|
||||||
std::vector<int64_t> shape = v->GetTensorTypeAndShapeInfo().GetShape();
|
std::vector<int64_t> shape = v->GetTensorTypeAndShapeInfo().GetShape();
|
||||||
auto size = static_cast<int32_t>(std::accumulate(
|
auto size = static_cast<int32_t>(
|
||||||
shape.begin(), shape.end(), 1, std::multiplies<int64_t>()));
|
std::accumulate(shape.begin(), shape.end(), 1, std::multiplies<>()));
|
||||||
|
|
||||||
if (n != -1 && n < size && n > 0) {
|
if (n != -1 && n < size && n > 0) {
|
||||||
size = n;
|
size = n;
|
||||||
|
|||||||
@@ -239,12 +239,12 @@ std::vector<TokenIDs> PiperPhonemizeLexicon::ConvertTextToTokenIds(
|
|||||||
if (meta_data_.is_piper || meta_data_.is_icefall) {
|
if (meta_data_.is_piper || meta_data_.is_icefall) {
|
||||||
for (const auto &p : phonemes) {
|
for (const auto &p : phonemes) {
|
||||||
phoneme_ids = PiperPhonemesToIds(token2id_, p);
|
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) {
|
} else if (meta_data_.is_coqui) {
|
||||||
for (const auto &p : phonemes) {
|
for (const auto &p : phonemes) {
|
||||||
phoneme_ids = CoquiPhonemesToIds(token2id_, p, meta_data_);
|
phoneme_ids = CoquiPhonemesToIds(token2id_, p, meta_data_);
|
||||||
ans.push_back(std::move(phoneme_ids));
|
ans.emplace_back(std::move(phoneme_ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user