|
import gradio as gr |
|
import speech_recognition as sr |
|
from transformers import pipeline |
|
|
|
|
|
speech_to_text = pipeline("automatic-speech-recognition", model="openai/whisper-large") |
|
|
|
|
|
def capture_user_info(audio_input): |
|
|
|
name = speech_to_text(audio_input)["text"] |
|
|
|
|
|
email_prompt = "Please provide your email address." |
|
|
|
|
|
return name, email_prompt |
|
|
|
|
|
def capture_email(audio_input): |
|
|
|
email = speech_to_text(audio_input)["text"] |
|
return email |
|
|
|
|
|
def gradio_interface(): |
|
with gr.Blocks() as demo: |
|
gr.Markdown("### Welcome to Biryani Hub") |
|
|
|
with gr.Column(): |
|
gr.Markdown("#### Step 1: Tell me your name") |
|
audio_input_name = gr.Audio(source="microphone", type="filepath", label="Speak your name") |
|
name_output = gr.Textbox(label="Your Name:") |
|
|
|
|
|
audio_input_name.change(capture_user_info, inputs=audio_input_name, outputs=[name_output, email_prompt_output]) |
|
|
|
gr.Markdown("#### Step 2: Please provide your email address") |
|
audio_input_email = gr.Audio(source="microphone", type="filepath", label="Speak your email") |
|
email_output = gr.Textbox(label="Your Email:") |
|
|
|
|
|
audio_input_email.change(capture_email, inputs=audio_input_email, outputs=email_output) |
|
|
|
return demo |
|
|
|
|
|
demo = gradio_interface() |
|
demo.launch(debug=True) |
|
|