ar08 commited on
Commit
c64fa8b
Β·
verified Β·
1 Parent(s): 9014e8a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -26
app.py CHANGED
@@ -104,43 +104,27 @@ def transcribe_and_chat(audio):
104
  return response, audio_path
105
 
106
  def create_demo():
107
- with gr.Blocks(css="""
108
- .container {
109
- background-color: #f0f4f7;
110
- padding: 20px;
111
- border-radius: 10px;
112
- }
113
- .gr-button {
114
- background-color: #4CAF50;
115
- color: white;
116
- padding: 10px 24px;
117
- border: none;
118
- border-radius: 5px;
119
- cursor: pointer;
120
- }
121
- .gr-button:hover {
122
- background-color: #45a049;
123
- }
124
- """) as demo:
125
  gr.Markdown(
126
  """
127
- <div style="text-align: center;">
128
- <h1 style="color: #333;">πŸ—£οΈ AI Voice Assistant</h1>
129
- <p>Record your voice, and the assistant will respond with both text and speech. Powered by advanced AI models.</p>
130
- </div>
131
  """
132
  )
133
 
134
- with gr.Row().style(margin_top="20px"):
135
  with gr.Column(scale=1):
136
  audio_input = gr.Audio(type="filepath", label="🎀 Record your voice", elem_id="audio-input")
137
- clear_button = gr.Button("Clear", variant="secondary", elem_id="clear-button", style={"margin-top": "10px"})
138
  voice_volume = gr.Slider(minimum=0, maximum=2, value=1, step=0.1, label="Voice Volume", elem_id="voice-volume")
139
 
140
  with gr.Column(scale=1):
141
  chat_output = gr.Textbox(label="πŸ’¬ AI Response", elem_id="chat-output", lines=5, interactive=False)
142
  audio_output = gr.Audio(label="πŸ”Š AI Voice Response", autoplay=True, elem_id="audio-output")
143
 
 
 
 
144
  # Processing the audio input
145
  def process_audio(audio, volume):
146
  logging.info(f"Received audio: {audio}")
@@ -163,7 +147,7 @@ def create_demo():
163
  document.querySelector('button[title="Submit"]').click();
164
  }, 500);
165
  });
166
-
167
  function playAssistantAudio() {
168
  var audioElements = document.querySelectorAll('audio');
169
  if (audioElements.length > 1) {
@@ -197,4 +181,4 @@ def create_demo():
197
  # Launch the Gradio app
198
  if __name__ == "__main__":
199
  demo = create_demo()
200
- demo.launch(server_name="0.0.0.0", server_port=7860)
 
104
  return response, audio_path
105
 
106
  def create_demo():
107
+ with gr.Blocks() as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  gr.Markdown(
109
  """
110
+ # πŸ—£οΈ AI Voice Assistant
111
+ Welcome to your personal voice assistant! Simply record your voice, and I will respond with both text and speech. Powered by advanced AI models.
 
 
112
  """
113
  )
114
 
115
+ with gr.Row():
116
  with gr.Column(scale=1):
117
  audio_input = gr.Audio(type="filepath", label="🎀 Record your voice", elem_id="audio-input")
118
+ clear_button = gr.Button("Clear", variant="secondary", elem_id="clear-button")
119
  voice_volume = gr.Slider(minimum=0, maximum=2, value=1, step=0.1, label="Voice Volume", elem_id="voice-volume")
120
 
121
  with gr.Column(scale=1):
122
  chat_output = gr.Textbox(label="πŸ’¬ AI Response", elem_id="chat-output", lines=5, interactive=False)
123
  audio_output = gr.Audio(label="πŸ”Š AI Voice Response", autoplay=True, elem_id="audio-output")
124
 
125
+ # Add some spacing and a divider
126
+ gr.Markdown("---")
127
+
128
  # Processing the audio input
129
  def process_audio(audio, volume):
130
  logging.info(f"Received audio: {audio}")
 
147
  document.querySelector('button[title="Submit"]').click();
148
  }, 500);
149
  });
150
+
151
  function playAssistantAudio() {
152
  var audioElements = document.querySelectorAll('audio');
153
  if (audioElements.length > 1) {
 
181
  # Launch the Gradio app
182
  if __name__ == "__main__":
183
  demo = create_demo()
184
+ demo.launch(server_name="0.0.0.0", server_port=7860)