From 7e116953300b289da35a1ab034eb8a5cef78b324 Mon Sep 17 00:00:00 2001 From: TianYuan Date: Mon, 13 Mar 2023 17:50:26 +0000 Subject: [PATCH] fix Word2WordVec --- demos/TTSCppFrontend/src/front/front_interface.cpp | 14 +++++++------- demos/TTSCppFrontend/src/front/front_interface.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/demos/TTSCppFrontend/src/front/front_interface.cpp b/demos/TTSCppFrontend/src/front/front_interface.cpp index 4682c8bb7..d15a48e54 100644 --- a/demos/TTSCppFrontend/src/front/front_interface.cpp +++ b/demos/TTSCppFrontend/src/front/front_interface.cpp @@ -438,11 +438,11 @@ int FrontEngineInterface::GetFinals(const std::string &word, } int FrontEngineInterface::Word2WordVec(const std::string &word, - std::vector &wordvec) { + std::vector *wordvec) { std::wstring word_wstr = ppspeech::utf8string2wstring(word); for (int i = 0; i < word_wstr.length(); i++) { std::wstring word_sigle(1, word_wstr[i]); - wordvec.push_back(word_sigle); + wordvec->push_back(word_sigle); } return 0; } @@ -785,7 +785,7 @@ int FrontEngineInterface::BuSandi(const std::string &word, std::wstring bu = L"不"; std::vector wordvec; // 一个词转成向量形式 - if (0 != Word2WordVec(word, wordvec)) { + if (0 != Word2WordVec(word, &wordvec)) { LOG(ERROR) << "Failed to get word vector"; return -1; } @@ -812,7 +812,7 @@ int FrontEngineInterface::YiSandhi(const std::string &word, std::wstring yi = L"一"; std::vector wordvec; // 一个词转成向量形式 - if (0 != Word2WordVec(word, wordvec)) { + if (0 != Word2WordVec(word, &wordvec)) { LOG(ERROR) << "Failed to get word vector"; return -1; } @@ -862,7 +862,7 @@ int FrontEngineInterface::NeuralSandhi(const std::string &word, std::wstring word_wstr = ppspeech::utf8string2wstring(word); std::vector wordvec; // 一个词转成向量形式 - if (0 != Word2WordVec(word, wordvec)) { + if (0 != Word2WordVec(word, &wordvec)) { LOG(ERROR) << "Failed to get word vector"; return -1; } @@ -985,7 +985,7 @@ int FrontEngineInterface::ThreeSandhi(const std::string &word, std::vector finals_temp; std::vector wordvec; // 一个词转成向量形式 - if (0 != Word2WordVec(word, wordvec)) { + if (0 != Word2WordVec(word, &wordvec)) { LOG(ERROR) << "Failed to get word vector"; return -1; } @@ -1094,7 +1094,7 @@ std::vector> FrontEngineInterface::MergeErhua( std::wstring word_wstr = ppspeech::utf8string2wstring(word); std::vector wordvec; // 一个词转成向量形式 - if (0 != Word2WordVec(word, wordvec)) { + if (0 != Word2WordVec(word, &wordvec)) { LOG(ERROR) << "Failed to get word vector"; } int word_num = wordvec.size(); diff --git a/demos/TTSCppFrontend/src/front/front_interface.h b/demos/TTSCppFrontend/src/front/front_interface.h index 6b90c21bd..b288c78a6 100644 --- a/demos/TTSCppFrontend/src/front/front_interface.h +++ b/demos/TTSCppFrontend/src/front/front_interface.h @@ -98,7 +98,7 @@ class FrontEngineInterface : public TextNormalizer { // 整个词转成向量形式,向量的每个元素对应词的一个字 int Word2WordVec(const std::string &word, - std::vector &wordvec); + std::vector *wordvec); // 将整个词重新进行 full cut,分词后,各个词会在词典中 int SplitWord(const std::string &word,