import gradio as gr def analyze_text(text): if not text.strip(): return 0, 0, "0 min" words = len(text.split()) characters = len(text) reading_time_minutes = max(1, words // 200) # ~200 wpm return words, characters, f"{reading_time_minutes} min" with gr.Blocks(title="Text Analyzer") as demo: gr.Markdown("# 📝 Text Analyzer") gr.Markdown("Analyze your text instantly using Gradio + Hugging Face Spaces.") text_input = gr.Textbox( label="Enter your text", placeholder="Paste or type your text here...", lines=6 ) analyze_btn = gr.Button("Analyze") with gr.Row(): word_count = gr.Number(label="Word Count") char_count = gr.Number(label="Character Count") read_time = gr.Textbox(label="Estimated Reading Time") analyze_btn.click( fn=analyze_text, inputs=text_input, outputs=[word_count, char_count, read_time] ) demo.launch()