Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -296,28 +296,49 @@ def process_lyrics(lyrics: str, song_name: str = "", artist_name: str = ""):
|
|
| 296 |
return display_html, youtube_embed, "Click on a word to get its definition."
|
| 297 |
|
| 298 |
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
}
|
| 319 |
-
""") as demo:
|
| 320 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 321 |
# This is the hidden component that our JavaScript will update.
|
| 322 |
# The `elem_id` is crucial for the JS to find it.
|
| 323 |
hidden_json_input = gr.Textbox(visible=False, elem_id="hidden_json_input")
|
|
|
|
| 296 |
return display_html, youtube_embed, "Click on a word to get its definition."
|
| 297 |
|
| 298 |
|
| 299 |
+
def welcome(name):
|
| 300 |
+
return f"Welcome to Gradio, {name}!"
|
| 301 |
+
|
| 302 |
+
js = """
|
| 303 |
+
function createGradioAnimation() {
|
| 304 |
+
var container = document.createElement('div');
|
| 305 |
+
container.id = 'gradio-animation';
|
| 306 |
+
container.style.fontSize = '2em';
|
| 307 |
+
container.style.fontWeight = 'bold';
|
| 308 |
+
container.style.textAlign = 'center';
|
| 309 |
+
container.style.marginBottom = '20px';
|
| 310 |
+
|
| 311 |
+
var text = 'Welcome to Gradio!';
|
| 312 |
+
for (var i = 0; i < text.length; i++) {
|
| 313 |
+
(function(i){
|
| 314 |
+
setTimeout(function(){
|
| 315 |
+
var letter = document.createElement('span');
|
| 316 |
+
letter.style.opacity = '0';
|
| 317 |
+
letter.style.transition = 'opacity 0.5s';
|
| 318 |
+
letter.innerText = text[i];
|
| 319 |
+
|
| 320 |
+
container.appendChild(letter);
|
| 321 |
+
|
| 322 |
+
setTimeout(function() {
|
| 323 |
+
letter.style.opacity = '1';
|
| 324 |
+
}, 50);
|
| 325 |
+
}, i * 250);
|
| 326 |
+
})(i);
|
| 327 |
}
|
|
|
|
| 328 |
|
| 329 |
+
var gradioContainer = document.querySelector('.gradio-container');
|
| 330 |
+
gradioContainer.insertBefore(container, gradioContainer.firstChild);
|
| 331 |
+
|
| 332 |
+
return 'Animation created';
|
| 333 |
+
}
|
| 334 |
+
"""
|
| 335 |
+
|
| 336 |
+
# Define the Gradio interface
|
| 337 |
+
with gr.Blocks(js=js) as demo:
|
| 338 |
+
|
| 339 |
+
inp = gr.Textbox(placeholder="What is your name?")
|
| 340 |
+
out = gr.Textbox()
|
| 341 |
+
inp.change(welcome, inp, out)
|
| 342 |
# This is the hidden component that our JavaScript will update.
|
| 343 |
# The `elem_id` is crucial for the JS to find it.
|
| 344 |
hidden_json_input = gr.Textbox(visible=False, elem_id="hidden_json_input")
|