mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 17:58:55 +00:00
synthetic IDs for TTS
This commit is contained in:
1 parent
31effd2ea8
commit
76c2fe446c
4 files changed
+59
-76
No files matched your search
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
# ONLY FOR LOCAL DEV
|
||||
|
||||
mysql -u storyteller \
|
||||
-ppassword \
|
||||
-h localhost \
|
||||
-D storyteller \
|
||||
-e "select * from tts_results\G"
|
||||
|
||||
|
||||
#echo '==============================================='
|
||||
#
|
||||
#read -r -d '' query << EOF
|
||||
#
|
||||
# SELECT
|
||||
# w2l_results.token as w2l_result_token,
|
||||
# w2l_results.maybe_tts_inference_result_token,
|
||||
# w2l_templates.token as maybe_w2l_template_token,
|
||||
# w2l_templates.template_type,
|
||||
# users.token as maybe_creator_user_token,
|
||||
# users.username as maybe_creator_username,
|
||||
# users.display_name as maybe_creator_display_name,
|
||||
# w2l_results.file_size_bytes,
|
||||
# w2l_results.frame_width,
|
||||
# w2l_results.frame_height,
|
||||
# w2l_results.duration_millis,
|
||||
# w2l_results.created_at,
|
||||
# w2l_results.updated_at
|
||||
# FROM
|
||||
# w2l_results
|
||||
# LEFT OUTER JOIN w2l_templates ON w2l_results.maybe_w2l_template_token = w2l_templates.token
|
||||
# LEFT OUTER JOIN users ON w2l_results.maybe_creator_user_token = users.token
|
||||
# WHERE
|
||||
# w2l_results.deleted_at IS NULL
|
||||
# AND users.username = 'echelon'\G
|
||||
#EOF
|
||||
#
|
||||
#echo $query
|
||||
#
|
||||
#mysql -u root \
|
||||
# -proot \
|
||||
# -h localhost \
|
||||
# -D storyteller \
|
||||
# -e "${query}"
|
||||
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
# ONLY FOR LOCAL DEV
|
||||
mysql -u storyteller \
|
||||
-ppassword \
|
||||
-h localhost \
|
||||
-D storyteller \
|
||||
-e "select * from tts_result_synthetic_ids\G"
|
||||
@@ -29,6 +29,8 @@ pub struct TtsInferenceRecordForList {
|
||||
pub maybe_creator_username: Option<String>,
|
||||
pub maybe_creator_display_name: Option<String>,
|
||||
|
||||
pub maybe_creator_result_id: Option<u64>,
|
||||
|
||||
pub file_size_bytes: u32,
|
||||
pub duration_millis: u32,
|
||||
|
||||
@@ -120,6 +122,7 @@ impl ListTtsResultsQueryBuilder {
|
||||
maybe_creator_user_token: r.maybe_creator_user_token.clone(),
|
||||
maybe_creator_username: r.maybe_creator_username.clone(),
|
||||
maybe_creator_display_name: r.maybe_creator_display_name.clone(),
|
||||
maybe_creator_result_id: r.maybe_creator_result_id.map(|v| v as u64).clone(),
|
||||
file_size_bytes: if r.file_size_bytes > 0 { r.file_size_bytes as u32 } else { 0 },
|
||||
duration_millis: if r.duration_millis > 0 { r.duration_millis as u32 } else { 0 },
|
||||
created_at: r.created_at,
|
||||
@@ -183,6 +186,8 @@ SELECT
|
||||
users.username as maybe_creator_username,
|
||||
users.display_name as maybe_creator_display_name,
|
||||
|
||||
tts_results.maybe_creator_synthetic_id as maybe_creator_result_id,
|
||||
|
||||
tts_results.file_size_bytes,
|
||||
tts_results.duration_millis,
|
||||
tts_results.created_at,
|
||||
@@ -279,6 +284,8 @@ pub struct RawInternalTtsRecord {
|
||||
pub maybe_creator_username: Option<String>,
|
||||
pub maybe_creator_display_name: Option<String>,
|
||||
|
||||
pub maybe_creator_result_id: Option<i64>,
|
||||
|
||||
pub file_size_bytes : i64,
|
||||
pub duration_millis : i64,
|
||||
pub created_at: DateTime<Utc>,
|
||||
|
||||
@@ -247,15 +247,6 @@ pub async fn insert_tts_result<P: AsRef<Path>>(
|
||||
let mut transaction = pool.begin().await?;
|
||||
|
||||
if let Some(creator_user_token) = maybe_creator_user_token.as_deref() {
|
||||
|
||||
info!(">>>>> Creating synthetic for {}", creator_user_token);
|
||||
|
||||
//let synthetic_id = {
|
||||
// let id = get_incremented_synthetic_id(creator_user_token, &mut transaction).await?;
|
||||
// id
|
||||
//};
|
||||
//maybe_creator_synthetic_id = Some(synthetic_id);
|
||||
|
||||
let query_result = sqlx::query!(
|
||||
r#"
|
||||
INSERT INTO tts_result_synthetic_ids
|
||||
@@ -306,8 +297,6 @@ LIMIT 1
|
||||
|
||||
let next_id = record.next_id as u64;
|
||||
|
||||
info!(">>>>> synthetic is {}", next_id);
|
||||
|
||||
maybe_creator_synthetic_id = Some(next_id);
|
||||
}
|
||||
|
||||
@@ -379,71 +368,6 @@ pub struct SyntheticIdRecord {
|
||||
pub next_id: i64,
|
||||
}
|
||||
|
||||
/*async fn get_incremented_synthetic_id<'a>(
|
||||
user_token: &str,
|
||||
transaction: &mut Transaction<'a, MySql>
|
||||
) -> AnyhowResult<u64> {
|
||||
|
||||
let do_rollback = {
|
||||
let query_result = sqlx::query!(
|
||||
r#"
|
||||
INSERT INTO tts_result_synthetic_ids
|
||||
SET
|
||||
user_token = ?,
|
||||
next_id = 1
|
||||
ON DUPLICATE KEY UPDATE
|
||||
user_token = ?,
|
||||
next_id = next_id + 1
|
||||
"#,
|
||||
user_token,
|
||||
user_token
|
||||
)
|
||||
.execute(transaction)
|
||||
.await;
|
||||
|
||||
match query_result {
|
||||
Ok(_) => false,
|
||||
Err(err) => {
|
||||
warn!("Transaction failure: {:?}", err);
|
||||
true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if do_rollback {
|
||||
transaction.rollback().await?;
|
||||
return Err(anyhow!("Transaction failure"));
|
||||
}
|
||||
|
||||
let query_result = sqlx::query_as!(
|
||||
SyntheticIdRecord,
|
||||
r#"
|
||||
SELECT
|
||||
next_id
|
||||
FROM
|
||||
tts_result_synthetic_ids
|
||||
WHERE
|
||||
user_token = ?
|
||||
LIMIT 1
|
||||
"#,
|
||||
user_token,
|
||||
)
|
||||
.fetch_one(transaction)
|
||||
.await;
|
||||
|
||||
let record : SyntheticIdRecord = match query_result {
|
||||
Ok(record) => record,
|
||||
Err(err) => {
|
||||
warn!("Transaction failure: {:?}", err);
|
||||
transaction.rollback().await?;
|
||||
return Err(anyhow!("Transaction failure: {:?}", err));
|
||||
}
|
||||
};
|
||||
|
||||
let next_id = record.next_id as u64;
|
||||
Ok(next_id)
|
||||
}*/
|
||||
|
||||
pub struct TtsModelRecord2 {
|
||||
pub model_token: String,
|
||||
pub tts_model_type: String,
|
||||
|
||||
Reference in new issue
Block a user