geethareddy commited on
Commit
1ceb718
·
verified ·
1 Parent(s): 957967f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -23,7 +23,7 @@ async def generate_tts_response(text):
23
  # Welcome Note Handler
24
  async def play_welcome_note():
25
  welcome_text = "Hello, welcome to Biryani Hub. What do you want to order?"
26
- return await generate_tts_response(welcome_text), "Hello, welcome to Biryani Hub. What do you want to order?"
27
 
28
  # Process customer input
29
  async def process_customer_input(audio_file):
@@ -65,13 +65,27 @@ def app():
65
  cart_output = gr.Textbox(label="Cart", placeholder="Your cart details will appear here")
66
 
67
  # Play welcome note
68
- welcome_audio_output.update(value=asyncio.run(play_welcome_note())[0])
 
 
69
 
70
  # Process customer input
 
 
 
 
 
 
 
 
 
 
 
 
71
  customer_audio_input.change(
72
- lambda audio: asyncio.run(process_customer_input(audio)),
73
  inputs=[customer_audio_input],
74
- outputs=[customer_audio_output, transcription_output]
75
  )
76
 
77
  return demo
 
23
  # Welcome Note Handler
24
  async def play_welcome_note():
25
  welcome_text = "Hello, welcome to Biryani Hub. What do you want to order?"
26
+ return await generate_tts_response(welcome_text), welcome_text
27
 
28
  # Process customer input
29
  async def process_customer_input(audio_file):
 
65
  cart_output = gr.Textbox(label="Cart", placeholder="Your cart details will appear here")
66
 
67
  # Play welcome note
68
+ def play_welcome():
69
+ tts_path, welcome_text = asyncio.run(play_welcome_note())
70
+ return tts_path, welcome_text
71
 
72
  # Process customer input
73
+ async def handle_customer_audio(audio):
74
+ tts_path, response_text = await process_customer_input(audio)
75
+ return tts_path, response_text
76
+
77
+ # Welcome button logic
78
+ gr.Button("Play Welcome Note").click(
79
+ play_welcome,
80
+ inputs=[],
81
+ outputs=[welcome_audio_output, transcription_output],
82
+ )
83
+
84
+ # Process customer input logic
85
  customer_audio_input.change(
86
+ lambda audio: asyncio.run(handle_customer_audio(audio)),
87
  inputs=[customer_audio_input],
88
+ outputs=[customer_audio_output, transcription_output],
89
  )
90
 
91
  return demo