1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use std::path::PathBuf;
use config::Config;
use rocket::async_trait;
use rocket::{fairing::AdHoc, request::FromRequest};
use utils::phrase_package::PhrasePackage;
#[async_trait]
pub trait TtsGenerator<'r>: Send + Sync + Sized + 'static {
type Error: core::fmt::Debug;
fn new() -> Result<Self, <Self as TtsGenerator<'r>>::Error>;
fn fairing() -> AdHoc
where
&'r Self: FromRequest<'r>,
{
AdHoc::on_ignite("Tts Generator", |rocket| {
Box::pin(async move {
let jenny = Self::new().unwrap();
rocket.manage(jenny)
})
})
}
async fn generate(
&self,
details: &PhrasePackage,
config: &Config,
) -> Result<PathBuf, <Self as TtsGenerator<'r>>::Error>;
}