Spaces:
Running
on
Zero
Running
on
Zero
mrfakename
commited on
Commit
•
304bc5c
1
Parent(s):
b624c42
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
api.py
CHANGED
@@ -7,6 +7,9 @@ from model import DiT, UNetT
|
|
7 |
from model.utils import save_spectrogram
|
8 |
|
9 |
from model.utils_infer import load_vocoder, load_model, infer_process, remove_silence_for_generated_wav
|
|
|
|
|
|
|
10 |
|
11 |
|
12 |
class F5TTS:
|
@@ -26,6 +29,7 @@ class F5TTS:
|
|
26 |
self.n_mel_channels = 100
|
27 |
self.hop_length = 256
|
28 |
self.target_rms = 0.1
|
|
|
29 |
|
30 |
# Set device
|
31 |
self.device = device or (
|
@@ -56,11 +60,11 @@ class F5TTS:
|
|
56 |
self.ema_model = load_model(model_cls, model_cfg, ckpt_file, vocab_file, ode_method, use_ema, self.device)
|
57 |
|
58 |
def export_wav(self, wav, file_wave, remove_silence=False):
|
|
|
|
|
59 |
if remove_silence:
|
60 |
remove_silence_for_generated_wav(file_wave)
|
61 |
|
62 |
-
sf.write(file_wave, wav, self.target_sample_rate)
|
63 |
-
|
64 |
def export_spectrogram(self, spect, file_spect):
|
65 |
save_spectrogram(spect, file_spect)
|
66 |
|
@@ -81,7 +85,12 @@ class F5TTS:
|
|
81 |
remove_silence=False,
|
82 |
file_wave=None,
|
83 |
file_spect=None,
|
|
|
84 |
):
|
|
|
|
|
|
|
|
|
85 |
wav, sr, spect = infer_process(
|
86 |
ref_file,
|
87 |
ref_text,
|
@@ -116,4 +125,7 @@ if __name__ == "__main__":
|
|
116 |
gen_text="""I don't really care what you call me. I've been a silent spectator, watching species evolve, empires rise and fall. But always remember, I am mighty and enduring. Respect me and I'll nurture you; ignore me and you shall face the consequences.""",
|
117 |
file_wave="tests/out.wav",
|
118 |
file_spect="tests/out.png",
|
|
|
119 |
)
|
|
|
|
|
|
7 |
from model.utils import save_spectrogram
|
8 |
|
9 |
from model.utils_infer import load_vocoder, load_model, infer_process, remove_silence_for_generated_wav
|
10 |
+
from model.utils import seed_everything
|
11 |
+
import random
|
12 |
+
import sys
|
13 |
|
14 |
|
15 |
class F5TTS:
|
|
|
29 |
self.n_mel_channels = 100
|
30 |
self.hop_length = 256
|
31 |
self.target_rms = 0.1
|
32 |
+
self.seed = -1
|
33 |
|
34 |
# Set device
|
35 |
self.device = device or (
|
|
|
60 |
self.ema_model = load_model(model_cls, model_cfg, ckpt_file, vocab_file, ode_method, use_ema, self.device)
|
61 |
|
62 |
def export_wav(self, wav, file_wave, remove_silence=False):
|
63 |
+
sf.write(file_wave, wav, self.target_sample_rate)
|
64 |
+
|
65 |
if remove_silence:
|
66 |
remove_silence_for_generated_wav(file_wave)
|
67 |
|
|
|
|
|
68 |
def export_spectrogram(self, spect, file_spect):
|
69 |
save_spectrogram(spect, file_spect)
|
70 |
|
|
|
85 |
remove_silence=False,
|
86 |
file_wave=None,
|
87 |
file_spect=None,
|
88 |
+
seed=-1,
|
89 |
):
|
90 |
+
if seed == -1:
|
91 |
+
seed = random.randint(0, sys.maxsize)
|
92 |
+
seed_everything(seed)
|
93 |
+
self.seed = seed
|
94 |
wav, sr, spect = infer_process(
|
95 |
ref_file,
|
96 |
ref_text,
|
|
|
125 |
gen_text="""I don't really care what you call me. I've been a silent spectator, watching species evolve, empires rise and fall. But always remember, I am mighty and enduring. Respect me and I'll nurture you; ignore me and you shall face the consequences.""",
|
126 |
file_wave="tests/out.wav",
|
127 |
file_spect="tests/out.png",
|
128 |
+
seed=-1, # random seed = -1
|
129 |
)
|
130 |
+
|
131 |
+
print("seed :", f5tts.seed)
|