Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import speech_recognition as sr
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
# Initialize the Hugging Face pipeline for speech-to-text
|
| 6 |
+
speech_to_text = pipeline("automatic-speech-recognition", model="openai/whisper-large")
|
| 7 |
+
|
| 8 |
+
# Function to process user input (name and email)
|
| 9 |
+
def capture_user_info(audio_input):
|
| 10 |
+
# Convert speech to text using Hugging Face's ASR model
|
| 11 |
+
name = speech_to_text(audio_input)["text"]
|
| 12 |
+
|
| 13 |
+
# Now, ask for the email
|
| 14 |
+
email_prompt = "Please provide your email address."
|
| 15 |
+
|
| 16 |
+
# Return the name and email prompt
|
| 17 |
+
return name, email_prompt
|
| 18 |
+
|
| 19 |
+
# Function to capture email input after the name
|
| 20 |
+
def capture_email(audio_input):
|
| 21 |
+
# Convert speech to text for the email
|
| 22 |
+
email = speech_to_text(audio_input)["text"]
|
| 23 |
+
return email
|
| 24 |
+
|
| 25 |
+
# Define Gradio Interface
|
| 26 |
+
def gradio_interface():
|
| 27 |
+
with gr.Blocks() as demo:
|
| 28 |
+
gr.Markdown("### Welcome to Biryani Hub")
|
| 29 |
+
|
| 30 |
+
with gr.Column():
|
| 31 |
+
gr.Markdown("#### Step 1: Tell me your name")
|
| 32 |
+
audio_input_name = gr.Audio(source="microphone", type="filepath", label="Speak your name")
|
| 33 |
+
name_output = gr.Textbox(label="Your Name:")
|
| 34 |
+
|
| 35 |
+
# Step 1: Capture Name
|
| 36 |
+
audio_input_name.change(capture_user_info, inputs=audio_input_name, outputs=[name_output, email_prompt_output])
|
| 37 |
+
|
| 38 |
+
gr.Markdown("#### Step 2: Please provide your email address")
|
| 39 |
+
audio_input_email = gr.Audio(source="microphone", type="filepath", label="Speak your email")
|
| 40 |
+
email_output = gr.Textbox(label="Your Email:")
|
| 41 |
+
|
| 42 |
+
# Step 2: Capture Email
|
| 43 |
+
audio_input_email.change(capture_email, inputs=audio_input_email, outputs=email_output)
|
| 44 |
+
|
| 45 |
+
return demo
|
| 46 |
+
|
| 47 |
+
# Launch the Gradio Interface
|
| 48 |
+
demo = gradio_interface()
|
| 49 |
+
demo.launch(debug=True)
|