Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -295,8 +295,8 @@ def phonemes_to_ids(config, phonemes: List[str]) -> List[int]:
|
|
295 |
ids.extend(id_map[PAD])
|
296 |
ids.extend(id_map[EOS])
|
297 |
return ids
|
298 |
-
|
299 |
-
def inferencing(model, config, sid, line, length_scale = 1, noise_scale = 0.667, noise_scale_w = 0.8, auto_play=True):
|
300 |
audios = []
|
301 |
if config["phoneme_type"] == "PhonemeType.ESPEAK":
|
302 |
config["phoneme_type"] = "espeak"
|
@@ -330,8 +330,14 @@ def inferencing(model, config, sid, line, length_scale = 1, noise_scale = 0.667,
|
|
330 |
audios.append(audio)
|
331 |
merged_audio = np.concatenate(audios)
|
332 |
sample_rate = config["audio"]["sample_rate"]
|
333 |
-
|
334 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
|
336 |
def denoise(
|
337 |
audio: np.ndarray, bias_spec: np.ndarray, denoiser_strength: float
|
|
|
295 |
ids.extend(id_map[PAD])
|
296 |
ids.extend(id_map[EOS])
|
297 |
return ids
|
298 |
+
@app.get("/generate_audio")
|
299 |
+
async def inferencing(model, config, sid, line, length_scale = 1, noise_scale = 0.667, noise_scale_w = 0.8, auto_play=True):
|
300 |
audios = []
|
301 |
if config["phoneme_type"] == "PhonemeType.ESPEAK":
|
302 |
config["phoneme_type"] = "espeak"
|
|
|
330 |
audios.append(audio)
|
331 |
merged_audio = np.concatenate(audios)
|
332 |
sample_rate = config["audio"]["sample_rate"]
|
333 |
+
# Save the audio as a temporary WAV file
|
334 |
+
temp_audio_path = os.path.join(tempfile.gettempdir(), "generated_audio.wav")
|
335 |
+
sf.write(temp_audio_path, merged_audio, config["audio"]["sample_rate"])
|
336 |
+
|
337 |
+
# Return the audio file as a FastAPI response
|
338 |
+
return FileResponse(temp_audio_path)
|
339 |
+
# display(Markdown(f"{line}"))
|
340 |
+
# display(Audio(merged_audio, rate=sample_rate, autoplay=auto_play))
|
341 |
|
342 |
def denoise(
|
343 |
audio: np.ndarray, bias_spec: np.ndarray, denoiser_strength: float
|