From 6c0c0118ff9b83f4e7eca988c4e1b2da0ca0b456 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Wed, 24 Aug 2016 03:36:24 -0400 Subject: [PATCH] add static to unmapped (word->phonemes) --- src/audiobank.rs | 27 +++++++++++++++++++++++++++ src/dictionary.rs | 7 ++++++- src/synthesizer.rs | 6 ++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/audiobank.rs b/src/audiobank.rs index 7ad66bd829..d91c93f0ac 100644 --- a/src/audiobank.rs +++ b/src/audiobank.rs @@ -91,6 +91,33 @@ impl Audiobank { Some(all_samples) } + /** + * Get the miscellaneous sound effect file. + */ + pub fn get_misc(&self, name: &str) -> Option> { + if check_path(name).is_err() { + return None; + } + + let path = self.audio_path.join("misc/") + .join(format!("{}.wav", name)); + + let mut reader = match WavReader::open(path) { + Err(_) => { return None; }, + Ok(reader) => reader, + }; + + // TODO: Inefficient. + let mut all_samples = Vec::new(); + let samples = reader.samples::(); + for sample in samples { + all_samples.push(sample.unwrap()); + } + + Some(all_samples) + } + + // TODO: This should be removed. We should cache the wav headers. pub fn get_spec(&self, speaker: &str, word: &str) -> Result { try!(check_path(speaker)); diff --git a/src/dictionary.rs b/src/dictionary.rs index 1008275d9a..68675291d5 100644 --- a/src/dictionary.rs +++ b/src/dictionary.rs @@ -43,7 +43,8 @@ impl VocabularyLibrary { } let dirname = try!(get_filename(&entry)); - if ignorable_file(&dirname) { + + if ignorable_file(&dirname) || ignorable_dir(&dirname) { continue; } @@ -109,3 +110,7 @@ fn ignorable_file(filename: &str) -> bool { filename.starts_with("_") || filename.ends_with("_") } +fn ignorable_dir(filename: &str) -> bool { + filename == "misc" +} + diff --git a/src/synthesizer.rs b/src/synthesizer.rs index db4f490c2d..bb6b0606b7 100644 --- a/src/synthesizer.rs +++ b/src/synthesizer.rs @@ -69,6 +69,12 @@ impl Synthesizer { match self.arpabet_dictionary.get_polyphone(word) { None => { // TODO: ERROR (maybe add static based on word length!) + match self.audiobank.get_misc("record_static") { + None => {}, + Some(waveform_data) => { + concatenated_waveform.extend(waveform_data); + }, + } continue; }, Some(polyphone) => {