Hev832 commited on
Commit
5d24592
·
verified ·
1 Parent(s): 6885980

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -9
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 an animation function
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
- # Create the Gradio interface
41
  def update_text():
42
- animated = ""
43
- for part in animate_text():
44
- animated = part
45
- return animated
46
 
 
47
  with gr.Blocks() as demo:
48
- text_output = gr.Markdown("")
49
- demo.markdown(content=update_text)
 
 
 
 
 
 
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()