Spaces:
Running
on
Zero
Running
on
Zero
Upload app.py
Browse files
app.py
CHANGED
@@ -126,6 +126,10 @@ CHOICES = {
|
|
126 |
'π―π΅ πΊ Japanese Female 0': 'jf_0',
|
127 |
}
|
128 |
VOICES = {k: torch.load(os.path.join(snapshot, 'voices', f'{k}.pt'), weights_only=True).to(device) for k in CHOICES.values()}
|
|
|
|
|
|
|
|
|
129 |
|
130 |
np_log_99 = np.log(99)
|
131 |
def s_curve(p):
|
@@ -165,7 +169,9 @@ def forward(tokens, voice, speed):
|
|
165 |
asr = t_en @ pred_aln_trg.unsqueeze(0).to(device)
|
166 |
return model.decoder(asr, F0_pred, N_pred, ref_s[:, :128]).squeeze().cpu().numpy()
|
167 |
|
168 |
-
def generate(text, voice, ps=None, speed=1.0, reduce_noise=0.5, opening_cut=4000, closing_cut=2000, ease_in=3000, ease_out=1000, pad_before=5000, pad_after=5000):
|
|
|
|
|
169 |
ps = ps or phonemize(text, voice)
|
170 |
tokens = tokenize(ps)
|
171 |
if not tokens:
|
|
|
126 |
'π―π΅ πΊ Japanese Female 0': 'jf_0',
|
127 |
}
|
128 |
VOICES = {k: torch.load(os.path.join(snapshot, 'voices', f'{k}.pt'), weights_only=True).to(device) for k in CHOICES.values()}
|
129 |
+
def get_random_en_voice():
|
130 |
+
# Top 2 most stable voices in each category of (US/GB) and (F/M)
|
131 |
+
# excluding Adam, because he is too recognizable
|
132 |
+
return random.choice(['af_0', 'af_bella', 'am_michael', 'bf_0', 'bf_2', 'bm_0', 'bm_1'])
|
133 |
|
134 |
np_log_99 = np.log(99)
|
135 |
def s_curve(p):
|
|
|
169 |
asr = t_en @ pred_aln_trg.unsqueeze(0).to(device)
|
170 |
return model.decoder(asr, F0_pred, N_pred, ref_s[:, :128]).squeeze().cpu().numpy()
|
171 |
|
172 |
+
def generate(text, voice=None, ps=None, speed=1.0, reduce_noise=0.5, opening_cut=4000, closing_cut=2000, ease_in=3000, ease_out=1000, pad_before=5000, pad_after=5000):
|
173 |
+
if voice not in VOICES:
|
174 |
+
voice = get_random_en_voice()
|
175 |
ps = ps or phonemize(text, voice)
|
176 |
tokens = tokenize(ps)
|
177 |
if not tokens:
|