mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 09:48:44 +00:00
Remove comments
This commit is contained in:
1 parent
b45f6ed691
commit
41b07049ff
1 file changed
+49
-55
@@ -10,54 +10,47 @@ use tokens::tokens::users::UserToken;
|
||||
|
||||
use crate::queries::generic_synthetic_ids::transactional_increment_generic_synthetic_id::transactional_increment_generic_synthetic_id;
|
||||
|
||||
|
||||
|
||||
// Model category? Zero shot?
|
||||
// Model type? end to end TTS / VC vs cascading TTS / VC
|
||||
// Model version? 1?
|
||||
// Encoding Type? npz ?
|
||||
//
|
||||
|
||||
pub struct CreateVoiceArgs<'a> {
|
||||
pub dataset_token: &'a ZsVoiceDatasetToken,
|
||||
pub dataset_token: &'a ZsVoiceDatasetToken,
|
||||
|
||||
// TODO(bt,2023-10-06): These should be *Rust Enums* to limit their possible range of values.
|
||||
pub model_category: &'a str,
|
||||
pub model_type: &'a str,
|
||||
pub model_version: u64,
|
||||
pub model_encoding_type: &'a str,
|
||||
// TODO(bt,2023-10-06): These should be *Rust Enums* to limit their possible range of values.
|
||||
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 UserToken>,
|
||||
|
||||
pub creator_ip_address: &'a str,
|
||||
pub creator_set_visibility: Visibility,
|
||||
pub mysql_pool: &'a MySqlPool
|
||||
pub creator_ip_address: &'a str,
|
||||
pub creator_set_visibility: Visibility,
|
||||
pub mysql_pool: &'a MySqlPool,
|
||||
}
|
||||
|
||||
pub async fn create_voice(args: CreateVoiceArgs<'_>) -> AnyhowResult<ZsVoiceToken>{
|
||||
let voice_token = ZsVoiceToken::generate();
|
||||
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;
|
||||
// TODO: enforce checks for idempotency token
|
||||
let mut maybe_creator_synthetic_id: Option<u64> = None;
|
||||
|
||||
let mut transaction = args.mysql_pool.begin().await?;
|
||||
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?;
|
||||
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);
|
||||
}
|
||||
maybe_creator_synthetic_id = Some(next_zs_dataset_synthetic_id);
|
||||
}
|
||||
|
||||
let query_result = sqlx::query!(
|
||||
r#"
|
||||
let query_result = sqlx
|
||||
::query(
|
||||
r#"
|
||||
INSERT INTO zs_voices
|
||||
SET
|
||||
token = ?,
|
||||
@@ -72,24 +65,25 @@ pub async fn create_voice(args: CreateVoiceArgs<'_>) -> AnyhowResult<ZsVoiceToke
|
||||
creator_set_visibility = ?,
|
||||
maybe_creator_synthetic_id = ?
|
||||
"#,
|
||||
voice_token.as_str(),
|
||||
args.dataset_token,
|
||||
args.model_category,
|
||||
args.model_type,
|
||||
args.model_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;
|
||||
voice_token.as_str(),
|
||||
args.dataset_token,
|
||||
args.model_category,
|
||||
args.model_type,
|
||||
args.model_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?;
|
||||
// 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)),
|
||||
}
|
||||
match query_result {
|
||||
Ok(_) => Ok(voice_token),
|
||||
Err(err) => Err(anyhow!("zs voice creation error: {:?}", err)),
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user