Skip to content

Commit

Permalink
[runtime] fix g2p_en
Browse files Browse the repository at this point in the history
  • Loading branch information
pengzhendong committed Sep 12, 2023
1 parent 07e7fa8 commit af60df8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ We plan to support a variaty of hardwares and platforms, including:
export GLOG_logtostderr=1
export GLOG_v=2

cd runtime
cd runtime/onnxruntime
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
./build/bin/tts_main \
Expand Down
14 changes: 11 additions & 3 deletions runtime/core/bin/tts_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ DEFINE_string(phone2id, "", "phone to id");
DEFINE_string(sname, "", "speaker name");
DEFINE_string(vits_model, "", "e2e tts model file");

DEFINE_int32(sampling_rate, 22050, "sampling rate of pcm");
DEFINE_string(text, "", "input text");
DEFINE_string(wav_path, "", "output wave path");

Expand All @@ -54,8 +55,14 @@ int main(int argc, char* argv[]) {
google::InitGoogleLogging(argv[0]);

auto tn = std::make_shared<wetext::Processor>(FLAGS_tagger, FLAGS_verbalizer);
auto g2p_en = std::make_shared<wetts::G2pEn>(
FLAGS_cmudict, FLAGS_g2p_en_model, FLAGS_g2p_en_sym);

bool has_en = !FLAGS_g2p_en_model.empty() && !FLAGS_g2p_en_sym.empty() &&
!FLAGS_g2p_en_sym.empty();
std::shared_ptr<wetts::G2pEn> g2p_en =
has_en ? std::make_shared<wetts::G2pEn>(FLAGS_cmudict, FLAGS_g2p_en_model,
FLAGS_g2p_en_sym)
: nullptr;

auto g2p_prosody = std::make_shared<wetts::G2pProsody>(
FLAGS_g2p_prosody_model, FLAGS_vocab, FLAGS_char2pinyin, FLAGS_pinyin2id,
FLAGS_pinyin2phones, g2p_en);
Expand All @@ -66,7 +73,8 @@ int main(int argc, char* argv[]) {
int sid = model->GetSid(FLAGS_sname);
model->Synthesis(FLAGS_text, sid, &audio);

wetts::WavWriter wav_writer(audio.data(), audio.size(), 1, 22050, 16);
wetts::WavWriter wav_writer(audio.data(), audio.size(), 1,
FLAGS_sampling_rate, 16);
wav_writer.Write(FLAGS_wav_path);
return 0;
}

0 comments on commit af60df8

Please sign in to comment.