Update voiceit.py
Browse files- voiceit.py +49 -68
voiceit.py
CHANGED
@@ -14,7 +14,6 @@ from pathlib import Path
|
|
14 |
|
15 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
16 |
MODELOS = os.path.join(current_dir, "modelos/")
|
17 |
-
MUSIC_EXTENSIONS = ['.wav']
|
18 |
SEGMENTS_DIRNAME = os.path.join(current_dir, "segments")
|
19 |
INFERENCE_OUTPUT_DIRNAME = os.path.join(current_dir, "inference_output")
|
20 |
|
@@ -60,11 +59,8 @@ def get_speakers():
|
|
60 |
continue
|
61 |
cur_speaker["model_path"] = g[0]
|
62 |
cur_speaker["model_folder"] = folder
|
63 |
-
|
64 |
-
|
65 |
-
cur_speaker["cluster_path"] = ""
|
66 |
-
else:
|
67 |
-
cur_speaker["cluster_path"] = clst[0]
|
68 |
cfg = glob.glob(os.path.join(MODELOS, folder, '*.json'))
|
69 |
if not len(cfg):
|
70 |
continue
|
@@ -90,15 +86,10 @@ def run_inference(speaker, seg_path, f0_method, transpose, noise_scale, cluster_
|
|
90 |
result = subprocess.run(inference_cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
91 |
if result.stderr:
|
92 |
if "AttributeError" in result.stderr:
|
93 |
-
return None, gr.Textbox.update("⚠️ Modelo incompatible.")
|
94 |
if not list(Path(SEGMENTS_DIRNAME).glob("*")):
|
95 |
return None, gr.Textbox.update("⚠️ Error.")
|
96 |
|
97 |
-
def check_audio_format(audio_file):
|
98 |
-
if not audio_file.lower().endswith(".wav"):
|
99 |
-
return False
|
100 |
-
return True
|
101 |
-
|
102 |
def convert(speaker_box, audio):
|
103 |
speaker = next((x for x in speakers if x["name"] == speaker_box), None)
|
104 |
if not speaker:
|
@@ -106,8 +97,6 @@ def convert(speaker_box, audio):
|
|
106 |
if not audio:
|
107 |
return None, gr.Textbox.update("⚠️ Sube un audio.")
|
108 |
|
109 |
-
if not check_audio_format(str(audio)):
|
110 |
-
return None, gr.Textbox.update("⚠️ Formato de audio incorrecto. Sube un archivo .wav.")
|
111 |
file_path = os.path.join(os.getcwd(), str(audio))
|
112 |
model_path = os.path.join(os.getcwd(), speaker["model_path"])
|
113 |
config_path = os.path.join(os.getcwd(), speaker["cfg_path"])
|
@@ -143,9 +132,32 @@ def clear():
|
|
143 |
return gr.Dropdown.update(value="Elige un modelo de voz"), None, gr.Textbox.update("🗑️ Datos borrados.", label=f"Información")
|
144 |
|
145 |
|
146 |
-
css = "
|
147 |
-
|
148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
gr.HTML(
|
150 |
"""
|
151 |
<div class="center-container">
|
@@ -173,7 +185,7 @@ with gr.Blocks(css=css,title="VoiceIt! - Pavloh", theme=gr.themes.Soft(primary_h
|
|
173 |
</div>
|
174 |
"""
|
175 |
)
|
176 |
-
|
177 |
with gr.Row(elem_id="1").style(equal_height=True):
|
178 |
with gr.Column():
|
179 |
d1 = gr.Dropdown([x["name"] for x in get_speakers()], label="📦 Selecciona un modelo", value="Elige un modelo de voz")
|
@@ -186,57 +198,26 @@ with gr.Blocks(css=css,title="VoiceIt! - Pavloh", theme=gr.themes.Soft(primary_h
|
|
186 |
b1 = gr.Button("🎤 Cambiar voz",variant="primary")
|
187 |
b0.click(clear, outputs=[d1, audio, t1])
|
188 |
b1.click(convert, inputs=[d1, audio], outputs=[a2, t1])
|
189 |
-
|
190 |
-
|
191 |
-
with gr.
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
<br><p>Por favor, lea atentamente estos Términos de Uso antes de utilizar la herramienta de conversión de voz mediante <i>Inteligencia Artificial</i> VoiceIt ("Servicio") operado por Pavloh.</p>
|
208 |
-
<p>El acceso y uso de este Servicio está condicionado a la aceptación y cumplimiento de estos Términos. Estos Términos se aplican a todos los visitantes, usuarios y otras personas que accedan o utilicen el Servicio.</p>
|
209 |
-
<p>Al acceder o utilizar el Servicio, usted acepta estar sujeto a estos Términos.</p>
|
210 |
-
|
211 |
-
<br><h4><b>1. Uso permitido</h4></b>
|
212 |
-
|
213 |
-
<p>El Servicio está destinado únicamente a fines personales y no comerciales. Usted no debe utilizar el Servicio para ningún propósito ilegal o no autorizado. Al utilizar el Servicio, usted acepta cumplir con todas las leyes, reglas y regulaciones aplicables.</p>
|
214 |
-
|
215 |
-
<h4><b>2. Restricciones de uso</h4></b>
|
216 |
-
<p>Al usar el Servicio, usted acepta a no:</p>
|
217 |
-
|
218 |
-
<p>· Subir, transmitir o distribuir cualquier material que viole derechos de autor, marcas registradas u otros derechos de propiedad intelectual.</p>
|
219 |
-
<p>· Utilizar el Servicio para fines ilegales o actividades fraudulentas.</p>
|
220 |
-
<p>· Subir, transmitir o distribuir cualquier material que contenga virus, malware u otro código malicioso.</p>
|
221 |
-
<p>· Intentar obtener acceso no autorizado a sistemas o redes informáticas, o interferir en el funcionamiento de los sistemas o redes informáticas.</p>
|
222 |
-
<p>· Realizar ingeniería inversa, descompilar o desensamblar cualquier software o tecnología utilizada en el Servicio.</p>
|
223 |
-
|
224 |
-
<h4><b>3. Derechos de propiedad intelectual</b></h4>
|
225 |
-
<p>Todos los derechos, títulos e intereses en y para el Servicio, incluyendo, sin limitación, todos los textos, gráficos, imágenes, logos, iconos, software y otros elementos contenidos en el Servicio son propiedad exclusiva de [Nombre de la empresa] o sus licenciantes y están protegidos por las leyes de derechos de autor y otras leyes de propiedad intelectual aplicables.</p>
|
226 |
-
|
227 |
-
<h4><b>4. Limitación de responsabilidad</h4></b>
|
228 |
-
<p>En ningún caso <i>Pavloh</i> será responsable por cualquier daño directo, indirecto, incidental, especial, ejemplar o consecuente (incluyendo, pero no limitado a, pérdida de uso, datos o beneficios; o interrupción del negocio) causado por el uso o la imposibilidad de utilizar el Servicio. Esta limitación de responsabilidad se aplicará en la medida máxima permitida por la ley aplicable.</p>
|
229 |
-
|
230 |
-
<h4><b>5. Cambios en los Términos de Uso</h4></b>
|
231 |
-
<p>Pavloh se reserva el derecho, a su exclusivo criterio, de modificar o reemplazar estos Términos en cualquier momento. Si la revisión es material, intentaremos proporcionar un aviso con al menos 30 días de anticipación antes de que los nuevos términos entren en vigencia. Lo que constituye un cambio material será determinado a nuestro exclusivo criterio.</p>
|
232 |
-
<p>Al continuar utilizando el Servicio después de que esos cambios entren en vigencia, usted acepta estar sujeto a los términos revisados. Si no está de acuerdo con los nuevos términos, por favor deje de usar el Servicio.</p>
|
233 |
-
|
234 |
-
<h4><b>6. Ley aplicable y jurisdicción</h4></b>
|
235 |
-
<p>Estos Términos se regirán e interpretarán de acuerdo con las leyes de Europa sin tener en cuenta sus disposiciones sobre conflicto de leyes. Nuestra incapacidad para hacer cumplir cualquier derecho o disposición de estos Términos no se considerará una renuncia a esos derechos. Si alguna disposición de estos Términos es considerada inválida o inaplicable por un tribunal, las disposiciones restantes de estos Términos seguirán en vigor.</p>
|
236 |
-
|
237 |
-
<br><p>Si tiene alguna pregunta sobre estos Términos, por favor póngase en contacto con Pavloh a través de [email protected].</b></p>
|
238 |
""")
|
239 |
-
|
240 |
if __name__ == "__main__":
|
241 |
pavloh.queue(concurrency_count=3)
|
242 |
pavloh.launch()
|
|
|
14 |
|
15 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
16 |
MODELOS = os.path.join(current_dir, "modelos/")
|
|
|
17 |
SEGMENTS_DIRNAME = os.path.join(current_dir, "segments")
|
18 |
INFERENCE_OUTPUT_DIRNAME = os.path.join(current_dir, "inference_output")
|
19 |
|
|
|
59 |
continue
|
60 |
cur_speaker["model_path"] = g[0]
|
61 |
cur_speaker["model_folder"] = folder
|
62 |
+
cur_speaker["cluster_path"] = ""
|
63 |
+
|
|
|
|
|
|
|
64 |
cfg = glob.glob(os.path.join(MODELOS, folder, '*.json'))
|
65 |
if not len(cfg):
|
66 |
continue
|
|
|
86 |
result = subprocess.run(inference_cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
87 |
if result.stderr:
|
88 |
if "AttributeError" in result.stderr:
|
89 |
+
return None, gr.Textbox.update("⚠️ Modelo SVC incompatible.")
|
90 |
if not list(Path(SEGMENTS_DIRNAME).glob("*")):
|
91 |
return None, gr.Textbox.update("⚠️ Error.")
|
92 |
|
|
|
|
|
|
|
|
|
|
|
93 |
def convert(speaker_box, audio):
|
94 |
speaker = next((x for x in speakers if x["name"] == speaker_box), None)
|
95 |
if not speaker:
|
|
|
97 |
if not audio:
|
98 |
return None, gr.Textbox.update("⚠️ Sube un audio.")
|
99 |
|
|
|
|
|
100 |
file_path = os.path.join(os.getcwd(), str(audio))
|
101 |
model_path = os.path.join(os.getcwd(), speaker["model_path"])
|
102 |
config_path = os.path.join(os.getcwd(), speaker["cfg_path"])
|
|
|
132 |
return gr.Dropdown.update(value="Elige un modelo de voz"), None, gr.Textbox.update("🗑️ Datos borrados.", label=f"Información")
|
133 |
|
134 |
|
135 |
+
css = """
|
136 |
+
.gradio-container {
|
137 |
+
font-family: 'IBM Plex Sans', sans-serif;
|
138 |
+
}
|
139 |
+
footer {
|
140 |
+
visibility: hidden;
|
141 |
+
display: none;
|
142 |
+
}
|
143 |
+
.center-container {
|
144 |
+
display: flex;
|
145 |
+
flex-direction: column;
|
146 |
+
align-items: center;
|
147 |
+
justify-content: center;
|
148 |
+
}
|
149 |
+
"""
|
150 |
+
|
151 |
+
with gr.Blocks(
|
152 |
+
css=css,
|
153 |
+
title="VoiceIt! - Pavloh",
|
154 |
+
theme=gr.themes.Soft(
|
155 |
+
primary_hue="cyan",
|
156 |
+
secondary_hue="blue",
|
157 |
+
radius_size="lg",
|
158 |
+
text_size="lg"
|
159 |
+
).set(loader_color="#0B0F19", shadow_drop='*shadow_drop_lg', block_border_width="3px")
|
160 |
+
) as pavloh:
|
161 |
gr.HTML(
|
162 |
"""
|
163 |
<div class="center-container">
|
|
|
185 |
</div>
|
186 |
"""
|
187 |
)
|
188 |
+
|
189 |
with gr.Row(elem_id="1").style(equal_height=True):
|
190 |
with gr.Column():
|
191 |
d1 = gr.Dropdown([x["name"] for x in get_speakers()], label="📦 Selecciona un modelo", value="Elige un modelo de voz")
|
|
|
198 |
b1 = gr.Button("🎤 Cambiar voz",variant="primary")
|
199 |
b0.click(clear, outputs=[d1, audio, t1])
|
200 |
b1.click(convert, inputs=[d1, audio], outputs=[a2, t1])
|
201 |
+
|
202 |
+
with gr.Row():
|
203 |
+
with gr.Accordion(label="Licencia", open=False):
|
204 |
+
gr.HTML("""
|
205 |
+
<center>
|
206 |
+
<p>
|
207 |
+
<i> Ten en cuenta que los audios deben contener solamente una voz y estar libres de ruido o música de fondo. </i>
|
208 |
+
</p>
|
209 |
+
<p>
|
210 |
+
<i> Asegúrate de que el nombre del archivo no contenga espacios ni símbolos raros, utilizando solo caracteres alfanuméricos y guiones bajos (_) para separar palabras si es necesario. </i>
|
211 |
+
</p>
|
212 |
+
<p>
|
213 |
+
<i> En caso de que tarde más de 5 minutos procesar el audio, es posible que se produzca un error debido a los límites del servidor. En ese caso, tendrás que utilizar VoiceIt localmente usando tus recursos. </i>
|
214 |
+
</p>
|
215 |
+
<p>
|
216 |
+
<i> Al utilizar este sitio web, aceptas la <a style="text-decoration: underline;" href="https://github.com/ImPavloh/voiceit/blob/main/LICENSE">licencia</a> y <a style="text-decoration: underline;" href="https://github.com/ImPavloh/voiceit/blob/main/TERMINOS_DE_USO.txt">condiciones de uso</a>. </i>
|
217 |
+
</p>
|
218 |
+
</center>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
""")
|
220 |
+
|
221 |
if __name__ == "__main__":
|
222 |
pavloh.queue(concurrency_count=3)
|
223 |
pavloh.launch()
|