mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 17:38:10 +00:00
early access speakers JSON endpoint + config
This commit is contained in:
1 parent
040270422e
commit
e300d7d198
5 files changed
+50
-5
No files matched your search
@@ -1,3 +1,9 @@
|
||||
early_access_voices = [
|
||||
"goku",
|
||||
"peter-griffin",
|
||||
"eric-cartman",
|
||||
]
|
||||
|
||||
[[speakers]]
|
||||
name = "Goku"
|
||||
slug = "goku"
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
early_access_voices = [
|
||||
"goku",
|
||||
"peter-griffin",
|
||||
"eric-cartman",
|
||||
]
|
||||
|
||||
# --------------- Experimental Speakers ---------------
|
||||
[[speakers]]
|
||||
name = "Current Experiment (glow only + pretrained melgan)"
|
||||
|
||||
@@ -21,10 +21,36 @@ pub async fn get_speakers(
|
||||
_request: HttpRequest,
|
||||
app_state: Data<Arc<AppState>>
|
||||
) -> std::io::Result<Json<SpeakersResult>> {
|
||||
println!("GET /models");
|
||||
println!("GET /speakers");
|
||||
let app_state = app_state.into_inner();
|
||||
|
||||
Ok(Json(SpeakersResult {
|
||||
speakers: app_state.model_configs.speakers.clone(),
|
||||
}))
|
||||
}
|
||||
|
||||
#[get("/early_access_speakers")]
|
||||
pub async fn get_early_access_speakers(
|
||||
_request: HttpRequest,
|
||||
app_state: Data<Arc<AppState>>
|
||||
) -> std::io::Result<Json<SpeakersResult>> {
|
||||
println!("GET /early_access_speakers");
|
||||
let app_state = app_state.into_inner();
|
||||
|
||||
let early_access_voices =
|
||||
app_state.model_configs.early_access_voices
|
||||
.as_ref()
|
||||
.map_or(Vec::new(), |list| list.clone());
|
||||
|
||||
let mut early_access_speakers : Vec<Speaker> = Vec::new();
|
||||
|
||||
for speaker in app_state.model_configs.speakers.iter() {
|
||||
if early_access_voices.contains(&speaker.slug) {
|
||||
early_access_speakers.push(speaker.clone());
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Json(SpeakersResult {
|
||||
speakers: early_access_speakers,
|
||||
}))
|
||||
}
|
||||
@@ -46,6 +46,7 @@ use crate::endpoints::speak::legacy_tts::post_tts;
|
||||
use crate::endpoints::speak::speak::post_speak;
|
||||
use crate::endpoints::speak::speak_with_spectrogram::post_speak_with_spectrogram;
|
||||
use crate::endpoints::speakers::get_speakers;
|
||||
use crate::endpoints::speakers::get_early_access_speakers;
|
||||
use crate::endpoints::words::get_words;
|
||||
use crate::model::model_cache::ModelCache;
|
||||
use crate::model::model_config::ModelConfigs;
|
||||
@@ -386,8 +387,12 @@ async fn run_server(app_state: AppState, server_args: ServerArgs) -> std::io::Re
|
||||
.exclude("/liveness")
|
||||
.exclude("/readiness"))
|
||||
.wrap(DefaultHeaders::new().header("X-Backend-Hostname", &server_hostname))
|
||||
.service(Files::new("/frontend", asset_directory.clone())
|
||||
.index_file("index.html"))
|
||||
.service(Files::new("/hidden_admin", asset_directory.clone())
|
||||
.index_file("hidden_admin.html"))
|
||||
.service(Files::new("/patreon_thanks", asset_directory.clone())
|
||||
.index_file("patreon_thanks.html"))
|
||||
.service(Files::new("/stream5", asset_directory.clone())
|
||||
.index_file("twitch_stream.html"))
|
||||
.service(
|
||||
web::resource("/advanced_tts")
|
||||
.route(web::post().to(post_tts))
|
||||
@@ -411,6 +416,7 @@ async fn run_server(app_state: AppState, server_args: ServerArgs) -> std::io::Re
|
||||
.service(get_sentences)
|
||||
.service(get_service_settings)
|
||||
.service(get_speakers)
|
||||
.service(get_early_access_speakers)
|
||||
.service(get_words)
|
||||
.app_data(arc.clone())
|
||||
)
|
||||
|
||||
@@ -5,6 +5,7 @@ use std::path::Path;
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct ModelConfigs {
|
||||
pub speakers: Vec<Speaker>,
|
||||
pub early_access_voices: Option<Vec<String>>,
|
||||
pub model_locations: Vec<ModelLocation>,
|
||||
}
|
||||
|
||||
@@ -62,9 +63,9 @@ pub enum ModelPipeline {
|
||||
impl ModelConfigs {
|
||||
pub fn load_from_file(filename: &str) -> Self {
|
||||
let contents = fs::read_to_string(filename)
|
||||
.expect("Couldn't read file");
|
||||
.expect(&format!("Couldn't read file: {}", filename));
|
||||
toml::from_str(&contents)
|
||||
.expect("Couldn't parse toml")
|
||||
.expect(&format!("Couldn't parse toml: {}", filename))
|
||||
}
|
||||
|
||||
pub fn find_speaker_by_slug(&self, slug: &str) -> Option<&Speaker> {
|
||||
|
||||
Reference in new issue
Block a user