mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-02 08:28:18 +00:00
seed voice
This commit is contained in:
1 parent
bef5dce947
commit
eaa9ddd62d
3 files changed
+95
-43
No files matched your search
@@ -13,13 +13,13 @@ pub async fn seed_user_accounts(mysql_pool: &Pool<MySql>) -> AnyhowResult<()> {
|
||||
info!("Seeding user accounts...");
|
||||
|
||||
let users = [
|
||||
(ADMIN_USERNAME, format!("{}@storyteller.ai", ADMIN_USERNAME), "password"),
|
||||
(HANASHI_USERNAME, format!("{}@storyteller.ai", HANASHI_USERNAME), "password"),
|
||||
("test", "test@storyteller.ai".to_string(), "password"),
|
||||
(ADMIN_USERNAME, "password"),
|
||||
(HANASHI_USERNAME, "password"),
|
||||
("test", "password"),
|
||||
];
|
||||
|
||||
for (username, email, password) in users {
|
||||
let result = seed_user(username, &email, password, &mysql_pool).await;
|
||||
for (username, password) in users {
|
||||
let result = seed_user(username, password, &mysql_pool).await;
|
||||
match result {
|
||||
Ok(_) => info!("Seeded {}", username),
|
||||
Err(err) => warn!("Could not seed user {} : {:?}", username, err),
|
||||
@@ -31,7 +31,6 @@ pub async fn seed_user_accounts(mysql_pool: &Pool<MySql>) -> AnyhowResult<()> {
|
||||
|
||||
async fn seed_user(
|
||||
username: &str,
|
||||
email_address: &str,
|
||||
password: &str,
|
||||
mysql_pool: &Pool<MySql>,
|
||||
) -> AnyhowResult<()> {
|
||||
@@ -39,13 +38,14 @@ async fn seed_user(
|
||||
|
||||
let display_name = username.clone();
|
||||
let username = username.to_lowercase();
|
||||
let email_address = format!("{}@storyteller.ai", username);
|
||||
let email_gravatar_hash = email_to_gravatar_hash(&email_address);
|
||||
let password_hash = bcrypt_password_hash(password)?;
|
||||
|
||||
create_account(mysql_pool, CreateAccountArgs {
|
||||
username: &username,
|
||||
display_name,
|
||||
email_address,
|
||||
email_address: &email_address,
|
||||
email_gravatar_hash: &email_gravatar_hash,
|
||||
password_hash: &password_hash,
|
||||
ip_address: "127.0.0.1",
|
||||
|
||||
@@ -7,6 +7,7 @@ use hashing::md5::email_to_gravatar_hash::email_to_gravatar_hash;
|
||||
use mysql_queries::queries::users::user::create_account::{create_account, CreateAccountArgs};
|
||||
use mysql_queries::queries::users::user::get_user_token_by_username::get_user_token_by_username;
|
||||
use mysql_queries::queries::voice_designer::datasets::create_dataset::{create_dataset, CreateDatasetArgs};
|
||||
use mysql_queries::queries::voice_designer::voices::create_voice::{create_voice, CreateVoiceArgs};
|
||||
|
||||
use crate::seeding::users::HANASHI_USERNAME;
|
||||
|
||||
@@ -29,7 +30,21 @@ pub async fn seed_zero_shot_tts(mysql_pool: &Pool<MySql>) -> AnyhowResult<()> {
|
||||
mysql_pool,
|
||||
}).await?;
|
||||
|
||||
info!("Creating voice...");
|
||||
|
||||
let voice_token = create_voice(CreateVoiceArgs {
|
||||
dataset_token: &dataset_token,
|
||||
model_category: "vc",
|
||||
model_type: "vall-e-x",
|
||||
model_version: 0,
|
||||
model_encoding_type: "encodec",
|
||||
voice_title: "Goku Voice",
|
||||
bucket_hash: "asdf",
|
||||
maybe_creator_user_token: Some(&user_token),
|
||||
creator_ip_address: "127.0.0.1",
|
||||
creator_set_visibility: &Default::default(),
|
||||
mysql_pool,
|
||||
}).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -10,44 +10,81 @@ use tokens::users::user::UserToken;
|
||||
use crate::queries::generic_synthetic_ids::transactional_increment_generic_synthetic_id::transactional_increment_generic_synthetic_id;
|
||||
|
||||
pub struct CreateVoiceArgs<'a> {
|
||||
pub voice_token: &'a ZsVoiceToken,
|
||||
pub dataset_token: &'a ZsDatasetToken,
|
||||
|
||||
pub dataset_token: &'a ZsDatasetToken,
|
||||
pub dataset_version: u64,
|
||||
pub model_category: &'a str,
|
||||
pub model_type: &'a str,
|
||||
pub model_version: u64,
|
||||
pub model_encoding_type: &'a str,
|
||||
|
||||
pub model_category: &'a str,
|
||||
pub model_type: &'a str,
|
||||
pub model_version: u64,
|
||||
pub model_encoding_type: &'a str,
|
||||
pub voice_title: &'a str,
|
||||
// TODO(Kasisnu): Is this a create/update field?
|
||||
// should it be nullable
|
||||
pub bucket_hash: &'a str,
|
||||
pub maybe_creator_user_token: Option<&'a UserToken>,
|
||||
|
||||
pub voice_title: &'a str,
|
||||
// TODO(Kasisnu): Is this a create/update field?
|
||||
// should it be nullable
|
||||
pub bucket_hash: &'a str,
|
||||
pub maybe_creator_user_token: Option<&'a str>,
|
||||
pub maybe_mod_user_token: Option<&'a str>,
|
||||
|
||||
pub creator_ip_address: &'a str,
|
||||
pub creator_set_visibility: &'a Visibility,
|
||||
pub mysql_pool: &'a MySqlPool
|
||||
pub creator_ip_address: &'a str,
|
||||
pub creator_set_visibility: &'a Visibility,
|
||||
pub mysql_pool: &'a MySqlPool
|
||||
}
|
||||
|
||||
// pub async fn create_voice(args: CreateVoiceArgs<'_>) -> AnyhowResult<()>{
|
||||
// // TODO: enforce checks for idempotency token
|
||||
// let mut maybe_creator_synthetic_id : Option<u64> = None;
|
||||
//
|
||||
// let mut transaction = args.mysql_pool.begin().await?;
|
||||
// if let Some(creator_user_token) = args.maybe_creator_user_token.as_deref() {
|
||||
// let user_token = UserToken::new_from_str(creator_user_token);
|
||||
//
|
||||
// let next_zs_dataset_synthetic_id = transactional_increment_generic_synthetic_id(
|
||||
// &user_token,
|
||||
// IdCategory::ZsVoice,
|
||||
// &mut transaction
|
||||
// ).await?;
|
||||
//
|
||||
// maybe_creator_synthetic_id = Some(next_zs_dataset_synthetic_id);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
pub async fn create_voice(args: CreateVoiceArgs<'_>) -> AnyhowResult<ZsVoiceToken>{
|
||||
let voice_token = ZsVoiceToken::generate();
|
||||
|
||||
// TODO: enforce checks for idempotency token
|
||||
let mut maybe_creator_synthetic_id : Option<u64> = None;
|
||||
|
||||
let mut transaction = args.mysql_pool.begin().await?;
|
||||
|
||||
if let Some(creator_user_token) = args.maybe_creator_user_token.as_deref() {
|
||||
let next_zs_dataset_synthetic_id = transactional_increment_generic_synthetic_id(
|
||||
creator_user_token,
|
||||
IdCategory::ZsDataset,
|
||||
&mut transaction
|
||||
).await?;
|
||||
|
||||
maybe_creator_synthetic_id = Some(next_zs_dataset_synthetic_id);
|
||||
}
|
||||
// TODO(bt,2023-10-06): These should be parameters, and moreover they should be *enums*
|
||||
// to limit their possible values.
|
||||
const MODEL_CATEGORY : &str = "vc";
|
||||
const MODEL_TYPE : &str = "vall-e-x";
|
||||
const ENCODING_TYPE : &str = "encodec";
|
||||
|
||||
let query_result = sqlx::query!(
|
||||
r#"
|
||||
INSERT INTO zs_voices
|
||||
SET
|
||||
token = ?,
|
||||
dataset_token = ?,
|
||||
model_category = ?,
|
||||
model_type = ?,
|
||||
encoding_type = ?,
|
||||
title = ?,
|
||||
bucket_hash = ?,
|
||||
maybe_creator_user_token = ?,
|
||||
creator_ip_address = ?,
|
||||
creator_set_visibility = ?,
|
||||
maybe_creator_synthetic_id = ?
|
||||
"#,
|
||||
voice_token.as_str(),
|
||||
args.dataset_token,
|
||||
MODEL_CATEGORY,
|
||||
MODEL_TYPE,
|
||||
ENCODING_TYPE,
|
||||
args.voice_title,
|
||||
args.bucket_hash,
|
||||
args.maybe_creator_user_token,
|
||||
args.creator_ip_address,
|
||||
args.creator_set_visibility.to_str(),
|
||||
maybe_creator_synthetic_id
|
||||
).execute(args.mysql_pool).await;
|
||||
|
||||
// TODO(Kasisnu): This should probably rollback
|
||||
transaction.commit().await?;
|
||||
|
||||
match query_result {
|
||||
Ok(_) => Ok(voice_token),
|
||||
Err(err) => Err(anyhow!("zs voice creation error: {:?}", err)),
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user