|
import gradio as gr |
|
import time |
|
|
|
def count_chars_with_delay(word_text,count_text): |
|
count_text = gr.Textbox(label="Count", value=str(int(len(word_text))), visible=True) |
|
return count_text |
|
|
|
with gr.Blocks() as demo: |
|
input_text = gr.Textbox(label="input") |
|
@gr.render(inputs=input_text, triggers=[input_text.submit]) |
|
def show_split(text): |
|
if len(text) == 0: |
|
gr.Markdown("## No Input Provided") |
|
else: |
|
for word in text.split(): |
|
with gr.Row(): |
|
word_text = gr.Textbox(label="Word", value=word) |
|
count_text = gr.Textbox(label="Count", value="") |
|
Timer=gr.Timer() |
|
Timer.tick(fn=count_chars_with_delay,inputs=[word_text,count_text],outputs=count_text,every=2) |
|
|
|
demo.launch() |