geethareddy commited on
Commit
685e8d2
·
verified ·
1 Parent(s): 0ad9425

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -13,23 +13,21 @@ recognizer = sr.Recognizer()
13
  device = "cuda" if torch.cuda.is_available() else "cpu"
14
  speech_to_text = pipeline("automatic-speech-recognition", model="openai/whisper-base", device=0 if device == "cuda" else -1)
15
 
16
- # Function to generate and play voice prompts
17
  def generate_audio(text, filename):
18
  tts = gTTS(text=text, lang="en")
19
  tts.save(filename)
20
 
 
 
 
 
 
 
21
  @app.route("/")
22
  def home():
23
  return render_template("index.html")
24
 
25
- @app.route("/start_interaction")
26
- def start_interaction():
27
- generate_audio("Welcome to Biryani Hub.", "static/welcome.mp3")
28
- generate_audio("Tell me your name.", "static/ask_name.mp3")
29
- generate_audio("Please provide your email.", "static/ask_email.mp3")
30
- generate_audio("Thank you for registration.", "static/thank_you.mp3")
31
- return jsonify({"status": "Audio prompts generated"})
32
-
33
  @app.route("/process_audio", methods=["POST"])
34
  def process_audio():
35
  if "audio" not in request.files:
 
13
  device = "cuda" if torch.cuda.is_available() else "cpu"
14
  speech_to_text = pipeline("automatic-speech-recognition", model="openai/whisper-base", device=0 if device == "cuda" else -1)
15
 
16
+ # Function to generate and save voice prompts
17
  def generate_audio(text, filename):
18
  tts = gTTS(text=text, lang="en")
19
  tts.save(filename)
20
 
21
+ # Generate all prompts before starting
22
+ generate_audio("Welcome to Biryani Hub.", "static/welcome.mp3")
23
+ generate_audio("Tell me your name.", "static/ask_name.mp3")
24
+ generate_audio("Please provide your email.", "static/ask_email.mp3")
25
+ generate_audio("Thank you for registration.", "static/thank_you.mp3")
26
+
27
  @app.route("/")
28
  def home():
29
  return render_template("index.html")
30
 
 
 
 
 
 
 
 
 
31
  @app.route("/process_audio", methods=["POST"])
32
  def process_audio():
33
  if "audio" not in request.files: