ibrahim313 commited on
Commit
e4852e2
·
verified ·
1 Parent(s): 1329434

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -79
app.py CHANGED
@@ -9,7 +9,7 @@ from groq import Groq
9
  os.environ['GROQ_API_KEY'] = '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'
10
  groq_client = Groq(api_key=os.environ.get('GROQ_API_KEY'))
11
 
12
- # Load Whisper model (use `whisper.load_model` from the correct library)
13
  whisper_model = whisper.load_model("base")
14
 
15
  def process_audio(audio_file):
@@ -39,89 +39,47 @@ def process_audio(audio_file):
39
  except Exception as e:
40
  return str(e), None
41
 
42
- # Define custom CSS for the Gradio interface
43
  css = """
44
- /* General body styling */
45
- body {
46
- background: #f0f2f5; /* Light background for the app */
47
- font-family: 'Arial', sans-serif;
48
- color: #333;
49
- }
50
-
51
- /* Container styling */
52
- .gradio-container {
53
- background: linear-gradient(135deg, #6e45e2, #88d3ce);
54
- border-radius: 15px;
55
- box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.1);
56
- padding: 20px;
57
- margin: auto; /* Centering container */
58
- width: 80%; /* Adjusted width for responsiveness */
59
- max-width: 700px; /* Max width for larger screens */
60
- }
61
-
62
- /* Title styling */
63
- .gradio-title {
64
- color: #0056b3; /* Deep blue color for the title */
65
- text-align: center;
66
- margin-bottom: 20px;
67
- font-size: 28px;
68
- font-weight: bold;
69
- }
70
-
71
- /* Input and output styling */
72
- .gradio-input, .gradio-output {
73
- border-radius: 10px;
74
- box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.15);
75
- }
76
-
77
- /* Textbox styling */
78
- .gradio-textbox {
79
- border: 2px solid #6e45e2;
80
- background: #fff;
81
- color: #333;
82
- padding: 10px;
83
- font-size: 16px;
84
- }
85
-
86
- /* Number component styling */
87
- .gradio-number {
88
- border: 2px solid #6e45e2;
89
- background: #fff;
90
- color: #333;
91
- border-radius: 8px;
92
- padding: 10px;
93
- }
94
-
95
- /* Button styling */
96
- .gradio-button {
97
- background: #6e45e2; /* Deep blue color for button */
98
- color: #fff;
99
- border: none;
100
- border-radius: 8px;
101
- padding: 12px 24px;
102
- font-size: 18px;
103
- cursor: pointer;
104
- transition: background 0.3s, transform 0.3s;
105
- }
106
-
107
- .gradio-button:hover {
108
- background: #5a3d9c; /* Darker blue on hover */
109
- transform: scale(1.05); /* Slightly enlarge on hover */
110
- }
111
  """
112
 
113
- # Create Gradio interface with custom CSS
114
  iface = gr.Interface(
115
  fn=process_audio,
116
- inputs=gr.Audio(type="filepath", label="Upload Audio File"),
117
- outputs=[gr.Textbox(label="Response Text"), gr.Audio(label="Response Audio")],
118
  live=True,
119
- css=css,
120
- title="Audio Transcription and Response Generator",
121
- description="Upload an audio file to get a transcription and a response generated by the Llama 8b model.",
122
- article="<h3>How to Use:</h3><ul><li>Upload an audio file.</li><li>Receive a transcribed text and response.</li></ul>"
123
  )
124
 
125
- # Launch the Gradio app
126
- if __name__ == "__main__":
127
- iface.launch()
 
9
  os.environ['GROQ_API_KEY'] = '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'
10
  groq_client = Groq(api_key=os.environ.get('GROQ_API_KEY'))
11
 
12
+ # Load Whisper model
13
  whisper_model = whisper.load_model("base")
14
 
15
  def process_audio(audio_file):
 
39
  except Exception as e:
40
  return str(e), None
41
 
42
+ # Create Gradio interface with custom CSS
43
  css = """
44
+ .gradio-container {
45
+ background: linear-gradient(135deg, #6e45e2, #88d3ce);
46
+ border-radius: 15px;
47
+ box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.1);
48
+ padding: 20px;
49
+ }
50
+ .gradio-input, .gradio-output {
51
+ border-radius: 10px;
52
+ box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.15);
53
+ }
54
+ .gradio-textbox {
55
+ border: 2px solid #6e45e2;
56
+ background: #fff;
57
+ color: #333;
58
+ }
59
+ .gradio-audio {
60
+ border: 2px solid #88d3ce;
61
+ background: #fff;
62
+ }
63
+ .gradio-button {
64
+ background: #6e45e2;
65
+ color: #fff;
66
+ border: none;
67
+ border-radius: 8px;
68
+ padding: 10px 20px;
69
+ font-size: 16px;
70
+ cursor: pointer;
71
+ }
72
+ .gradio-button:hover {
73
+ background: #5a3d9c;
74
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  """
76
 
 
77
  iface = gr.Interface(
78
  fn=process_audio,
79
+ inputs=gr.Audio(type="filepath"),
80
+ outputs=[gr.Textbox(label="Response"), gr.Audio(label="Response Audio")],
81
  live=True,
82
+ css=css
 
 
 
83
  )
84
 
85
+ iface.launch()