jfforero commited on
Commit
4e7ba40
·
verified ·
1 Parent(s): 8bd1fe6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -65
app.py CHANGED
@@ -681,101 +681,67 @@ theme = gr.themes.Soft(primary_hue="red", secondary_hue="orange", font=gr.themes
681
  block_border_color="*neutral_800"
682
  )
683
 
684
-
685
  with gr.Blocks(title="BELLO", fill_width=True, theme=theme) as interface:
686
  gr.HTML('<div class="main-title">Bello</div>')
687
  gr.HTML('<div class="sub-title">Lo que acaba por no terminar</div>')
688
- gr.HTML('<div class="question-title">¿Cómo fue que te perdiste? </div>')
689
 
690
- # PASO 1: Grabación + Botones
691
  with gr.Row():
692
  with gr.Column():
693
  gr.HTML('<div class="step-header">Paso 1: Graba tu experiencia y genera un ambiente virtual afectivo </div>')
694
  audio_input = gr.Audio(label="🎤 Grabadora", type="filepath", sources=["microphone", "upload"])
 
 
695
  with gr.Row():
696
  process_btn = gr.Button("🚀 GENERAR", variant="primary", size="lg")
697
  clear_btn = gr.Button("🗑️ LIMPIAR", variant="secondary")
698
-
699
- # Carga con efecto máquina de escribir y sonido
700
  with gr.Row():
701
  with gr.Column(scale=1):
702
  loading_indicator = gr.Group(visible=False)
703
  with loading_indicator:
704
- gr.HTML('''
705
- <div style="text-align: center;">
706
- <pre id="poetry" style="font-family: monospace; font-size: 16px; color:#ff7f50;"></pre>
707
- </div>
708
- <audio id="typewriter-sound" src="https://cdn.pixabay.com/download/audio/2022/11/05/audio_4d7a4f223b.mp3?filename=typewriter-keys.mp3" loop></audio>
709
- <script>
710
- const poetry = `
711
- A ver, adivine:
712
-
713
- ¿Lengua o labio?
714
- ¿ Bello o terrible?
715
-
716
-
717
- A ver, digame:
718
- ¿La boca dice
719
- O el aire empuja?
720
-
721
- ¿Tiene algo que decir,
722
- O solo tiene ganas de decirlo?
723
-
724
-
725
- A ver:
726
- ¿Es usted ciego?
727
- `;
728
- const textContainer = document.getElementById('poetry');
729
- const sound = document.getElementById('typewriter-sound');
730
- let index = 0;
731
- function typeWriter() {
732
- if (index < poetry.length) {
733
- textContainer.innerHTML += poetry.charAt(index);
734
- sound.currentTime = 0;
735
- sound.play();
736
- index++;
737
- setTimeout(typeWriter, 50);
738
- }
739
- }
740
- typeWriter();
741
- </script>
742
- '''
743
- )
744
  with gr.TabItem("Resultado de la Experiencia", visible=False) as tab:
745
  with gr.Group():
746
  with gr.Row():
747
- emo = gr.Label(label="😌 Tono emocional", elem_id="emotion-label")
748
- sent = gr.Label(label="💭 Análisis sentimental", elem_id="sentiment-label")
749
- trans = gr.Textbox(label="📝 Transcripción", lines=2)
750
  with gr.Row():
751
- img_out = gr.Image(label="🖼️ Imagen Generada°", height=320)
752
- img_file = gr.File(label="", visible=False)
753
  with gr.Row():
754
- audio_out = gr.Audio(label="🎶 Música Generada")
755
- audio_file = gr.File(label="", visible=False)
 
756
  group_components.append(tab)
757
-
758
- # PASO 3: Descargar HTML
759
  with gr.Group(elem_classes="download-section"):
760
  gr.HTML('<div class="step-header">Paso 2: Descarga el HTML y visualizalo en tu navegador</div>')
761
  html_download = gr.File(label="📥 Descargar Visor Inmersivo HTML 360°", type="filepath", interactive=False)
762
- # La opción de publicar en GitHub está comentada para evitar errores
763
- """
764
  publish_btn = gr.Button("📤 Publicar Escena en GitHub (Gist)", variant="primary")
765
- # publish_status = gr.Markdown("")
766
- """
767
-
768
- # Eventos
769
- def clear_all():
770
- return [None, gr.update(visible=False), None, None, None, None, None, None, None, None, ""]
771
 
 
 
 
 
 
 
 
772
  clear_btn.click(
773
- fn=clear_all,
774
  inputs=[],
775
- outputs=[audio_input, loading_indicator, tab, emo, trans, sent, img_out, img_file, audio_out, audio_file, html_download]
776
  )
 
 
777
 
778
- # Montar la app
779
  app = mount_gradio_app(fastapi_app, interface, path="/", theme=theme, css=custom_css)
780
 
781
  if __name__ == "__main__":
 
681
  block_border_color="*neutral_800"
682
  )
683
 
 
684
  with gr.Blocks(title="BELLO", fill_width=True, theme=theme) as interface:
685
  gr.HTML('<div class="main-title">Bello</div>')
686
  gr.HTML('<div class="sub-title">Lo que acaba por no terminar</div>')
687
+ gr.HTML('<div class="question-title">¿Y tú, cómo, cuándo y dónde fue que te perdiste? </div>')
688
 
689
+ # PASO 1: Grabación + Botones acoplados verticalmente abajo
690
  with gr.Row():
691
  with gr.Column():
692
  gr.HTML('<div class="step-header">Paso 1: Graba tu experiencia y genera un ambiente virtual afectivo </div>')
693
  audio_input = gr.Audio(label="🎤 Grabadora", type="filepath", sources=["microphone", "upload"])
694
+
695
+ # Sub-fila interna para colocar los botones debajo del reproductor/editor de audio
696
  with gr.Row():
697
  process_btn = gr.Button("🚀 GENERAR", variant="primary", size="lg")
698
  clear_btn = gr.Button("🗑️ LIMPIAR", variant="secondary")
699
+
700
+ # Visualizador de carga y resultados (Texto Paso 2 removido por completo)
701
  with gr.Row():
702
  with gr.Column(scale=1):
703
  loading_indicator = gr.Group(visible=False)
704
  with loading_indicator:
705
+ gr.HTML('<div class="loader"></div><p style="text-align:center; font-weight:bold; color:#ff7f50;">La IA está dibujando tu panorama y componiendo tu música...</p>')
706
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
707
  with gr.TabItem("Resultado de la Experiencia", visible=False) as tab:
708
  with gr.Group():
709
  with gr.Row():
710
+ emo = gr.Label(label="😌 Tono emocional")
711
+ sent = gr.Label(label="💭 Análisis sentimental")
712
+ trans = gr.Textbox(label="📝 Transcripción del relato", lines=2)
713
  with gr.Row():
714
+ img_out = gr.Image(label="🖼️ Vista Previa Panorama 360°", height=320)
715
+ img_file = gr.File(label="📁 Descargar Imagen 360° (.jpg)")
716
  with gr.Row():
717
+ audio_out = gr.Audio(label="🎶 Música Generada por IA")
718
+ audio_file = gr.File(label="📁 Descargar Audio (.wav)")
719
+
720
  group_components.append(tab)
721
+
722
+ # PASO 3: Descarga e Inmersión
723
  with gr.Group(elem_classes="download-section"):
724
  gr.HTML('<div class="step-header">Paso 2: Descarga el HTML y visualizalo en tu navegador</div>')
725
  html_download = gr.File(label="📥 Descargar Visor Inmersivo HTML 360°", type="filepath", interactive=False)
 
 
726
  publish_btn = gr.Button("📤 Publicar Escena en GitHub (Gist)", variant="primary")
727
+ publish_status = gr.Markdown("")
 
 
 
 
 
728
 
729
+ # Mapeos de eventos
730
+ process_btn.click(
731
+ fn=process_and_display,
732
+ inputs=[audio_input],
733
+ outputs=[loading_indicator, tab, emo, trans, sent, img_out, img_file, audio_out, audio_file, html_download, publish_status]
734
+ )
735
+
736
  clear_btn.click(
737
+ fn=clear_all,
738
  inputs=[],
739
+ outputs=[audio_input, loading_indicator, tab, emo, trans, sent, img_out, img_file, audio_out, audio_file, html_download, publish_status]
740
  )
741
+
742
+ publish_btn.click(fn=publish_to_github, inputs=[html_download], outputs=[publish_status])
743
 
744
+ # Forzar la inicialización con el CSS personalizado oscuro
745
  app = mount_gradio_app(fastapi_app, interface, path="/", theme=theme, css=custom_css)
746
 
747
  if __name__ == "__main__":