From b467d0c48170d5ce84a4479c1519d3ca4ce79277 Mon Sep 17 00:00:00 2001 From: xd009642 Date: Mon, 22 Apr 2024 12:33:58 +0100 Subject: [PATCH] Make dictionary non-necessary for character input --- src/lib.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2488f6d..23c4381 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,10 +38,15 @@ pub struct XdTts { impl XdTts { pub fn new(tacotron2: &Path, phoneme_input: bool) -> anyhow::Result { - let mut dict = CmuDictionary::open("data/cmudict-0.7b.txt")?; - if let Ok(custom) = CmuDictionary::open("resources/custom_dict.txt") { - dict.merge(custom); - } + let dict = if phoneme_input { + let mut dict = CmuDictionary::open("data/cmudict-0.7b.txt")?; + if let Ok(custom) = CmuDictionary::open("resources/custom_dict.txt") { + dict.merge(custom); + } + dict + } else { + CmuDictionary::default() + }; let model = Tacotron2::load(tacotron2)?; let vocoder = create_griffin_lim()?; Ok(Self {