|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import gradio as gr |
|
|
|
demo = gr.Blocks() |
|
|
|
|
|
def process_uploaded_file(uploaded_file: str): |
|
print("uploaded_file", uploaded_file) |
|
return "hello" |
|
|
|
|
|
with demo: |
|
gr.Markdown("Upload audio from disk or record from microphone for recognition") |
|
with gr.Tabs(): |
|
with gr.TabItem("Upload from disk"): |
|
uploaded_file = gr.inputs.Audio( |
|
source="upload", |
|
type="filepath", |
|
optional=False, |
|
label="Upload from disk", |
|
) |
|
upload_button = gr.Button("Upload") |
|
uploaded_output = ( |
|
gr.outputs.Textbox(label="Recognized speech for uploaded file"), |
|
) |
|
|
|
with gr.TabItem("Record from microphone"): |
|
microphone = gr.inputs.Audio( |
|
source="microphone", |
|
type="filepath", |
|
optional=False, |
|
label="Record from microphone", |
|
) |
|
recorded_output = ( |
|
gr.outputs.Textbox(label="Recognized speech for recordings"), |
|
) |
|
|
|
record_button = gr.Button("Record") |
|
|
|
upload_button.click( |
|
process_uploaded_file, |
|
inputs=uploaded_file, |
|
outputs=uploaded_output, |
|
) |
|
record_button.click( |
|
process_uploaded_file, |
|
inputs=microphone, |
|
outputs=recorded_output, |
|
) |
|
|
|
if __name__ == "__main__": |
|
demo.launch() |
|
|