mirror of
https://github.com/storytold/artcraft.git
synced 2026-10-26 02:59:37 +00:00
cleanup, move effects mod into synthesis::effects
This commit is contained in:
@@ -264,36 +264,6 @@ impl Audiobank {
|
||||
Some(all_samples)
|
||||
}
|
||||
|
||||
/** Get a diphone in the form "{first}_{second}.wav". */
|
||||
pub fn get_diphone(&self, speaker: &str, first: &str, second: &str)
|
||||
-> Option<Vec<i16>> {
|
||||
|
||||
if check_path(speaker).is_err()
|
||||
|| check_path(first).is_err()
|
||||
|| check_path(second).is_err() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let path = self.audio_path.join(format!("{}/", speaker))
|
||||
.join("2-phones/")
|
||||
.join(format!("{}_{}.wav", first, second));
|
||||
|
||||
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::<i16>();
|
||||
for sample in samples {
|
||||
all_samples.push(sample.unwrap());
|
||||
}
|
||||
|
||||
Some(all_samples)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the miscellaneous sound effect file.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// Copyright (c) 2015 Brandon Thomas <bt@brand.io>
|
||||
// TODO: This looks really bad now. Needs cleanup.
|
||||
|
||||
use config::Config;
|
||||
use crypto::digest::Digest;
|
||||
@@ -119,7 +118,6 @@ impl SpeakRequest {
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
let sen = match get_str(params, SENTENCE_PARAM) {
|
||||
Some(s) => s.to_string(),
|
||||
None => {
|
||||
@@ -294,7 +292,6 @@ impl AudioSynthHandler {
|
||||
|
||||
synth.generate(&request.sentence, &request.speaker, params)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn get_str<'a>(params: &'a QueryParams, param_name: &str)
|
||||
|
||||
@@ -20,7 +20,6 @@ extern crate urlencoded;
|
||||
|
||||
pub mod audiobank;
|
||||
pub mod config;
|
||||
pub mod effects;
|
||||
pub mod error;
|
||||
pub mod handlers;
|
||||
pub mod lang;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Copyright (c) 2016 Brandon Thomas <bt@brand.io, echelon@gmail.com>
|
||||
|
||||
pub mod effects;
|
||||
pub mod synthesizer;
|
||||
pub mod tokens;
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
use audiobank::Audiobank;
|
||||
use audiobank::SampleBytes;
|
||||
use audiobank::SamplePreference;
|
||||
use effects::pause::generate_pause;
|
||||
use effects::speed::change_speed;
|
||||
use effects::volume::change_volume;
|
||||
use error::SynthError;
|
||||
use hound::WavSpec;
|
||||
use hound::WavWriter;
|
||||
@@ -14,6 +11,9 @@ use lang::parser::Parser;
|
||||
use speaker::Speaker;
|
||||
use std::io::BufWriter;
|
||||
use std::io::Cursor;
|
||||
use synthesis::effects::pause::generate_pause;
|
||||
use synthesis::effects::speed::change_speed;
|
||||
use synthesis::effects::volume::change_volume;
|
||||
use synthesis::tokens::*;
|
||||
|
||||
pub type WavBytes = Vec<u8>;
|
||||
@@ -38,11 +38,6 @@ pub struct SynthesisParams {
|
||||
* Generates wave files from text input.
|
||||
*/
|
||||
pub struct Synthesizer {
|
||||
// TODO: For now we rely on word files existing on the filesystem
|
||||
// at runtime. This is pretty lame.
|
||||
///// Word dictionary
|
||||
//word_dictionary: Vocabulary,
|
||||
|
||||
/// Arpabet, (Word) -> (PhonemeList)
|
||||
arpabet_dictionary: Arpabet,
|
||||
|
||||
@@ -72,7 +67,7 @@ impl Synthesizer {
|
||||
sentence: &str,
|
||||
speaker: &Speaker,
|
||||
params: SynthesisParams)
|
||||
-> Result<WavBytes, SynthError> {
|
||||
-> Result<WavBytes, SynthError> {
|
||||
|
||||
let tokens = self.parser.parse(sentence);
|
||||
|
||||
@@ -594,4 +589,3 @@ impl Synthesizer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user