Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
# Instalar Python 3.10.7
|
4 |
+
os.system("pip install python==3.10.7")
|
5 |
+
os.system('/usr/local/bin/python -m pip install --upgrade pip')
|
6 |
+
os.system("pip install git+https://github.com/enhuiz/vall-e")
|
7 |
+
os.system("pip install pydub")
|
8 |
+
from pydub import AudioSegment
|
9 |
+
|
10 |
+
def synthesis(audio_file: gr.input_audio, text: str, ar_ckpt: str, nar_ckpt: str):
|
11 |
+
# Cargar el archivo de audio de entrada
|
12 |
+
audio = AudioSegment.from_file(audio_file)
|
13 |
+
# Exportar el archivo de audio a un archivo temporal
|
14 |
+
temp_file = "temp.wav"
|
15 |
+
audio.export(temp_file, format="wav")
|
16 |
+
# Utilizar la función de síntesis de vall-e para generar un archivo de audio de salida
|
17 |
+
output_file = "output.wav"
|
18 |
+
vall_e.synthesis(text, temp_file, output_file, ar_ckpt=ar_ckpt, nar_ckpt=nar_ckpt)
|
19 |
+
# Cargar el archivo de audio de salida
|
20 |
+
output_audio = AudioSegment.from_file(output_file)
|
21 |
+
return output_audio
|
22 |
+
|
23 |
+
synthesis_interface = gr.Interface(synthesis,
|
24 |
+
inputs={"audio_file": gr.input_audio, "text": "text", "ar_ckpt": "text", "nar_ckpt": "text"},
|
25 |
+
outputs=gr.output_audio,
|
26 |
+
live=True,
|
27 |
+
capture_session=True)
|
28 |
+
synthesis_interface.launch()
|