Spaces:
Running
on
Zero
Running
on
Zero
mrfakename
commited on
Commit
•
6c15fbb
1
Parent(s):
aabbc45
Sync from GitHub repo
Browse filesThis Space is synced from the GitHub repo: https://github.com/SWivid/F5-TTS. Please submit contributions to the Space there
src/f5_tts/infer/utils_infer.py
CHANGED
@@ -182,7 +182,7 @@ def preprocess_ref_audio_text(ref_audio_orig, ref_text, show_info=print, device=
|
|
182 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as f:
|
183 |
aseg = AudioSegment.from_file(ref_audio_orig)
|
184 |
|
185 |
-
non_silent_segs = silence.split_on_silence(aseg, min_silence_len=
|
186 |
non_silent_wave = AudioSegment.silent(duration=0)
|
187 |
for non_silent_seg in non_silent_segs:
|
188 |
if len(non_silent_wave) > 10000 and len(non_silent_wave + non_silent_seg) > 18000:
|
@@ -190,6 +190,9 @@ def preprocess_ref_audio_text(ref_audio_orig, ref_text, show_info=print, device=
|
|
190 |
break
|
191 |
non_silent_wave += non_silent_seg
|
192 |
aseg = non_silent_wave
|
|
|
|
|
|
|
193 |
|
194 |
aseg.export(f.name, format="wav")
|
195 |
ref_audio = f.name
|
|
|
182 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as f:
|
183 |
aseg = AudioSegment.from_file(ref_audio_orig)
|
184 |
|
185 |
+
non_silent_segs = silence.split_on_silence(aseg, min_silence_len=500, silence_thresh=-50, keep_silence=1000)
|
186 |
non_silent_wave = AudioSegment.silent(duration=0)
|
187 |
for non_silent_seg in non_silent_segs:
|
188 |
if len(non_silent_wave) > 10000 and len(non_silent_wave + non_silent_seg) > 18000:
|
|
|
190 |
break
|
191 |
non_silent_wave += non_silent_seg
|
192 |
aseg = non_silent_wave
|
193 |
+
if len(aseg) > 18000: # if no proper silence found for clipping
|
194 |
+
aseg = aseg[:18000]
|
195 |
+
show_info("Audio is over 18s, clipping short.")
|
196 |
|
197 |
aseg.export(f.name, format="wav")
|
198 |
ref_audio = f.name
|