Diego-0121 commited on
Commit
add24aa
1 Parent(s): 9be843c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -41,7 +41,18 @@ def recommend_with_youtube_links(song_name, artist_name):
41
  api_key = "AIzaSyAnFiRh8g13HW_wLhUW7wZwRE2SsPo0aJs"
42
  recommendations = recommend_song_interface(song_name, artist_name)
43
  recommendations_with_links = add_youtube_links(recommendations, api_key)
44
- return recommendations_with_links
 
 
 
 
 
 
 
 
 
 
 
45
 
46
  # Configuraci贸n de la interfaz Gradio
47
  iface = gr.Interface(
@@ -50,10 +61,7 @@ iface = gr.Interface(
50
  gr.Textbox(placeholder="Ingrese el t铆tulo de la canci贸n", label="T铆tulo de la Canci贸n"),
51
  gr.Textbox(placeholder="Ingrese el nombre del artista", label="Nombre del Artista")
52
  ],
53
- outputs=[gr.Textbox(label="Recomendaci贸n 1"),
54
- gr.Textbox(label="Recomendaci贸n 2"),
55
- gr.Textbox(label="Recomendaci贸n 3"),
56
- gr.Textbox(label="Recomendaci贸n 4")],
57
  title="Recomendador de Canciones con Enlaces de YouTube",
58
  description="Ingrese el t铆tulo de una canci贸n y el nombre del artista.",
59
  theme="dark", # Comenta o elimina si el tema oscuro no est谩 disponible
 
41
  api_key = "AIzaSyAnFiRh8g13HW_wLhUW7wZwRE2SsPo0aJs"
42
  recommendations = recommend_song_interface(song_name, artist_name)
43
  recommendations_with_links = add_youtube_links(recommendations, api_key)
44
+ html_links = [
45
+ f"<div style='margin: 10px; padding: 10px; border: 1px solid #ccc; border-radius: 5px;'>"
46
+ f"{rec}<br><a href='{link}' target='_blank'>YouTube Link</a></div>"
47
+ if rec and link.startswith('http') else ""
48
+ for rec, link in recommendations_with_links
49
+ ]
50
+
51
+ # Aseg煤rate de devolver la cantidad correcta de salidas esperadas por la interfaz Gradio
52
+ while len(html_links) < 4:
53
+ html_links.append("")
54
+
55
+ return "<br>".join(html_links[:4])
56
 
57
  # Configuraci贸n de la interfaz Gradio
58
  iface = gr.Interface(
 
61
  gr.Textbox(placeholder="Ingrese el t铆tulo de la canci贸n", label="T铆tulo de la Canci贸n"),
62
  gr.Textbox(placeholder="Ingrese el nombre del artista", label="Nombre del Artista")
63
  ],
64
+ outputs= gr.HTML(),
 
 
 
65
  title="Recomendador de Canciones con Enlaces de YouTube",
66
  description="Ingrese el t铆tulo de una canci贸n y el nombre del artista.",
67
  theme="dark", # Comenta o elimina si el tema oscuro no est谩 disponible