Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -260,7 +260,15 @@ def phonemes_to_ids(config, phonemes: List[str]) -> List[int]:
|
|
260 |
ids.extend(id_map[PAD])
|
261 |
ids.extend(id_map[EOS])
|
262 |
return ids
|
263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
264 |
def inferencing(model, config, sid, line, length_scale = 1, noise_scale = 0.667, noise_scale_w = 0.8, auto_play=True):
|
265 |
audios = []
|
266 |
if config["phoneme_type"] == "PhonemeType.ESPEAK":
|
|
|
260 |
ids.extend(id_map[PAD])
|
261 |
ids.extend(id_map[EOS])
|
262 |
return ids
|
263 |
+
def audio_float_to_int16(
|
264 |
+
audio: np.ndarray, max_wav_value: float = 32767.0
|
265 |
+
) -> np.ndarray:
|
266 |
+
"""Normalize audio and convert to int16 range"""
|
267 |
+
audio_norm = audio * (max_wav_value / max(0.01, np.max(np.abs(audio))))
|
268 |
+
audio_norm = np.clip(audio_norm, -max_wav_value, max_wav_value)
|
269 |
+
audio_norm = audio_norm.astype("int16")
|
270 |
+
return audio_norm
|
271 |
+
|
272 |
def inferencing(model, config, sid, line, length_scale = 1, noise_scale = 0.667, noise_scale_w = 0.8, auto_play=True):
|
273 |
audios = []
|
274 |
if config["phoneme_type"] == "PhonemeType.ESPEAK":
|