This commit is contained in:
tuna2134
2024-09-14 03:25:53 +00:00
parent d5b2c4842e
commit 38f9d98d1a
6 changed files with 20 additions and 13 deletions

View File

@@ -54,6 +54,17 @@ impl JTalk {
Ok(Self { jpreprocess })
}
pub fn num2word(&self, text: &str) -> Result<String> {
let mut parsed = self.jpreprocess.text_to_njd(text)?;
parsed.preprocess();
let texts: Vec<String> = parsed
.nodes
.iter()
.map(|x| x.get_string().to_string())
.collect();
Ok(texts.join(""))
}
pub fn process_text(&self, text: &str) -> Result<JTalkProcess> {
let parsed = self.jpreprocess.run_frontend(text)?;
let jtalk_process = JTalkProcess::new(Arc::clone(&self.jpreprocess), parsed);

View File

@@ -120,7 +120,8 @@ pub fn replace_punctuation(mut text: String) -> String {
for (k, v) in REPLACE_MAP.iter() {
text = text.replace(k, v);
}
PUNCTUATION_CLEANUP_PATTERN
let content = PUNCTUATION_CLEANUP_PATTERN
.replace_all(&text, "")
.to_string()
.to_string();
content
}

View File

@@ -123,7 +123,8 @@ impl TTSModelHolder {
&self,
text: &str,
) -> Result<(Array2<f32>, Array1<i64>, Array1<i64>, Array1<i64>)> {
let normalized_text = norm::normalize_text(text);
let text = self.jtalk.num2word(text)?;
let normalized_text = norm::normalize_text(&text);
let process = self.jtalk.process_text(&normalized_text)?;
let (phones, tones, mut word2ph) = process.g2p()?;