Update app.py
Browse files
app.py
CHANGED
|
@@ -31,21 +31,25 @@ We welcome contributions from the open-source community! If you're interested in
|
|
| 31 |
For inquiries or collaboration, feel free to reach out to us through [GitHub](https://github.com/kindahex), or [Hugging Face discussions](https://huggingface.co/spaces/kindahex/README/discussions).
|
| 32 |
"""
|
| 33 |
|
| 34 |
-
# Define
|
| 35 |
def animate_text():
|
| 36 |
for i in range(0, len(content), 100):
|
| 37 |
-
time.sleep(0.1) # Sleep for 100 milliseconds
|
| 38 |
yield content[:i]
|
|
|
|
| 39 |
|
| 40 |
-
#
|
| 41 |
def update_text():
|
| 42 |
-
|
| 43 |
-
for part in animate_text():
|
| 44 |
-
animated = part
|
| 45 |
-
return animated
|
| 46 |
|
|
|
|
| 47 |
with gr.Blocks() as demo:
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
demo.launch()
|
|
|
|
| 31 |
For inquiries or collaboration, feel free to reach out to us through [GitHub](https://github.com/kindahex), or [Hugging Face discussions](https://huggingface.co/spaces/kindahex/README/discussions).
|
| 32 |
"""
|
| 33 |
|
| 34 |
+
# Define the animation function
|
| 35 |
def animate_text():
|
| 36 |
for i in range(0, len(content), 100):
|
|
|
|
| 37 |
yield content[:i]
|
| 38 |
+
time.sleep(0.1) # Sleep for a while between updates
|
| 39 |
|
| 40 |
+
# Update the Gradio interface dynamically
|
| 41 |
def update_text():
|
| 42 |
+
return list(animate_text())[-1]
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
# Create the Gradio interface
|
| 45 |
with gr.Blocks() as demo:
|
| 46 |
+
markdown_output = gr.Markdown()
|
| 47 |
+
|
| 48 |
+
def animate():
|
| 49 |
+
for part in animate_text():
|
| 50 |
+
markdown_output.update(part)
|
| 51 |
+
time.sleep(0.1)
|
| 52 |
+
|
| 53 |
+
demo.load(fn=animate, inputs=[], outputs=markdown_output)
|
| 54 |
|
| 55 |
demo.launch()
|