import gradio as gr # Backend processing function def process_text(input_text): # Example processing: Return the text with a prefix return f"Processed Text: {input_text}" # Define the Gradio interface with gr.Blocks() as demo: # Title gr.Markdown("# Speech-to-Text Demo with Web Speech API") # Input and output elements with gr.Row(): input_box = gr.Textbox(label="Speech-to-Text Input", elem_id="speech-input") output_box = gr.Textbox(label="Processed Output") with gr.Row(): speech_button = gr.Button("Start Speech Recognition", elem_id="speech-button") # Link the input box to the backend processing function speech_button.click(process_text, inputs=input_box, outputs=output_box) # Inject JavaScript for Web Speech API gr.HTML(""" """) # Launch the demo demo.launch(share=True, port= 20005)