Spaces:
Runtime error
Runtime error
matias
commited on
Commit
·
48443f7
1
Parent(s):
cd8ff52
fixed space
Browse files- Iso_Logotipo_Ceibal.png +0 -0
- app.py +46 -13
Iso_Logotipo_Ceibal.png
ADDED
|
app.py
CHANGED
|
@@ -20,17 +20,26 @@ pipe = pipe.to(device)
|
|
| 20 |
# pipe.unet = torch.compile(pipe.unet)
|
| 21 |
#pipe.unet = torch.compile(pipe.unet)
|
| 22 |
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
print(text)
|
| 25 |
# text=translate_text(text)
|
| 26 |
text = translate_text(text)
|
|
|
|
| 27 |
#translator = Translator()
|
| 28 |
#text=translator.translate(text, src='es',dest="en").text
|
| 29 |
print(text)
|
| 30 |
waveforms = pipe(text,
|
| 31 |
-
num_inference_steps=
|
| 32 |
-
audio_length_in_s=
|
| 33 |
-
negative_prompt =
|
| 34 |
rate =16000
|
| 35 |
return rate, waveforms[0]
|
| 36 |
#return gr.make_waveform((rate, waveforms[0]))
|
|
@@ -42,18 +51,42 @@ def translate_text(text):
|
|
| 42 |
text = es_en_translator(text)[0].get("translation_text")
|
| 43 |
return text
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
with gr.Row():
|
| 48 |
with gr.Column():
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
with gr.Column():
|
| 54 |
-
output = gr.Audio()
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
|
|
|
|
| 59 |
demo.launch()
|
|
|
|
| 20 |
# pipe.unet = torch.compile(pipe.unet)
|
| 21 |
#pipe.unet = torch.compile(pipe.unet)
|
| 22 |
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
import base64
|
| 26 |
+
|
| 27 |
+
with open("Iso_Logotipo_Ceibal.png", "rb") as image_file:
|
| 28 |
+
encoded_image = base64.b64encode(image_file.read()).decode()
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def generate_sound(text,steps,audio_length,negative_prompt):
|
| 32 |
print(text)
|
| 33 |
# text=translate_text(text)
|
| 34 |
text = translate_text(text)
|
| 35 |
+
negative_prompt = translate_text(negative_prompt)
|
| 36 |
#translator = Translator()
|
| 37 |
#text=translator.translate(text, src='es',dest="en").text
|
| 38 |
print(text)
|
| 39 |
waveforms = pipe(text,
|
| 40 |
+
num_inference_steps=steps,
|
| 41 |
+
audio_length_in_s=audio_length,
|
| 42 |
+
negative_prompt = negative_prompt).audios
|
| 43 |
rate =16000
|
| 44 |
return rate, waveforms[0]
|
| 45 |
#return gr.make_waveform((rate, waveforms[0]))
|
|
|
|
| 51 |
text = es_en_translator(text)[0].get("translation_text")
|
| 52 |
return text
|
| 53 |
|
| 54 |
+
with gr.Blocks() as demo:
|
| 55 |
+
gr.Markdown("""
|
| 56 |
+
<center>
|
| 57 |
+
<h1>
|
| 58 |
+
Uso de AI para la generación de sonidos a partir de texto.
|
| 59 |
+
</h1>
|
| 60 |
+
<img src='data:image/jpg;base64,{}' width=200px>
|
| 61 |
+
<h3>
|
| 62 |
+
Con este espacio podrás generar sondios a partir de texto, intentá ser lo más descriptivo/a posible en el texto. Se puede usar directamente o podés cambiar ajustes, que impacto tiene cada uno está detallado en su descripción. Cambiá valores y mirá los resultados!
|
| 63 |
+
</h3>
|
| 64 |
+
<h4>El texto se traduce del español al inglés para alimetnar al modelo, también se puede escribir el texto de entrada en inglés.</h4>
|
| 65 |
+
</center>
|
| 66 |
+
""".format(encoded_image))
|
| 67 |
with gr.Row():
|
| 68 |
with gr.Column():
|
| 69 |
+
gr.Markdown("Primero debes ingresar el texto para generar el sonido:")
|
| 70 |
+
with gr.Row():
|
| 71 |
+
with gr.Column(scale=4):
|
| 72 |
+
prompt = gr.Textbox(label="Texo base para generar la imagen") #Give prompt some real estate
|
| 73 |
+
with gr.Column(scale=1, min_width=50):
|
| 74 |
+
btn = gr.Button("Generar") #Submit button side by side!
|
| 75 |
+
with gr.Row():
|
| 76 |
+
with gr.Accordion("Opciones avanzadas", open=False): #Let's hide the advanced options!
|
| 77 |
+
negative_prompt = gr.Textbox(label="Texto negativo para la generación", info='Al ingresar texto en este campo el modelo intentará alejarse lo mas posible del mismo, este puede ser "baja calidad"')
|
| 78 |
+
with gr.Row():
|
| 79 |
+
with gr.Column():
|
| 80 |
+
audio_len = gr.Slider(label="Duración del sonido", minimum=1, maximum=30, value=5, step = 1,
|
| 81 |
+
info="Cuánto mayor sonido, mayor será el tiempo de procesamiento.")
|
| 82 |
+
steps = gr.Slider(label="Paos de Inferencia", minimum=1, maximum=100, value=20,step =1 ,
|
| 83 |
+
info="Al aumentar los pasos de inferencia se puede acercar más a la descripción del texto pero con un mayor tiempo de procesamiento.")
|
| 84 |
+
examples = gr.Examples(inputs=[prompt,negative_prompt],examples=[["Un martillo golpeando madera","low quality"]])
|
| 85 |
|
| 86 |
with gr.Column():
|
| 87 |
+
output = gr.Audio(label="Resultado") #Move the output up too
|
| 88 |
+
|
| 89 |
+
btn.click(fn=generate_sound, inputs=[prompt,steps,audio_len,negative_prompt], outputs=[output]) #steps,guidance,width,height]
|
|
|
|
| 90 |
|
| 91 |
+
gr.close_all()
|
| 92 |
demo.launch()
|