Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -81,7 +81,6 @@ def predict(prompt, language, reference_audio):
|
|
81 |
|
82 |
output_path = "pedro_labattaglia_TTS.wav"
|
83 |
# Guardar el audio directamente desde el output del modelo
|
84 |
-
import scipy.io.wavfile as wavfile
|
85 |
wavfile.write(output_path, config.audio["output_sample_rate"], out["wav"])
|
86 |
|
87 |
audio_length = len(out["wav"]) / config.audio["output_sample_rate"] # duración del audio en segundos
|
@@ -125,36 +124,97 @@ Sintetizador de voz con la voz del locutor argentino Pedro Labattaglia.
|
|
125 |
- Presione generar voz
|
126 |
"""
|
127 |
|
128 |
-
# JavaScript para limpiar los datos de autenticación
|
129 |
clear_auth_js = """
|
130 |
function clearAuthData() {
|
131 |
localStorage.removeItem('gradio_auth_token');
|
132 |
localStorage.removeItem('gradio_auth_expiration');
|
|
|
|
|
|
|
|
|
133 |
}
|
134 |
|
135 |
-
// Limpiar datos de autenticación cuando la página se refresca o se cierra
|
136 |
window.addEventListener('beforeunload', clearAuthData);
|
137 |
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
"""
|
153 |
|
154 |
# Interfaz de Gradio
|
155 |
-
with gr.Blocks(theme=theme) as demo:
|
156 |
gr.Markdown(description)
|
157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
# Fila para centrar la imagen
|
159 |
with gr.Row():
|
160 |
with gr.Column(equal_height=True):
|
@@ -185,19 +245,21 @@ with gr.Blocks(theme=theme) as demo:
|
|
185 |
outputs=[generated_audio, metrics_output]
|
186 |
)
|
187 |
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
}
|
200 |
"""
|
201 |
|
202 |
if __name__ == "__main__":
|
203 |
-
demo.launch(
|
|
|
|
|
|
|
|
81 |
|
82 |
output_path = "pedro_labattaglia_TTS.wav"
|
83 |
# Guardar el audio directamente desde el output del modelo
|
|
|
84 |
wavfile.write(output_path, config.audio["output_sample_rate"], out["wav"])
|
85 |
|
86 |
audio_length = len(out["wav"]) / config.audio["output_sample_rate"] # duración del audio en segundos
|
|
|
124 |
- Presione generar voz
|
125 |
"""
|
126 |
|
127 |
+
# JavaScript mejorado para limpiar los datos de autenticación
|
128 |
clear_auth_js = """
|
129 |
function clearAuthData() {
|
130 |
localStorage.removeItem('gradio_auth_token');
|
131 |
localStorage.removeItem('gradio_auth_expiration');
|
132 |
+
sessionStorage.removeItem('gradio_auth_token');
|
133 |
+
sessionStorage.removeItem('gradio_auth_expiration');
|
134 |
+
document.cookie = 'gradio_auth_token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
|
135 |
+
document.cookie = 'gradio_auth_expiration=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
|
136 |
}
|
137 |
|
|
|
138 |
window.addEventListener('beforeunload', clearAuthData);
|
139 |
|
140 |
+
function logout() {
|
141 |
+
clearAuthData();
|
142 |
+
window.location.reload();
|
143 |
+
}
|
144 |
+
"""
|
145 |
+
|
146 |
+
# CSS personalizado
|
147 |
+
custom_css = """
|
148 |
+
#image-container img {
|
149 |
+
display: block;
|
150 |
+
margin-left: auto;
|
151 |
+
margin-right: auto;
|
152 |
+
max-width: 256px;
|
153 |
+
height: auto;
|
154 |
+
}
|
155 |
+
.logout-button {
|
156 |
+
position: fixed;
|
157 |
+
top: 10px;
|
158 |
+
right: 10px;
|
159 |
+
z-index: 1000;
|
160 |
+
padding: 8px 16px;
|
161 |
+
background-color: #f44336;
|
162 |
+
color: white;
|
163 |
+
border: none;
|
164 |
+
border-radius: 4px;
|
165 |
+
cursor: pointer;
|
166 |
+
}
|
167 |
+
.logout-button:hover {
|
168 |
+
background-color: #d32f2f;
|
169 |
+
}
|
170 |
+
.login-container {
|
171 |
+
background-color: white;
|
172 |
+
padding: 2rem;
|
173 |
+
border-radius: 10px;
|
174 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
175 |
+
text-align: center;
|
176 |
+
max-width: 400px;
|
177 |
+
width: 100%;
|
178 |
+
}
|
179 |
+
.login-container h1 {
|
180 |
+
margin-bottom: 1rem;
|
181 |
+
color: #4a4a4a;
|
182 |
+
}
|
183 |
+
.login-container input {
|
184 |
+
width: 100%;
|
185 |
+
padding: 0.5rem;
|
186 |
+
margin-bottom: 1rem;
|
187 |
+
border: 1px solid #ddd;
|
188 |
+
border-radius: 4px;
|
189 |
+
}
|
190 |
+
.login-container button {
|
191 |
+
width: 100%;
|
192 |
+
padding: 0.5rem;
|
193 |
+
background-color: #3498db;
|
194 |
+
color: white;
|
195 |
+
border: none;
|
196 |
+
border-radius: 4px;
|
197 |
+
cursor: pointer;
|
198 |
+
}
|
199 |
+
.login-container button:hover {
|
200 |
+
background-color: #2980b9;
|
201 |
+
}
|
202 |
"""
|
203 |
|
204 |
# Interfaz de Gradio
|
205 |
+
with gr.Blocks(theme=theme, css=custom_css) as demo:
|
206 |
gr.Markdown(description)
|
207 |
|
208 |
+
# Botón de cerrar sesión
|
209 |
+
gr.HTML(
|
210 |
+
"""
|
211 |
+
<button onclick="logout()" class="logout-button">Cerrar sesión</button>
|
212 |
+
<script>
|
213 |
+
""" + clear_auth_js + """
|
214 |
+
</script>
|
215 |
+
"""
|
216 |
+
)
|
217 |
+
|
218 |
# Fila para centrar la imagen
|
219 |
with gr.Row():
|
220 |
with gr.Column(equal_height=True):
|
|
|
245 |
outputs=[generated_audio, metrics_output]
|
246 |
)
|
247 |
|
248 |
+
# Formulario de inicio de sesión personalizado (en español)
|
249 |
+
login_form = """
|
250 |
+
<div class="login-container">
|
251 |
+
<h1>Bienvenido al sintetizador de voz de Pedro Labattaglia</h1>
|
252 |
+
<p>Por favor, introduzca sus credenciales para acceder.</p>
|
253 |
+
<form id="login-form">
|
254 |
+
<input type="text" id="username" name="username" placeholder="Usuario" required>
|
255 |
+
<input type="password" id="password" name="password" placeholder="Contraseña" required>
|
256 |
+
<button type="submit">Iniciar sesión</button>
|
257 |
+
</form>
|
258 |
+
</div>
|
|
|
259 |
"""
|
260 |
|
261 |
if __name__ == "__main__":
|
262 |
+
demo.launch(
|
263 |
+
auth=[("Pedro Labattaglia", "PL2024"), ("Invitado", "PLTTS2024")],
|
264 |
+
auth_message=login_form
|
265 |
+
)
|