mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 09:48:44 +00:00
tacotron2
This commit is contained in:
1 parent
2856be7aa9
commit
58ce32dcbb
6 files changed
+64
-43
No files matched your search
+1
@@ -1,4 +1,5 @@
|
||||
pub mod process_job;
|
||||
pub mod read_metadata_file;
|
||||
pub mod seconds_to_decoder_steps;
|
||||
pub mod tacotron2_dependencies;
|
||||
pub mod tacotron2_inference_command;
|
||||
+15
-6
@@ -32,7 +32,6 @@ use crate::util::maybe_download_file_from_bucket::maybe_download_file_from_bucke
|
||||
/// This allows the request to bypass the model cache and query the latest TTS model.
|
||||
const TEST_REQUEST_TEXT: &str = "This is a test request.";
|
||||
|
||||
|
||||
pub struct ProcessJobArgs<'a> {
|
||||
pub job_dependencies: &'a JobDependencies,
|
||||
pub job: &'a AvailableInferenceJob,
|
||||
@@ -50,10 +49,18 @@ pub async fn process_job(args: ProcessJobArgs<'_>) -> Result<JobSuccessResult, P
|
||||
.new_generic_inference(job.inference_job_token.as_str())
|
||||
.map_err(|e| ProcessSingleJobError::Other(anyhow!(e)))?;
|
||||
|
||||
let model_dependencies = args
|
||||
.job_dependencies
|
||||
.job_specific_dependencies
|
||||
.maybe_tacotron2_dependencies
|
||||
.as_ref()
|
||||
.ok_or_else(|| ProcessSingleJobError::JobSystemMisconfiguration(Some("missing Tacotron2 dependencies".to_string())))?;
|
||||
|
||||
// ==================== CONFIRM OR DOWNLOAD WAVEGLOW VOCODER MODEL ==================== //
|
||||
|
||||
let waveglow_vocoder_model_fs_path = {
|
||||
let waveglow_vocoder_model_filename = args.job_dependencies.job_type_details.tacotron2_old_vocodes.waveglow_vocoder_model_filename.clone();
|
||||
// TODO(bt,2023-11-21): Port this to the common downloader code.
|
||||
let waveglow_vocoder_model_filename = model_dependencies.waveglow_vocoder_model_filename.clone();
|
||||
let waveglow_vocoder_model_fs_path = args.job_dependencies.fs.semi_persistent_cache.tts_pretrained_vocoder_model_path(&waveglow_vocoder_model_filename);
|
||||
let waveglow_vocoder_model_object_path = args.job_dependencies.bucket_path_unifier.tts_pretrained_vocoders_path(&waveglow_vocoder_model_filename);
|
||||
|
||||
@@ -74,7 +81,8 @@ pub async fn process_job(args: ProcessJobArgs<'_>) -> Result<JobSuccessResult, P
|
||||
// ==================== CONFIRM OR DOWNLOAD HIFIGAN (NORMAL) VOCODER MODEL ==================== //
|
||||
|
||||
let pretrained_hifigan_vocoder_model_fs_path = {
|
||||
let hifigan_vocoder_model_filename = args.job_dependencies.job_type_details.tacotron2_old_vocodes.hifigan_vocoder_model_filename.clone();
|
||||
// TODO(bt,2023-11-21): Port this to the common downloader code.
|
||||
let hifigan_vocoder_model_filename = model_dependencies.hifigan_vocoder_model_filename.clone();
|
||||
let hifigan_vocoder_model_fs_path = args.job_dependencies.fs.semi_persistent_cache.tts_pretrained_vocoder_model_path(&hifigan_vocoder_model_filename);
|
||||
let hifigan_vocoder_model_object_path = args.job_dependencies.bucket_path_unifier.tts_pretrained_vocoders_path(&hifigan_vocoder_model_filename);
|
||||
|
||||
@@ -95,7 +103,8 @@ pub async fn process_job(args: ProcessJobArgs<'_>) -> Result<JobSuccessResult, P
|
||||
// ==================== CONFIRM OR DOWNLOAD HIFIGAN (SUPERRES) VOCODER MODEL ==================== //
|
||||
|
||||
let hifigan_superres_vocoder_model_fs_path = {
|
||||
let hifigan_superres_vocoder_model_filename = args.job_dependencies.job_type_details.tacotron2_old_vocodes.hifigan_superres_vocoder_model_filename.clone();
|
||||
// TODO(bt,2023-11-21): Port this to the common downloader code.
|
||||
let hifigan_superres_vocoder_model_filename = model_dependencies.hifigan_superres_vocoder_model_filename.clone();
|
||||
let hifigan_superres_vocoder_model_fs_path = args.job_dependencies.fs.semi_persistent_cache.tts_pretrained_vocoder_model_path(&hifigan_superres_vocoder_model_filename);
|
||||
let hifigan_superres_vocoder_model_object_path = args.job_dependencies.bucket_path_unifier.tts_pretrained_vocoders_path(&hifigan_superres_vocoder_model_filename);
|
||||
|
||||
@@ -113,7 +122,7 @@ pub async fn process_job(args: ProcessJobArgs<'_>) -> Result<JobSuccessResult, P
|
||||
hifigan_superres_vocoder_model_fs_path
|
||||
};
|
||||
|
||||
// // ==================== CONFIRM OR DOWNLOAD OPTIONAL CUSTOM VOCODER MODEL ==================== //
|
||||
// ==================== CONFIRM OR DOWNLOAD OPTIONAL CUSTOM VOCODER MODEL ==================== //
|
||||
|
||||
let custom_vocoder_fs_path = match &tts_model.maybe_custom_vocoder {
|
||||
None => None,
|
||||
@@ -249,7 +258,7 @@ pub async fn process_job(args: ProcessJobArgs<'_>) -> Result<JobSuccessResult, P
|
||||
|
||||
let inference_start_time = Instant::now();
|
||||
|
||||
let _r = args.job_dependencies.job_type_details.tacotron2_old_vocodes.inference_command.execute_inference(InferenceArgs {
|
||||
let _r = model_dependencies.inference_command.execute_inference(InferenceArgs {
|
||||
synthesizer_checkpoint_path: &tts_synthesizer_fs_path,
|
||||
text_pipeline_type: text_pipeline_type_or_guess.to_str(),
|
||||
vocoder: vocoder_option,
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
use errors::AnyhowResult;
|
||||
use crate::job::job_types::tts::tacotron2_v2_early_fakeyou::tacotron2_inference_command::Tacotron2InferenceCommand;
|
||||
|
||||
pub struct Tacotron2Dependencies {
|
||||
pub inference_command: Tacotron2InferenceCommand,
|
||||
|
||||
/// Common pretrained waveglow vocoder filename
|
||||
pub waveglow_vocoder_model_filename: String,
|
||||
|
||||
/// Common pretrained hifigan vocoder filename
|
||||
pub hifigan_vocoder_model_filename: String,
|
||||
|
||||
/// Common pretrained hifigan super resolution vocoder filename
|
||||
pub hifigan_superres_vocoder_model_filename: String,
|
||||
}
|
||||
|
||||
impl Tacotron2Dependencies {
|
||||
pub fn setup() -> AnyhowResult<Self> {
|
||||
|
||||
let waveglow_vocoder_model_filename = easyenv::get_env_string_or_default(
|
||||
"TTS_WAVEGLOW_VOCODER_MODEL_FILENAME", "waveglow.pth");
|
||||
|
||||
let hifigan_vocoder_model_filename = easyenv::get_env_string_or_default(
|
||||
"TTS_HIFIGAN_VOCODER_MODEL_FILENAME", "hifigan.pth");
|
||||
|
||||
let hifigan_superres_vocoder_model_filename = easyenv::get_env_string_or_default(
|
||||
"TTS_HIFIGAN_SUPERRES_VOCODER_MODEL_FILENAME", "hifigan_superres.pth");
|
||||
|
||||
Ok(Self {
|
||||
inference_command: Tacotron2InferenceCommand::from_env()?,
|
||||
waveglow_vocoder_model_filename,
|
||||
hifigan_vocoder_model_filename,
|
||||
hifigan_superres_vocoder_model_filename,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ use mysql_queries::queries::tts::tts_models::get_tts_model_for_inference_improve
|
||||
use mysql_queries::queries::voice_conversion::inference::get_voice_conversion_model_for_inference::VoiceConversionModelForInference;
|
||||
use newrelic_telemetry::Client as NewRelicClient;
|
||||
|
||||
use crate::job::job_types::tts::tacotron2_v2_early_fakeyou::tacotron2_inference_command::Tacotron2InferenceCommand;
|
||||
use crate::job::job_types::tts::vall_e_x::model_downloaders::VallEXDownloaders;
|
||||
use crate::job::job_types::tts::vall_e_x::vall_e_x_inference_command::VallEXCreateEmbeddingCommand;
|
||||
use crate::job::job_types::tts::vall_e_x::vall_e_x_inference_command::VallEXInferenceCommand;
|
||||
@@ -158,25 +157,8 @@ pub struct JobCaches {
|
||||
|
||||
/// Per-job type details
|
||||
pub struct JobTypeDetails {
|
||||
pub tacotron2_old_vocodes: Tacotron2VocodesDetails,
|
||||
pub vits: VitsDetails,
|
||||
pub vall_e_x: VallEXDetails
|
||||
//pub tacotron2_modern: ...,
|
||||
//pub softvc: ...,
|
||||
}
|
||||
|
||||
/// "Old" TT2 (vocodes-era)
|
||||
pub struct Tacotron2VocodesDetails {
|
||||
pub inference_command: Tacotron2InferenceCommand,
|
||||
|
||||
/// Common pretrained waveglow vocoder filename
|
||||
pub waveglow_vocoder_model_filename: String,
|
||||
|
||||
/// Common pretrained hifigan vocoder filename
|
||||
pub hifigan_vocoder_model_filename: String,
|
||||
|
||||
/// Common pretrained hifigan super resolution vocoder filename
|
||||
pub hifigan_superres_vocoder_model_filename: String,
|
||||
}
|
||||
|
||||
pub struct VitsDetails {
|
||||
|
||||
@@ -4,6 +4,7 @@ use enums::by_table::generic_inference_jobs::inference_model_type::InferenceMode
|
||||
use errors::AnyhowResult;
|
||||
|
||||
use crate::job::job_types::lipsync::sad_talker::sad_talker_dependencies::SadTalkerDependencies;
|
||||
use crate::job::job_types::tts::tacotron2_v2_early_fakeyou::tacotron2_dependencies::Tacotron2Dependencies;
|
||||
use crate::job::job_types::vc::rvc_v2::rvc_v2_dependencies::RvcV2Dependencies;
|
||||
use crate::job::job_types::vc::so_vits_svc::svc_dependencies::SvcDependencies;
|
||||
use crate::util::scoped_execution::ScopedExecution;
|
||||
@@ -12,6 +13,7 @@ pub struct JobSpecificDependencies {
|
||||
pub maybe_rvc_v2_dependencies: Option<RvcV2Dependencies>,
|
||||
pub maybe_sad_talker_dependencies: Option<SadTalkerDependencies>,
|
||||
pub maybe_svc_dependencies: Option<SvcDependencies>,
|
||||
pub maybe_tacotron2_dependencies: Option<Tacotron2Dependencies>,
|
||||
}
|
||||
|
||||
impl JobSpecificDependencies {
|
||||
@@ -20,6 +22,7 @@ impl JobSpecificDependencies {
|
||||
let mut maybe_rvc_v2_dependencies = None;
|
||||
let mut maybe_sad_talker_dependencies = None;
|
||||
let mut maybe_svc_dependencies = None;
|
||||
let mut maybe_tacotron2_dependencies = None;
|
||||
|
||||
if scoped_execution.can_run_job(InferenceModelType::RvcV2) {
|
||||
info!("Setting RVCv2 dependencies...");
|
||||
@@ -36,10 +39,16 @@ impl JobSpecificDependencies {
|
||||
maybe_svc_dependencies = Some(SvcDependencies::setup()?);
|
||||
}
|
||||
|
||||
if scoped_execution.can_run_job(InferenceModelType::Tacotron2) {
|
||||
info!("Setting Tacotron2 dependencies...");
|
||||
maybe_tacotron2_dependencies = Some(Tacotron2Dependencies::setup()?);
|
||||
}
|
||||
|
||||
Ok(JobSpecificDependencies {
|
||||
maybe_rvc_v2_dependencies,
|
||||
maybe_sad_talker_dependencies,
|
||||
maybe_svc_dependencies
|
||||
maybe_svc_dependencies,
|
||||
maybe_tacotron2_dependencies,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -50,12 +50,11 @@ use subprocess_common::docker_options::{DockerEnvVar, DockerFilesystemMount, Doc
|
||||
use crate::http_server::run_http_server::CreateServerArgs;
|
||||
use crate::http_server::run_http_server::launch_http_server;
|
||||
use crate::job::job_loop::main_loop::main_loop;
|
||||
use crate::job::job_types::tts::tacotron2_v2_early_fakeyou::tacotron2_inference_command::Tacotron2InferenceCommand;
|
||||
use crate::job::job_types::tts::vall_e_x::model_downloaders::VallEXDownloaders;
|
||||
use crate::job::job_types::tts::vall_e_x::vall_e_x_inference_command::VallEXCreateEmbeddingCommand;
|
||||
use crate::job::job_types::tts::vall_e_x::vall_e_x_inference_command::VallEXInferenceCommand;
|
||||
use crate::job::job_types::tts::vits::vits_inference_command::VitsInferenceCommand;
|
||||
use crate::job_dependencies::{FileSystemDetails, JobCaches, JobDependencies, JobTypeDetails, JobWorkerDetails, Tacotron2VocodesDetails, VallEXDetails, VitsDetails};
|
||||
use crate::job_dependencies::{FileSystemDetails, JobCaches, JobDependencies, JobTypeDetails, JobWorkerDetails, VallEXDetails, VitsDetails};
|
||||
use crate::job_specific_dependencies::JobSpecificDependencies;
|
||||
use crate::util::scoped_execution::ScopedExecution;
|
||||
use crate::util::scoped_temp_dir_creator::ScopedTempDirCreator;
|
||||
@@ -169,15 +168,6 @@ async fn main() -> AnyhowResult<()> {
|
||||
|
||||
let common_env = CommonEnv::read_from_env()?;
|
||||
|
||||
let waveglow_vocoder_model_filename = easyenv::get_env_string_or_default(
|
||||
"TTS_WAVEGLOW_VOCODER_MODEL_FILENAME", "waveglow.pth");
|
||||
|
||||
let hifigan_vocoder_model_filename = easyenv::get_env_string_or_default(
|
||||
"TTS_HIFIGAN_VOCODER_MODEL_FILENAME", "hifigan.pth");
|
||||
|
||||
let hifigan_superres_vocoder_model_filename = easyenv::get_env_string_or_default(
|
||||
"TTS_HIFIGAN_SUPERRES_VOCODER_MODEL_FILENAME", "hifigan_superres.pth");
|
||||
|
||||
let sidecar_max_synthesizer_models = easyenv::get_env_num(
|
||||
"SIDECAR_MAX_SYNTHESIZER_MODELS", 3)?;
|
||||
|
||||
@@ -305,13 +295,7 @@ async fn main() -> AnyhowResult<()> {
|
||||
low_priority_starvation_prevention_every_nth,
|
||||
maybe_minimum_priority,
|
||||
job_type_details: JobTypeDetails {
|
||||
tacotron2_old_vocodes: Tacotron2VocodesDetails {
|
||||
inference_command: Tacotron2InferenceCommand::from_env()?,
|
||||
waveglow_vocoder_model_filename,
|
||||
hifigan_vocoder_model_filename,
|
||||
hifigan_superres_vocoder_model_filename,
|
||||
},
|
||||
vall_e_x: VallEXDetails {
|
||||
vall_e_x: VallEXDetails {
|
||||
downloaders: VallEXDownloaders::build_all_from_env(),
|
||||
inference_command: VallEXInferenceCommand::from_env()?,
|
||||
create_embedding_command: VallEXCreateEmbeddingCommand::from_env()?,
|
||||
|
||||
Reference in new issue
Block a user