diff --git a/assets/seed/trump_problem.wav b/assets/seed/trump_problem.wav deleted file mode 100644 index 537576718b..0000000000 Binary files a/assets/seed/trump_problem.wav and /dev/null differ diff --git a/crates/_types/enums/src/by_table/mod.rs b/crates/_types/enums/src/by_table/mod.rs index 1061281e12..1259d76cd9 100644 --- a/crates/_types/enums/src/by_table/mod.rs +++ b/crates/_types/enums/src/by_table/mod.rs @@ -14,7 +14,7 @@ pub mod user_ratings; pub mod voice_conversion_models; pub mod voice_conversion_results; pub mod zs_voices; - +pub mod model_weights; // ===== Sqlite ===== pub mod tts_render_tasks; pub mod web_rendition_targets; diff --git a/crates/_types/enums/src/by_table/model_weights/mod.rs b/crates/_types/enums/src/by_table/model_weights/mod.rs new file mode 100644 index 0000000000..5217cf739e --- /dev/null +++ b/crates/_types/enums/src/by_table/model_weights/mod.rs @@ -0,0 +1,2 @@ +pub mod weights_types; +pub mod weights_category; diff --git a/crates/_types/enums/src/by_table/model_weights/weights_category.rs b/crates/_types/enums/src/by_table/model_weights/weights_category.rs new file mode 100644 index 0000000000..7792f63fce --- /dev/null +++ b/crates/_types/enums/src/by_table/model_weights/weights_category.rs @@ -0,0 +1,82 @@ +use std::collections::BTreeSet; + +#[cfg(test)] +use strum::EnumCount; +#[cfg(test)] +use strum::EnumIter; + +#[cfg_attr(test, derive(EnumIter, EnumCount))] +#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize,Debug)] +pub enum WeightsCategory { + #[serde(rename = "image_generation")] + ImageGeneration, + #[serde(rename = "text_to_speech")] + TextToSpeech, + #[serde(rename = "vocoder")] + Vocoder, + #[serde(rename = "voice_conversion")] + VoiceConversion, +} + +impl WeightsCategory { + pub fn to_str(&self) -> &'static str { + match self { + Self::ImageGeneration => "image_generation", + Self::TextToSpeech => "text_to_speech", + Self::Vocoder => "vocoder", + Self::VoiceConversion => "voice_conversion", + } + } + + pub fn from_str(value: &str) -> Result { + match value { + "image_generation" => Ok(Self::ImageGeneration), + "text_to_speech" => Ok(Self::TextToSpeech), + "vocoder" => Ok(Self::Vocoder), + "voice_conversion" => Ok(Self::VoiceConversion), + _ => Err(format!("invalid value: {:?}", value)), + } + } + + pub fn all_variants() -> BTreeSet { + BTreeSet::from([ + Self::ImageGeneration, + Self::TextToSpeech, + Self::Vocoder, + Self::VoiceConversion, + ]) + } +} + + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_to_str() { + assert_eq!(WeightsCategory::ImageGeneration.to_str(), "image_generation"); + assert_eq!(WeightsCategory::TextToSpeech.to_str(), "text_to_speech"); + assert_eq!(WeightsCategory::Vocoder.to_str(), "vocoder"); + assert_eq!(WeightsCategory::VoiceConversion.to_str(), "voice_conversion"); + } + + #[test] + fn test_from_str() { + assert_eq!(WeightsCategory::from_str("image_generation").unwrap(), WeightsCategory::ImageGeneration); + assert_eq!(WeightsCategory::from_str("text_to_speech").unwrap(), WeightsCategory::TextToSpeech); + assert_eq!(WeightsCategory::from_str("vocoder").unwrap(), WeightsCategory::Vocoder); + assert_eq!(WeightsCategory::from_str("voice_conversion").unwrap(), WeightsCategory::VoiceConversion); + assert!(WeightsCategory::from_str("invalid").is_err()); + } + + #[test] + fn test_all_variants() { + let variants = WeightsCategory::all_variants(); + assert_eq!(variants.len(), 4); + assert!(variants.contains(&WeightsCategory::ImageGeneration)); + assert!(variants.contains(&WeightsCategory::TextToSpeech)); + assert!(variants.contains(&WeightsCategory::Vocoder)); + assert!(variants.contains(&WeightsCategory::VoiceConversion)); + } +} \ No newline at end of file diff --git a/crates/_types/enums/src/by_table/model_weights/weights_types.rs b/crates/_types/enums/src/by_table/model_weights/weights_types.rs new file mode 100644 index 0000000000..7f09c5a539 --- /dev/null +++ b/crates/_types/enums/src/by_table/model_weights/weights_types.rs @@ -0,0 +1,105 @@ +use std::collections::BTreeSet; + +#[cfg(test)] +use strum::EnumCount; +#[cfg(test)] +use strum::EnumIter; + +#[cfg_attr(test, derive(EnumIter, EnumCount))] +#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize,Debug)] +pub enum WeightsType { + #[serde(rename = "hifigan_tt2")] + HifiganTacotron2, + #[serde(rename = "rvc_v2")] + RvcV2, + #[serde(rename = "sd_1.5")] + StableDiffusion15, + #[serde(rename = "sdxl")] + StableDiffusionXL, + #[serde(rename = "so_vits_svc")] + SoVitsSvc, + #[serde(rename = "tt2")] + Tacotron2, + #[serde(rename = "loRA")] + LoRA, +} + +impl WeightsType { + pub fn to_str(&self) -> &'static str { + match self { + Self::HifiganTacotron2 => "hifigan_tt2", + Self::RvcV2 => "rvc_v2", + Self::StableDiffusion15 => "sd_1.5", + Self::StableDiffusionXL => "sdxl", + Self::SoVitsSvc => "so_vits_svc", + Self::Tacotron2 => "tt2", + Self::LoRA => "loRA", + } + } + + pub fn from_str(value: &str) -> Result { + match value { + "hifigan_tt2" => Ok(Self::HifiganTacotron2), + "rvc_v2" => Ok(Self::RvcV2), + "sd_1.5" => Ok(Self::StableDiffusion15), + "sdxl" => Ok(Self::StableDiffusionXL), + "so_vits_svc" => Ok(Self::SoVitsSvc), + "tt2" => Ok(Self::Tacotron2), + "loRA" => Ok(Self::LoRA), + _ => Err(format!("invalid value: {:?}", value)), + } + } + + pub fn all_variants() -> BTreeSet { + BTreeSet::from([ + Self::HifiganTacotron2, + Self::RvcV2, + Self::StableDiffusion15, + Self::StableDiffusionXL, + Self::SoVitsSvc, + Self::Tacotron2, + Self::LoRA, + ]) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_to_str() { + assert_eq!(WeightsType::HifiganTacotron2.to_str(), "hifigan_tt2"); + assert_eq!(WeightsType::RvcV2.to_str(), "rvc_v2"); + assert_eq!(WeightsType::StableDiffusion15.to_str(), "sd_1.5"); + assert_eq!(WeightsType::StableDiffusionXL.to_str(), "sdxl"); + assert_eq!(WeightsType::SoVitsSvc.to_str(), "so_vits_svc"); + assert_eq!(WeightsType::Tacotron2.to_str(), "tt2"); + assert_eq!(WeightsType::LoRA.to_str(), "loRA"); + } + + #[test] + fn test_from_str() { + assert_eq!(WeightsType::from_str("hifigan_tt2").unwrap(), WeightsType::HifiganTacotron2); + assert_eq!(WeightsType::from_str("rvc_v2").unwrap(), WeightsType::RvcV2); + assert_eq!(WeightsType::from_str("sd_1.5").unwrap(), WeightsType::StableDiffusion15); + assert_eq!(WeightsType::from_str("sdxl").unwrap(), WeightsType::StableDiffusionXL); + assert_eq!(WeightsType::from_str("so_vits_svc").unwrap(), WeightsType::SoVitsSvc); + assert_eq!(WeightsType::from_str("tt2").unwrap(), WeightsType::Tacotron2); + assert_eq!(WeightsType::from_str("loRA").unwrap(), WeightsType::LoRA); + assert!(WeightsType::from_str("invalid").is_err()); + } + + #[test] + fn test_all_variants() { + let variants = WeightsType::all_variants(); + assert_eq!(variants.len(), 7); + assert!(variants.contains(&WeightsType::HifiganTacotron2)); + assert!(variants.contains(&WeightsType::RvcV2)); + assert!(variants.contains(&WeightsType::StableDiffusion15)); + assert!(variants.contains(&WeightsType::StableDiffusionXL)); + assert!(variants.contains(&WeightsType::SoVitsSvc)); + assert!(variants.contains(&WeightsType::Tacotron2)); + assert!(variants.contains(&WeightsType::LoRA)); + } +} diff --git a/crates/cli/dev_database_seed/src/seeding/mod.rs b/crates/cli/dev_database_seed/src/seeding/mod.rs index ed87c42c9e..cba272641d 100644 --- a/crates/cli/dev_database_seed/src/seeding/mod.rs +++ b/crates/cli/dev_database_seed/src/seeding/mod.rs @@ -1,3 +1,4 @@ pub mod users; pub mod voice_conversion; -pub mod zero_shot_tts; \ No newline at end of file +pub mod zero_shot_tts; +pub mod model_weights; \ No newline at end of file diff --git a/crates/cli/dev_database_seed/src/seeding/model_weights.rs b/crates/cli/dev_database_seed/src/seeding/model_weights.rs new file mode 100644 index 0000000000..0f01bcc8b0 --- /dev/null +++ b/crates/cli/dev_database_seed/src/seeding/model_weights.rs @@ -0,0 +1,65 @@ + + +use storyteller_root::get_storyteller_rust_root; +use tokens::tokens::users::UserToken; +use log::info; +use sqlx::{MySql, Pool}; + +use enums::by_table::voice_conversion_models::voice_conversion_model_type::VoiceConversionModelType; +use errors::{anyhow, AnyhowResult}; +use mysql_queries::queries::users::user::get_user_token_by_username::get_user_token_by_username; +use mysql_queries::queries::voice_conversion::models::insert_voice_conversion_model_from_download_job::{insert_voice_conversion_model_from_download_job, InsertVoiceConversionModelArgs}; + +use crate::seeding::users::HANASHI_USERNAME; + + +pub async fn seed_weights(mysql_pool: &Pool) -> AnyhowResult<()> { + info!("Seeding weights..."); + + // let user_token = match get_user_token_by_username(HANASHI_USERNAME, mysql_pool).await? { + // None => { return Err(anyhow!("could not find user hanashi")) } + // Some(token) => token, + // }; + + // let rvc_models = [ + // // NB: The bucket hashes here are already uploaded to the development Google Cloud Storage + // // bucket and should be usable if you have the development secrets on your machine. + // ("Eric Cartman", "4t9d3y4ve807q69t806pw352dx82h83dzf52bfrp9s9z63gqsxgyezxf8fzdn9yn", true), + // ("Stewie", "bvfe3zwvqnrv64rrtvva1f3r2p2k5tpznfejbh90r353brzqfkveytzyt4cy73hs", true), + // ("Yoda", "cqbcbjsbdy77s4g525nrs791s035b13wew7rp6pep49sx0xr8pqr5af5sseqtkq7", false), + // ]; + + // for (title, private_bucket_hash, has_index_file) in rvc_models { + // create_rvc_model(title, private_bucket_hash, has_index_file, &user_token, mysql_pool).await?; + // } + + Ok(()) +} + +async fn create_rvc_model( + title: &str, + private_bucket_hash: &str, + has_index_file: bool, + creator_user_token: &UserToken, + mysql_pool: &Pool, +) -> AnyhowResult<()> { + + // info!("Creating voice conversion record"); + + // insert_voice_conversion_model_from_download_job(InsertVoiceConversionModelArgs { + // model_type: VoiceConversionModelType::RvcV2, + // title, + // original_download_url: "https://example.com", + // original_filename: "unknown.zip", + // file_size_bytes: 1234, + // creator_user_token: creator_user_token.as_str(), + // creator_ip_address: "127.0.0.1", + // creator_set_visibility: Default::default(), + // has_index_file, + // private_bucket_hash, + // private_bucket_object_name: "unused", + // mysql_pool, + // }).await?; + + Ok(()) +} diff --git a/crates/lib/mysql_queries/src/queries/mod.rs b/crates/lib/mysql_queries/src/queries/mod.rs index 523ec28d2f..f61317dc57 100644 --- a/crates/lib/mysql_queries/src/queries/mod.rs +++ b/crates/lib/mysql_queries/src/queries/mod.rs @@ -22,3 +22,4 @@ pub mod voice_clone_requests; pub mod voice_conversion; pub mod voice_designer; pub mod w2l; +pub mod model_weights; \ No newline at end of file diff --git a/crates/lib/mysql_queries/src/queries/model_weights/create_weight.rs b/crates/lib/mysql_queries/src/queries/model_weights/create_weight.rs new file mode 100644 index 0000000000..97f7e87e13 --- /dev/null +++ b/crates/lib/mysql_queries/src/queries/model_weights/create_weight.rs @@ -0,0 +1,3 @@ +use sqlx::{MySql, Pool}; +use enums::by_table::generic_synthetic_ids::id_category::IdCategory; + diff --git a/crates/lib/mysql_queries/src/queries/model_weights/mod.rs b/crates/lib/mysql_queries/src/queries/model_weights/mod.rs new file mode 100644 index 0000000000..d55c3bf35a --- /dev/null +++ b/crates/lib/mysql_queries/src/queries/model_weights/mod.rs @@ -0,0 +1 @@ +pub mod create_weight;