mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-08 11:01:35 +00:00
upload reference transcript file
This commit is contained in:
1 parent
4fda4cdda5
commit
72a18875ea
4 files changed
+55
-1
No files matched your search
+2
@@ -52,6 +52,7 @@ pub struct InferenceArgs<'s> {
|
||||
pub gpt_model_path: &'s Path,
|
||||
pub sovits_model_path: &'s Path,
|
||||
pub reference_audio_path: &'s Path,
|
||||
pub reference_transcript_path: &'s Path,
|
||||
pub output_audio_directory: &'s Path,
|
||||
|
||||
pub maybe_reference_free: Option<bool>,
|
||||
@@ -154,6 +155,7 @@ impl GptSovitsInferenceCommand {
|
||||
command.push_str(&format!(" --gpt_model {}", path_to_string(args.gpt_model_path)));
|
||||
command.push_str(&format!(" --sovits_model {}", path_to_string(args.sovits_model_path)));
|
||||
command.push_str(&format!(" --ref_audio {}", path_to_string(args.reference_audio_path)));
|
||||
//command.push_str(&format!(" --ref_transcript {}", path_to_string(args.reference_transcript_path)));
|
||||
command.push_str(&format!(" --output_path {}", path_to_string(args.output_audio_directory)));
|
||||
|
||||
if let Some(reference_free) = args.maybe_reference_free {
|
||||
|
||||
+14
@@ -24,11 +24,18 @@ static ALLOWED_TYPES_REF_AUDIO : Lazy<HashSet<&'static str>> = Lazy::new(|| {
|
||||
])
|
||||
});
|
||||
|
||||
static ALLOWED_TYPES_REF_TRANSCRIPT : Lazy<HashSet<&'static str>> = Lazy::new(|| {
|
||||
HashSet::from([
|
||||
"txt",
|
||||
])
|
||||
});
|
||||
|
||||
#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
|
||||
pub enum GptSovitsPackageFileType {
|
||||
GptModel,
|
||||
SovitsCheckpoint,
|
||||
ReferenceAudio,
|
||||
ReferenceTranscript,
|
||||
}
|
||||
|
||||
impl GptSovitsPackageFileType {
|
||||
@@ -39,6 +46,8 @@ impl GptSovitsPackageFileType {
|
||||
Some(GptSovitsPackageFileType::SovitsCheckpoint)
|
||||
} else if ALLOWED_TYPES_REF_AUDIO.contains(extension) {
|
||||
Some(GptSovitsPackageFileType::ReferenceAudio)
|
||||
} else if ALLOWED_TYPES_REF_TRANSCRIPT.contains(extension) {
|
||||
Some(GptSovitsPackageFileType::ReferenceTranscript)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -49,6 +58,7 @@ impl GptSovitsPackageFileType {
|
||||
GptSovitsPackageFileType::GptModel => ALLOWED_TYPES_GPT.contains(extension),
|
||||
GptSovitsPackageFileType::SovitsCheckpoint => ALLOWED_TYPES_SOVITS.contains(extension),
|
||||
GptSovitsPackageFileType::ReferenceAudio => ALLOWED_TYPES_REF_AUDIO.contains(extension),
|
||||
GptSovitsPackageFileType::ReferenceTranscript => ALLOWED_TYPES_REF_TRANSCRIPT.contains(extension),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +70,7 @@ impl GptSovitsPackageFileType {
|
||||
Self::GptModel,
|
||||
Self::SovitsCheckpoint,
|
||||
Self::ReferenceAudio,
|
||||
Self::ReferenceTranscript,
|
||||
])
|
||||
}
|
||||
|
||||
@@ -68,6 +79,7 @@ impl GptSovitsPackageFileType {
|
||||
GptSovitsPackageFileType::GptModel => "gpt_model",
|
||||
GptSovitsPackageFileType::SovitsCheckpoint => "sovits_checkpoint",
|
||||
GptSovitsPackageFileType::ReferenceAudio => "reference_audio",
|
||||
GptSovitsPackageFileType::ReferenceTranscript => "reference_transcript",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +94,7 @@ pub enum GptSovitsPackageError {
|
||||
InvalidGPTModel(String),
|
||||
InvalidSovitsCheckpoint(String),
|
||||
InvalidReferenceAudio(String),
|
||||
InvalidReferenceTranscript(String),
|
||||
UploadError,
|
||||
TooManyFiles,
|
||||
ExtractionError,
|
||||
@@ -98,5 +111,6 @@ pub struct GptSovitsPackageDetails {
|
||||
pub gpt_model: GptSovitsPackageFile,
|
||||
pub sovits_checkpoint: GptSovitsPackageFile,
|
||||
pub reference_audio: GptSovitsPackageFile,
|
||||
pub reference_transcript: GptSovitsPackageFile,
|
||||
}
|
||||
|
||||
+3
@@ -90,12 +90,14 @@ pub async fn process_single_gpt_sovits_tts_job(
|
||||
let stderr_output_file = work_temp_dir.path().join("stderr.txt");
|
||||
let stdout_output_file = work_temp_dir.path().join("stdout.txt");
|
||||
let text_input_fs_path = work_temp_dir.path().join("inference_input.txt");
|
||||
|
||||
std::fs::write(&text_input_fs_path, &input_text)
|
||||
.map_err(|e| ProcessSingleJobError::from_io_error(e))?;
|
||||
|
||||
let gpt_model_path = weights_directory.join(format!("{}{}", model_token.as_str(), GptSovitsPackageFileType::GptModel.get_expected_package_suffix()));
|
||||
let sovits_model_path = weights_directory.join(format!("{}{}", model_token.as_str(), GptSovitsPackageFileType::SovitsCheckpoint.get_expected_package_suffix()));
|
||||
let reference_audio_path = weights_directory.join(format!("{}{}", model_token.as_str(), GptSovitsPackageFileType::ReferenceAudio.get_expected_package_suffix()));
|
||||
let reference_transcript_path = weights_directory.join(format!("{}{}", model_token.as_str(), GptSovitsPackageFileType::ReferenceTranscript.get_expected_package_suffix()));
|
||||
|
||||
let inference_start_time = Instant::now();
|
||||
let command_exit_status = gpt_sovits_deps
|
||||
@@ -107,6 +109,7 @@ pub async fn process_single_gpt_sovits_tts_job(
|
||||
gpt_model_path: &gpt_model_path,
|
||||
sovits_model_path: &sovits_model_path,
|
||||
reference_audio_path: &reference_audio_path,
|
||||
reference_transcript_path: &reference_transcript_path,
|
||||
output_audio_directory: &output_dir,
|
||||
maybe_reference_free: None,
|
||||
maybe_temperature: None,
|
||||
|
||||
+36
-1
@@ -32,6 +32,7 @@ pub async fn extract_and_upload_gpt_sovits_package_files(
|
||||
let mut gpt_model: Option<GptSovitsPackageFile> = None;
|
||||
let mut sovits_checkpoint: Option<GptSovitsPackageFile> = None;
|
||||
let mut reference_audio: Option<GptSovitsPackageFile> = None;
|
||||
let mut reference_transcript : Option<GptSovitsPackageFile> = None;
|
||||
|
||||
let entries = get_relevant_zip_entries(&mut archive)?;
|
||||
|
||||
@@ -39,13 +40,13 @@ pub async fn extract_and_upload_gpt_sovits_package_files(
|
||||
info!("Entry: {:?}", entry);
|
||||
|
||||
let enclosed_name = path_to_string(&entry.enclosed_name);
|
||||
|
||||
let mut file = archive.by_name(&enclosed_name)
|
||||
.map_err(|err| {
|
||||
error!("Problem reading file from archive: {:?}", err);
|
||||
GptSovitsPackageError::InvalidArchive
|
||||
})?;
|
||||
|
||||
|
||||
let mut zip_item_bytes = Vec::new();
|
||||
|
||||
file.read_to_end(&mut zip_item_bytes)
|
||||
@@ -145,6 +146,36 @@ pub async fn extract_and_upload_gpt_sovits_package_files(
|
||||
file_size_bytes: file_size_bytes as u64,
|
||||
});
|
||||
},
|
||||
GptSovitsPackageFileType::ReferenceTranscript => {
|
||||
let bucket_public_upload_path = WeightFileBucketPath::from_object_hash(
|
||||
weights_file_bucket_directory.get_object_hash(),
|
||||
Some("weight_"),
|
||||
Some(&entry.package_type.get_expected_package_suffix()),
|
||||
);
|
||||
info!("Uploading reference transcript package to {:?}", bucket_public_upload_path.get_full_object_path_str());
|
||||
bucket_client.upload_file(
|
||||
bucket_public_upload_path.get_full_object_path_str(),
|
||||
zip_item_bytes.as_ref())
|
||||
.await
|
||||
.map_err(|e| {
|
||||
warn!("Upload reference transcript package to bucket error: {:?}", e);
|
||||
GptSovitsPackageError::UploadError
|
||||
})?;
|
||||
|
||||
let hash = sha256_hash_bytes(&zip_item_bytes)
|
||||
.map_err(|io_error| {
|
||||
error!("Problem hashing bytes: {:?}", io_error);
|
||||
GptSovitsPackageError::UploadError
|
||||
})?;
|
||||
|
||||
let file_size_bytes = zip_item_bytes.len();
|
||||
|
||||
reference_transcript = Some(GptSovitsPackageFile {
|
||||
public_upload_path: bucket_public_upload_path,
|
||||
sha256_checksum: hash,
|
||||
file_size_bytes: file_size_bytes as u64,
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,6 +183,7 @@ pub async fn extract_and_upload_gpt_sovits_package_files(
|
||||
gpt_model: gpt_model.ok_or(GptSovitsPackageError::InvalidArchive)?,
|
||||
sovits_checkpoint: sovits_checkpoint.ok_or(GptSovitsPackageError::InvalidArchive)?,
|
||||
reference_audio: reference_audio.ok_or(GptSovitsPackageError::InvalidArchive)?,
|
||||
reference_transcript: reference_transcript.ok_or(GptSovitsPackageError::InvalidArchive)?,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -220,6 +252,9 @@ fn get_relevant_zip_entries(archive: &mut ZipArchive<BufReader<Cursor<&[u8]>>>)
|
||||
GptSovitsPackageFileType::ReferenceAudio => {
|
||||
Err(GptSovitsPackageError::InvalidReferenceAudio("Multiple reference audio files found".to_string()))
|
||||
}
|
||||
GptSovitsPackageFileType::ReferenceTranscript => {
|
||||
Err(GptSovitsPackageError::InvalidReferenceTranscript("Multiple reference transcript files found".to_string()))
|
||||
}
|
||||
}
|
||||
}
|
||||
info!("Adding file with name {} extension: {}", enclosed_name.display(), extension);
|
||||
|
||||
Reference in new issue
Block a user