Yushen CHEN commited on
Commit
b664bc7
·
unverified ·
1 Parent(s): 552c0fd

Update finetune_gradio.py

Browse files
Files changed (1) hide show
  1. src/f5_tts/train/finetune_gradio.py +2 -10
src/f5_tts/train/finetune_gradio.py CHANGED
@@ -28,7 +28,7 @@ from safetensors.torch import save_file
28
  from scipy.io import wavfile
29
  from transformers import pipeline
30
  from cached_path import cached_path
31
- from f5_tts.api import F5TTS, target_sample_rate
32
  from f5_tts.model.utils import convert_char_to_pinyin
33
  from importlib.resources import files
34
 
@@ -174,15 +174,7 @@ def load_settings(project_name):
174
  def get_audio_duration(audio_path):
175
  """Calculate the duration mono of an audio file."""
176
  audio, sample_rate = torchaudio.load(audio_path)
177
-
178
- if audio.shape[0] > 1:
179
- audio = torch.mean(audio, dim=0, keepdim=True)
180
-
181
- if sample_rate != target_sample_rate:
182
- audio = torchaudio.transforms.Resample(sample_rate, target_sample_rate)
183
-
184
- num_channels = audio.shape[0]
185
- return audio.shape[1] / (sample_rate * num_channels)
186
 
187
 
188
  def clear_text(text):
 
28
  from scipy.io import wavfile
29
  from transformers import pipeline
30
  from cached_path import cached_path
31
+ from f5_tts.api import F5TTS
32
  from f5_tts.model.utils import convert_char_to_pinyin
33
  from importlib.resources import files
34
 
 
174
  def get_audio_duration(audio_path):
175
  """Calculate the duration mono of an audio file."""
176
  audio, sample_rate = torchaudio.load(audio_path)
177
+ return audio.shape[1] / sample_rate
 
 
 
 
 
 
 
 
178
 
179
 
180
  def clear_text(text):