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);
|
||||
|
||||
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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user