From 3dd59b8cdfb8f23ea5bf2d98acb6048292f40977 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Oct 2024 14:26:13 +0200 Subject: [PATCH] when ref_text empty automatic transcribing --- src/f5_tts/api.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/f5_tts/api.py b/src/f5_tts/api.py index 41fc6675c..4dac62faa 100644 --- a/src/f5_tts/api.py +++ b/src/f5_tts/api.py @@ -15,6 +15,9 @@ infer_process, remove_silence_for_generated_wav, save_spectrogram, + preprocess_ref_audio_text, + target_sample_rate, + hop_length, ) @@ -31,10 +34,8 @@ def __init__( ): # Initialize parameters self.final_wave = None - self.target_sample_rate = 24000 - self.n_mel_channels = 100 - self.hop_length = 256 - self.target_rms = 0.1 + self.target_sample_rate = target_sample_rate + self.hop_length = hop_length self.seed = -1 # Set device @@ -97,6 +98,10 @@ def infer( seed = random.randint(0, sys.maxsize) seed_everything(seed) self.seed = seed + + if ref_text == "": + ref_file, ref_text = preprocess_ref_audio_text(ref_file, ref_text, device=self.device) + wav, sr, spect = infer_process( ref_file, ref_text,