Merge pull request #81 from storytold/echelon-test-weights

Add zero shot weights and upload six test files; add to db seed tool
This commit is contained in:
Brandon Thomas authored and GitHub committed 2023-10-06 12:51:20 -04:00
commit 63795b2cb6
4 files changed
+73 -3

No files matched your search

@@ -18,9 +18,12 @@ pub async fn seed_zero_shot_tts(mysql_pool: &Pool<MySql>) -> AnyhowResult<()> {
};
let records = [
("Goku", "todo", &user_token),
("David Attenborough", "todo", &user_token),
("Ash Ketchum", "todo", &user_token),
("Alice", "qtqaprnd5shtybve4fqpvcfp50yjw238fbgj92z1521c50xqdxy1akkhkw7tesj0", &user_token),
("Biden", "n945w0xsq15xrh16hc147a5mc1a91gwh886e14qqzte1gr9z9q3yawjfvanp4fmg", &user_token),
("Goku", "cnnv05yjst2m737dpmxazgfpksjf4y7cxxern2ph7gddgnkh2bw1ephg5mhjbz14", &user_token),
("Hilary", "7wav68ba2yy86491jk36cgk36tkmzesr452dgfs28wchkrr03bd0h3e6c1bbz9eg", &user_token),
("Obama", "z3gy4v56sgtfrxfrpvaj7v74sqc67rcqs89jb884b00zfdm9vmkf1w2fsnta0gwp", &user_token),
("Trump", "qcy7pv3rph0ntkqnpz5cfg9ksyh7kkz53v1wbr2ckvt8znvhxqn7ca5mz7wzm3q5", &user_token),
];
for (voice_name, bucket_hash, user_token) in records {
@@ -17,6 +17,8 @@ pub struct BucketPathUnifier {
pub w2l_inference_output_root: PathBuf,
pub w2l_model_root: PathBuf,
pub w2l_end_bump_root: PathBuf,
// Zero shot
pub zs_tts_speaker_embedding_root: PathBuf,
// VC
pub rvc_v2_model_root: PathBuf,
pub softvc_model_root: PathBuf,
@@ -39,6 +41,8 @@ impl BucketPathUnifier {
w2l_inference_output_root: PathBuf::from("/w2l_inference_output"),
w2l_model_root: PathBuf::from("/w2l_pretrained_models"),
w2l_end_bump_root: PathBuf::from("/w2l_end_bumps"),
// Zero shot
zs_tts_speaker_embedding_root: PathBuf::from("/user/zero_shot_embeddings/tts"),
// VC
rvc_v2_model_root: PathBuf::from("/user_uploaded_rvc_v2_models"),
softvc_model_root: PathBuf::from("/user_uploaded_softvc_models"),
@@ -197,6 +201,19 @@ impl BucketPathUnifier {
.join(video_filename)
}
// ==================== ZERO SHOT SPEAKER EMBEDDINGS ==================== //
// NB: Entropic hash is not based on file hash and will be reused for future encodings.
pub fn zero_shot_tts_speaker_encoding(&self, entropic_hash: &str, version: u32) -> PathBuf {
let hashed_path = Self::hashed_directory_path(entropic_hash);
let speaker_encoding_filename = format!("{}_{}.zs", &entropic_hash, version);
self.zs_tts_speaker_embedding_root
.join(hashed_path)
.join(speaker_encoding_filename)
}
// ==================== VOICE CONVERSION MODELS ==================== //
// NB: Entropic hash is not based on file hash and is shared between .pth and .index files.
@@ -279,6 +296,7 @@ mod tests {
w2l_model_root: PathBuf::from("/test_path_w2l_pretrained_models"),
w2l_end_bump_root: PathBuf::from("/test_path_w2l_end_bumps"),
// VOICE CONVERSION
zs_tts_speaker_embedding_root: PathBuf::from("/test/zs_tts_speaker_embedding_root"),
rvc_v2_model_root: PathBuf::from("/test_path_rvc_v2_models"),
softvc_model_root: PathBuf::from("/test_path_softvc_models"),
so_vits_svc_model_root: PathBuf::from("/test_path_so_vits_svc_models"),
@@ -383,6 +401,27 @@ mod tests {
"/test_path_w2l_output/a/b/c/vocodes_video_TYPEABCDEF.mp4");
}
#[test]
fn test_zero_shot_tts_speaker_encoding_paths() {
let paths = get_instance();
let entropic_hash = "entropic";
let version = 0;
assert_eq!(paths.zero_shot_tts_speaker_encoding(entropic_hash, version).to_str().unwrap(),
"/test/zs_tts_speaker_embedding_root/e/n/t/entropic_0.zs");
let version = 23;
assert_eq!(paths.zero_shot_tts_speaker_encoding(entropic_hash, version).to_str().unwrap(),
"/test/zs_tts_speaker_embedding_root/e/n/t/entropic_23.zs");
}
//#[test]
//fn test_temp() {
// // TODO/TEMP: Generating paths to use in dev
// let unifier = BucketPathUnifier::default_paths();
// let path = unifier.zero_shot_tts_speaker_encoding("qcy7pv3rph0ntkqnpz5cfg9ksyh7kkz53v1wbr2ckvt8znvhxqn7ca5mz7wzm3q5", 0);
// assert_eq!(path.to_str().unwrap(), "");
//}
#[test]
fn test_rvc_model_and_index_paths() {
let paths = get_instance();
@@ -180,3 +180,15 @@ pub async fn process_rvc_v2_model<'a, 'b>(
entity_type: Some(VoiceConversionModelType::RvcV2.to_string()), // NB: This may be different from `GenericDownloadType` in the future!
})
}
//#[cfg(test)]
//mod tests {
// use crockford::crockford_entropy_lower;
//
// #[test]
// fn temp() {
// // need to make some hashes really quick
// let e = crockford_entropy_lower(64);
// assert_eq!(e, "");
// }
//}
@@ -247,6 +247,22 @@ async fn main() -> AnyhowResult<()> {
job_stats: job_stats.clone(),
};
//// TODO/REMOVE - testing download of the dev weights
//let records = [
// ("Alice", "qtqaprnd5shtybve4fqpvcfp50yjw238fbgj92z1521c50xqdxy1akkhkw7tesj0"),
// ("Biden", "n945w0xsq15xrh16hc147a5mc1a91gwh886e14qqzte1gr9z9q3yawjfvanp4fmg"),
// ("Goku", "cnnv05yjst2m737dpmxazgfpksjf4y7cxxern2ph7gddgnkh2bw1ephg5mhjbz14"),
// ("Hilary", "7wav68ba2yy86491jk36cgk36tkmzesr452dgfs28wchkrr03bd0h3e6c1bbz9eg"),
// ("Obama", "z3gy4v56sgtfrxfrpvaj7v74sqc67rcqs89jb884b00zfdm9vmkf1w2fsnta0gwp"),
// ("Trump", "qcy7pv3rph0ntkqnpz5cfg9ksyh7kkz53v1wbr2ckvt8znvhxqn7ca5mz7wzm3q5"),
//];
//let paths = BucketPathUnifier::default_paths();
//for (name, hash) in records {
// let object_path = paths.zero_shot_tts_speaker_encoding(hash, 0);
// let filesystem_path = format!("{}_weights.npz", name);
// private_bucket_client.download_file_to_disk(object_path, filesystem_path).await?;
//}
let job_dependencies = JobDependencies {
scoped_execution: ScopedExecution::new_from_env()?,
fs: FileSystemDetails {