pythontech9 commited on
Commit
44fe398
Β·
verified Β·
1 Parent(s): 90756d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -6
app.py CHANGED
@@ -3,8 +3,6 @@ import os
3
  import pygame # type: ignore
4
  import gradio as gr
5
  from gtts import gTTS # type: ignore
6
- from pydub import AudioSegment
7
- from pydub.playback import play
8
 
9
  # Dog sound files (Ensure these files exist in the same directory)
10
  dog_sounds = {
@@ -16,7 +14,6 @@ dog_sounds = {
16
  "bark": "dog_bark.mp3",
17
  "angry": "mixkit-angry-and-agitated-dog-growling-53.wav",
18
  "happy": "mixkit-happy-puppy-barks-741.wav",
19
-
20
  }
21
 
22
  # Initialize speech recognizer
@@ -79,14 +76,35 @@ def process_command(audio_file):
79
  # Return the dog sound file in the first output
80
  return sound_file, response_text, speech_file
81
 
82
- # Gradio UI
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  iface = gr.Interface(
84
  fn=process_command,
85
  inputs=gr.Audio(sources=["microphone"], type="filepath"),
86
- outputs=["audio", "text", "audio"], # First box now plays dog sound
87
  title="🐢 Dog Command Recognition 🐢",
88
- description="🎀 Speak a command and let the dog respond! πŸ•\n\nTry commands like 'sit', 'come', 'fetch', 'treat', 'play'",
89
  live=True,
 
 
90
  )
91
 
92
  if __name__ == "__main__":
 
3
  import pygame # type: ignore
4
  import gradio as gr
5
  from gtts import gTTS # type: ignore
 
 
6
 
7
  # Dog sound files (Ensure these files exist in the same directory)
8
  dog_sounds = {
 
14
  "bark": "dog_bark.mp3",
15
  "angry": "mixkit-angry-and-agitated-dog-growling-53.wav",
16
  "happy": "mixkit-happy-puppy-barks-741.wav",
 
17
  }
18
 
19
  # Initialize speech recognizer
 
76
  # Return the dog sound file in the first output
77
  return sound_file, response_text, speech_file
78
 
79
+ # Gradio UI with a purple theme
80
+ custom_css = """
81
+ body {
82
+ background-color: #6a0dad;
83
+ color: white;
84
+ text-align: center;
85
+ }
86
+ .gradio-container {
87
+ font-family: 'Arial', sans-serif;
88
+ background-color: #800080;
89
+ padding: 20px;
90
+ border-radius: 15px;
91
+ }
92
+ button {
93
+ background-color: #ffccff !important;
94
+ color: #6a0dad !important;
95
+ font-weight: bold !important;
96
+ }
97
+ """
98
+
99
  iface = gr.Interface(
100
  fn=process_command,
101
  inputs=gr.Audio(sources=["microphone"], type="filepath"),
102
+ outputs=["audio", "text", "audio"],
103
  title="🐢 Dog Command Recognition 🐢",
104
+ description="🎀 Speak a command and let the dog respond! πŸ•\n\nTry commands like 'happy', 'angry', 'sit', 'come', 'fetch', 'treat', 'play'",
105
  live=True,
106
+ theme="compact",
107
+ css=custom_css,
108
  )
109
 
110
  if __name__ == "__main__":