Skip to content

Commit

Permalink
Update finetune_gradio.py
Browse files Browse the repository at this point in the history
  • Loading branch information
SWivid authored Nov 1, 2024
1 parent 552c0fd commit b664bc7
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/f5_tts/train/finetune_gradio.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from scipy.io import wavfile
from transformers import pipeline
from cached_path import cached_path
from f5_tts.api import F5TTS, target_sample_rate
from f5_tts.api import F5TTS
from f5_tts.model.utils import convert_char_to_pinyin
from importlib.resources import files

Expand Down Expand Up @@ -174,15 +174,7 @@ def load_settings(project_name):
def get_audio_duration(audio_path):
"""Calculate the duration mono of an audio file."""
audio, sample_rate = torchaudio.load(audio_path)

if audio.shape[0] > 1:
audio = torch.mean(audio, dim=0, keepdim=True)

if sample_rate != target_sample_rate:
audio = torchaudio.transforms.Resample(sample_rate, target_sample_rate)

num_channels = audio.shape[0]
return audio.shape[1] / (sample_rate * num_channels)
return audio.shape[1] / sample_rate


def clear_text(text):
Expand Down

0 comments on commit b664bc7

Please sign in to comment.