Skip to content

Commit

Permalink
Rename SpeechGenerator functions to generate_* (#40)
Browse files Browse the repository at this point in the history
* rename to generate

* step
  • Loading branch information
femshima authored May 11, 2024
1 parent d1bece8 commit c7e0384
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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

0 comments on commit c7e0384

Please sign in to comment.