Spaces:
Build error
Build error
Update app.py
Browse files
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
|
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 |
-
#
|
43 |
css = """
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
}
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
.gradio-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
.gradio-
|
73 |
-
|
74 |
-
|
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"
|
117 |
-
outputs=[gr.Textbox(label="Response
|
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 |
-
|
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()
|
|
|
|