Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,6 @@ import time
|
|
4 |
import sys
|
5 |
import subprocess
|
6 |
import gradio as gr
|
7 |
-
from pydub import AudioSegment # Corrección aquí
|
8 |
from TTS.api import TTS
|
9 |
from TTS.tts.configs.xtts_config import XttsConfig
|
10 |
from TTS.tts.models.xtts import Xtts
|
@@ -48,8 +47,6 @@ def predict(prompt, language, reference_audio):
|
|
48 |
if len(prompt) < 2 or len(prompt) > 600:
|
49 |
return None, "El texto debe tener entre 2 y 600 caracteres."
|
50 |
|
51 |
-
sentences = split_text(prompt)
|
52 |
-
|
53 |
# Obtener los parámetros de la configuración JSON
|
54 |
temperature = config.model_args.get("temperature", 0.85)
|
55 |
length_penalty = config.model_args.get("length_penalty", 1.0)
|
@@ -62,35 +59,32 @@ def predict(prompt, language, reference_audio):
|
|
62 |
)
|
63 |
|
64 |
start_time = time.time()
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
)
|
85 |
-
combined_audio += audio_segment
|
86 |
-
combined_audio += AudioSegment.silent(duration=500) # 0.5 segundos de silencio
|
87 |
|
88 |
inference_time = time.time() - start_time
|
89 |
|
90 |
output_path = "output.wav"
|
91 |
-
|
92 |
|
93 |
-
audio_length = len(
|
94 |
real_time_factor = inference_time / audio_length
|
95 |
|
96 |
metrics_text = f"Tiempo de generación: {inference_time:.2f} segundos\n"
|
|
|
4 |
import sys
|
5 |
import subprocess
|
6 |
import gradio as gr
|
|
|
7 |
from TTS.api import TTS
|
8 |
from TTS.tts.configs.xtts_config import XttsConfig
|
9 |
from TTS.tts.models.xtts import Xtts
|
|
|
47 |
if len(prompt) < 2 or len(prompt) > 600:
|
48 |
return None, "El texto debe tener entre 2 y 600 caracteres."
|
49 |
|
|
|
|
|
50 |
# Obtener los parámetros de la configuración JSON
|
51 |
temperature = config.model_args.get("temperature", 0.85)
|
52 |
length_penalty = config.model_args.get("length_penalty", 1.0)
|
|
|
59 |
)
|
60 |
|
61 |
start_time = time.time()
|
62 |
+
|
63 |
+
out = model.inference(
|
64 |
+
prompt,
|
65 |
+
language,
|
66 |
+
gpt_cond_latent,
|
67 |
+
speaker_embedding,
|
68 |
+
temperature=temperature,
|
69 |
+
length_penalty=length_penalty,
|
70 |
+
repetition_penalty=repetition_penalty,
|
71 |
+
top_k=top_k,
|
72 |
+
top_p=top_p
|
73 |
+
)
|
74 |
+
|
75 |
+
audio_segment = AudioSegment(
|
76 |
+
out["wav"].tobytes(),
|
77 |
+
frame_rate=config.audio["output_sample_rate"],
|
78 |
+
sample_width=2,
|
79 |
+
channels=1
|
80 |
+
)
|
|
|
|
|
|
|
81 |
|
82 |
inference_time = time.time() - start_time
|
83 |
|
84 |
output_path = "output.wav"
|
85 |
+
audio_segment.export(output_path, format="wav")
|
86 |
|
87 |
+
audio_length = len(audio_segment) / 1000 # duración del audio en segundos
|
88 |
real_time_factor = inference_time / audio_length
|
89 |
|
90 |
metrics_text = f"Tiempo de generación: {inference_time:.2f} segundos\n"
|