geethareddy commited on
Commit
1277d49
·
verified ·
1 Parent(s): f29720a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -13
app.py CHANGED
@@ -1,18 +1,17 @@
1
  import gradio as gr
2
  import whisper
3
- import time
4
  import os
5
 
6
- # Load Whisper ASR Model
 
 
 
7
  model = whisper.load_model("base")
8
 
9
  # Store User Data
10
  user_data = {"name": "", "email": ""}
11
 
12
- # Function to Play Welcome Message
13
- def welcome_message():
14
- return "Welcome to Biryani Hub. Tell me your name."
15
-
16
  # Function to Capture Name
17
  def capture_name(audio):
18
  global user_data
@@ -21,7 +20,8 @@ def capture_name(audio):
21
 
22
  # Save the audio
23
  audio_path = "name.wav"
24
- audio.export(audio_path, format="wav")
 
25
 
26
  # Convert Speech to Text
27
  result = model.transcribe(audio_path)
@@ -37,7 +37,8 @@ def capture_email(audio):
37
 
38
  # Save the audio
39
  audio_path = "email.wav"
40
- audio.export(audio_path, format="wav")
 
41
 
42
  # Convert Speech to Text
43
  result = model.transcribe(audio_path)
@@ -49,18 +50,15 @@ def capture_email(audio):
49
  with gr.Blocks() as demo:
50
  gr.Markdown("# 🎙️ Voice-Enabled Restaurant Menu - Biryani Hub")
51
 
52
- # Welcome Message
53
- welcome = gr.Textbox(value=welcome_message(), interactive=False)
54
-
55
  # Step 1: Capture Name
56
  gr.Markdown("### 🗣️ Step 1: Say Your Name")
57
- name_input = gr.Audio(source="microphone", type="file")
58
  name_output = gr.Textbox()
59
  name_button = gr.Button("Submit Name")
60
 
61
  # Step 2: Capture Email
62
  gr.Markdown("### 📧 Step 2: Say Your Email")
63
- email_input = gr.Audio(source="microphone", type="file")
64
  email_output = gr.Textbox()
65
  email_button = gr.Button("Submit Email")
66
 
 
1
  import gradio as gr
2
  import whisper
3
+ import torch
4
  import os
5
 
6
+ # Suppress Torch Warnings
7
+ torch.serialization._legacy_load = torch.load # Suppresses `torch.load` warnings
8
+
9
+ # Load Whisper Model
10
  model = whisper.load_model("base")
11
 
12
  # Store User Data
13
  user_data = {"name": "", "email": ""}
14
 
 
 
 
 
15
  # Function to Capture Name
16
  def capture_name(audio):
17
  global user_data
 
20
 
21
  # Save the audio
22
  audio_path = "name.wav"
23
+ with open(audio_path, "wb") as f:
24
+ f.write(audio) # Save audio from Gradio
25
 
26
  # Convert Speech to Text
27
  result = model.transcribe(audio_path)
 
37
 
38
  # Save the audio
39
  audio_path = "email.wav"
40
+ with open(audio_path, "wb") as f:
41
+ f.write(audio) # Save audio from Gradio
42
 
43
  # Convert Speech to Text
44
  result = model.transcribe(audio_path)
 
50
  with gr.Blocks() as demo:
51
  gr.Markdown("# 🎙️ Voice-Enabled Restaurant Menu - Biryani Hub")
52
 
 
 
 
53
  # Step 1: Capture Name
54
  gr.Markdown("### 🗣️ Step 1: Say Your Name")
55
+ name_input = gr.Audio(type="filepath") # FIXED!
56
  name_output = gr.Textbox()
57
  name_button = gr.Button("Submit Name")
58
 
59
  # Step 2: Capture Email
60
  gr.Markdown("### 📧 Step 2: Say Your Email")
61
+ email_input = gr.Audio(type="filepath") # FIXED!
62
  email_output = gr.Textbox()
63
  email_button = gr.Button("Submit Email")
64