Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename SpeechGenerator functions to generate_* #40

Merged
merged 2 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ impl Engine {
}

pub fn synthesize(&self, labels: impl ToLabels) -> Result<Vec<f64>, EngineError> {
Ok(self.generator(labels)?.synthesize_all())
Ok(self.generator(labels)?.generate_all())
}

pub fn generator(&self, labels: impl ToLabels) -> Result<SpeechGenerator, EngineError> {
Expand Down
6 changes: 3 additions & 3 deletions src/speech.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl SpeechGenerator {
}

/// Generate speech
pub fn synthesize(&mut self, speech: &mut [f64]) -> usize {
pub fn generate_step(&mut self, speech: &mut [f64]) -> usize {
if self.lf0.len() <= self.next {
return 0;
}
Expand All @@ -61,13 +61,13 @@ impl SpeechGenerator {
self.fperiod
}

pub fn synthesize_all(mut self) -> Vec<f64> {
pub fn generate_all(mut self) -> Vec<f64> {
if self.next != 0 {
eprintln!("The speech generator has already synthesized some frames.");
}

let mut buf = vec![0.0; (self.lf0.len() - self.next) * self.fperiod];
while self.synthesize(&mut buf[self.next * self.fperiod..]) > 0 {}
while self.generate_step(&mut buf[self.next * self.fperiod..]) > 0 {}

buf
}
Expand Down
Loading