import gradio as gr def word_and_char_counter(text) words = text.split() num_words = len(words) num_chars = len(text.replace( , )) # Remove spaces before counting characters return f{num_words} words, {num_chars} characters # Define your interface interface = gr.Interface( fn=word_and_char_counter, inputs=gr.Textbox(lines=2, placeholder=Type something here...), outputs=text, title=Word and Character Counter, description=Counts the words and non-space characters in your text. ) # Launch the app if __name__ == __main__ interface.launch()