File size: 1,835 Bytes
0197ed3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import gradio as gr
import speech_recognition as sr
from transformers import pipeline

# Initialize the Hugging Face pipeline for speech-to-text
speech_to_text = pipeline("automatic-speech-recognition", model="openai/whisper-large")

# Function to process user input (name and email)
def capture_user_info(audio_input):
    # Convert speech to text using Hugging Face's ASR model
    name = speech_to_text(audio_input)["text"]
    
    # Now, ask for the email
    email_prompt = "Please provide your email address."
    
    # Return the name and email prompt
    return name, email_prompt

# Function to capture email input after the name
def capture_email(audio_input):
    # Convert speech to text for the email
    email = speech_to_text(audio_input)["text"]
    return email

# Define Gradio Interface
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:")
            
            # Step 1: Capture 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:")
            
            # Step 2: Capture Email
            audio_input_email.change(capture_email, inputs=audio_input_email, outputs=email_output)

    return demo

# Launch the Gradio Interface
demo = gradio_interface()
demo.launch(debug=True)