Rammohan0504 commited on
Commit
924fc2c
·
verified ·
1 Parent(s): 270cfeb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -40,17 +40,20 @@ def voice_assistant(audio_file):
40
  with gr.Blocks() as demo:
41
  gr.HTML("<h1 style='text-align: center; color: #333;'>🎤 Voice Assistant</h1>")
42
 
43
- # Voice Assistant Section
44
  with gr.Row():
45
- mic_button = gr.Image(
46
- value="/mnt/data/Screenshot 2024-12-28 101858.jpg",
47
- interactive=True,
48
- label="Click to Speak"
49
- )
50
- mic_input = gr.Audio(type="filepath", label="Record Your Query", visible=False)
51
- mic_response = gr.Audio(type="filepath", label="Response", visible=False)
 
 
 
 
52
 
53
- # Link the microphone button to the function
54
- mic_button.click(voice_assistant, inputs=[mic_input], outputs=[mic_response])
55
 
56
  demo.launch()
 
40
  with gr.Blocks() as demo:
41
  gr.HTML("<h1 style='text-align: center; color: #333;'>🎤 Voice Assistant</h1>")
42
 
 
43
  with gr.Row():
44
+ # Microphone icon to prompt users to speak
45
+ gr.HTML(f"""
46
+ <div style="text-align: center;">
47
+ <img src="/mnt/data/Screenshot 2024-12-28 101858.jpg" alt="Microphone"
48
+ style="cursor: pointer; width: 50px; height: 50px;"
49
+ onclick="document.getElementById('audio-input').click()">
50
+ <p>Click the microphone to speak</p>
51
+ </div>
52
+ """)
53
+ mic_input = gr.Audio(id="audio-input", type="filepath", label="Record Your Query")
54
+ response_output = gr.Audio(type="filepath", label="Response")
55
 
56
+ # Link the audio input to the voice assistant function
57
+ mic_input.change(voice_assistant, inputs=[mic_input], outputs=[response_output])
58
 
59
  demo.launch()