thejagstudio commited on
Commit
ee2d751
·
verified ·
1 Parent(s): 1371f37

Upload 3 files

Browse files
Files changed (3) hide show
  1. requirements.txt +2 -0
  2. static/simple.css +85 -0
  3. templates/index.html +341 -0
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ flask
2
+ google-generativeai
static/simple.css ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body {
2
+ font-family: 'Inter', sans-serif;
3
+ }
4
+
5
+ .dropzone {
6
+ border: 2px dashed #e5e7eb;
7
+ border-radius: 0.5rem;
8
+ transition: all 0.3s ease;
9
+ }
10
+
11
+ .dropzone:hover,
12
+ .dropzone.dragover {
13
+ border-color: #3b82f6;
14
+ background-color: rgba(59, 130, 246, 0.05);
15
+ }
16
+
17
+ .pulse {
18
+ animation: pulse 2s infinite;
19
+ }
20
+
21
+ @keyframes pulse {
22
+ 0% {
23
+ box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
24
+ }
25
+
26
+ 70% {
27
+ box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
28
+ }
29
+
30
+ 100% {
31
+ box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
32
+ }
33
+ }
34
+
35
+ .glass-morphism {
36
+ background: rgba(255, 255, 255, 0.7);
37
+ backdrop-filter: blur(10px);
38
+ -webkit-backdrop-filter: blur(10px);
39
+ border: 1px solid rgba(255, 255, 255, 0.18);
40
+ }
41
+
42
+ .gtitlev3 {
43
+ padding-top: 0.25rem;
44
+ padding-bottom: 0.25rem;
45
+ padding-left: 0.5rem;
46
+ padding-right: 0.5rem;
47
+ margin-bottom: 0.75rem;
48
+ border-radius: 0.375rem;
49
+ font-size: 1.5rem;
50
+ line-height: 2rem;
51
+ font-weight: 700;
52
+ text-align: center;
53
+ box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
54
+ background-color: rgb(255 248 220);
55
+ }
56
+
57
+ .chend {
58
+ padding-left: 1.25rem;
59
+ padding-right: 1.25rem;
60
+ margin-top: 0.75rem;
61
+ border-radius: 0.375rem;
62
+ width: fit-content;
63
+ height: 1.5rem;
64
+ font-size: 1.875rem;
65
+ line-height: 2.25rem;
66
+ font-weight: 700;
67
+ text-align: center;
68
+ box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
69
+ color: rgb(49 71 91);
70
+ background-color: rgb(255 248 220);
71
+ }
72
+
73
+ .gpara {
74
+ font-weight: 600;
75
+ color: rgb(49 71 91)
76
+ /* #31475b */
77
+ ;
78
+ }
79
+
80
+ .gparabhajan3 {
81
+ font-weight: 600;
82
+ color: rgb(49 71 91)
83
+ /* #31475b */
84
+ ;
85
+ }
templates/index.html ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Audio to Lyrics Converter</title>
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
10
+ <script src="https://unpkg.com/feather-icons"></script>
11
+ <style>
12
+ body {
13
+ font-family: 'Inter', sans-serif;
14
+ }
15
+
16
+ .dropzone {
17
+ border: 2px dashed #e5e7eb;
18
+ border-radius: 0.5rem;
19
+ transition: all 0.3s ease;
20
+ }
21
+
22
+ .dropzone:hover,
23
+ .dropzone.dragover {
24
+ border-color: #3b82f6;
25
+ background-color: rgba(59, 130, 246, 0.05);
26
+ }
27
+
28
+ .pulse {
29
+ animation: pulse 2s infinite;
30
+ }
31
+
32
+ @keyframes pulse {
33
+ 0% {
34
+ box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
35
+ }
36
+
37
+ 70% {
38
+ box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
39
+ }
40
+
41
+ 100% {
42
+ box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
43
+ }
44
+ }
45
+
46
+ .glass-morphism {
47
+ background: rgba(255, 255, 255, 0.7);
48
+ backdrop-filter: blur(10px);
49
+ -webkit-backdrop-filter: blur(10px);
50
+ border: 1px solid rgba(255, 255, 255, 0.18);
51
+ }
52
+
53
+ .gtitlev3 {
54
+ padding-top: 0.25rem;
55
+ padding-bottom: 0.25rem;
56
+ padding-left: 0.5rem;
57
+ padding-right: 0.5rem;
58
+ margin-bottom: 0.75rem;
59
+ border-radius: 0.375rem;
60
+ font-size: 1.5rem;
61
+ line-height: 2rem;
62
+ font-weight: 700;
63
+ text-align: center;
64
+ box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 #0000000f;
65
+ background-color: #fff8dc;
66
+ }
67
+
68
+ .chend {
69
+ padding-left: 1.25rem;
70
+ padding-right: 1.25rem;
71
+ margin-top: 0.75rem;
72
+ border-radius: 0.375rem;
73
+ width: fit-content;
74
+ height: 1.5rem;
75
+ font-size: 1.875rem;
76
+ line-height: 2.25rem;
77
+ font-weight: 700;
78
+ text-align: center;
79
+ box-shadow: 0 1px 3px 0 #0000001a, 0 1px 2px 0 #0000000f;
80
+ color: rgb(49 71 91);
81
+ background-color: #fff8dc;
82
+ }
83
+
84
+ .gpara {
85
+ font-weight: 600;
86
+ color: rgb(49 71 91)
87
+ /* #31475b */
88
+ ;
89
+ }
90
+
91
+ .gparabhajan3 {
92
+ font-weight: 600;
93
+ color: rgb(49 71 91)
94
+ /* #31475b */
95
+ ;
96
+ }
97
+ </style>
98
+ </head>
99
+
100
+ <body class="bg-gradient-to-br from-blue-50 to-indigo-100 min-h-screen">
101
+ <div class="container mx-auto px-4 py-12 max-w-4xl md:max-w-[90%]">
102
+ <header class="text-center mb-12">
103
+ <h1 class="text-4xl font-bold text-gray-800 mb-2">
104
+ <span class="bg-clip-text text-transparent bg-gradient-to-r from-blue-600 to-indigo-600">Audio to
105
+ Lyrics</span>
106
+ Converter
107
+ </h1>
108
+ <p class="text-gray-600 max-w-xl mx-auto">Transform your audio files into beautifully formatted lyrics with
109
+ AI-powered transcription</p>
110
+ </header>
111
+ <div class="grid grid-cols-1 md:grid-cols-4 gap-8">
112
+ <div class="glass-morphism col-span-1 md:col-span-1 rounded-xl shadow-xl p-8 mb-8 h-fit">
113
+ <div class="dropzone p-8 mb-6 flex flex-col items-center justify-center" id="dropzone">
114
+ <i data-feather="music" class="text-blue-500 mb-4" style="width: 48px; height: 48px;"></i>
115
+ <label class="block text-gray-700 font-medium mb-2">Upload Audio File</label>
116
+ <p class="text-sm text-gray-500 mb-4">Drag & drop your file here or click to browse</p>
117
+ <input type="file" id="audioFile" accept="audio/*" class="hidden">
118
+ <button id="browseBtn"
119
+ class="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-6 rounded-full transition duration-300 flex items-center">
120
+ <i data-feather="upload-cloud" class="mr-2"></i>
121
+ Browse Files
122
+ </button>
123
+ </div>
124
+
125
+ <div class="mb-6">
126
+ <div class="bg-gray-50 rounded-lg p-4 flex items-center" id="fileInfoContainer"
127
+ style="display: none;">
128
+ <div
129
+ class="w-12 h-12 bg-blue-100 rounded-lg flex items-center justify-center mr-3 flex-shrink-0">
130
+ <i data-feather="file" class="text-blue-600"></i>
131
+ </div>
132
+ <div class="flex-grow">
133
+ <p class="font-medium text-gray-800" id="fileName">No file selected</p>
134
+ <p class="text-sm text-gray-500" id="fileSize"></p>
135
+ </div>
136
+ <button id="removeFileBtn"
137
+ class="text-gray-400 hover:text-red-500 transition-colors duration-300">
138
+ <i data-feather="x-circle"></i>
139
+ </button>
140
+ </div>
141
+
142
+ <audio id="audioPlayer" controls class="w-full mt-4 rounded-lg" hidden>
143
+ Your browser does not support the audio element.
144
+ </audio>
145
+ </div>
146
+
147
+ <button id="convertBtn"
148
+ class="w-full bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 text-white font-semibold py-3 px-4 rounded-lg disabled:opacity-50 disabled:cursor-not-allowed transition duration-300 flex items-center justify-center pulse"
149
+ disabled>
150
+ <i data-feather="zap" class="mr-2"></i>
151
+ Convert to Lyrics
152
+ </button>
153
+
154
+ <div id="loadingIndicator" class="hidden mt-6 text-center">
155
+ <div class="inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"></div>
156
+ <p class="mt-2 text-blue-600 font-medium">Processing your audio file...</p>
157
+ <p class="text-sm text-gray-500">This might take a moment depending on file size</p>
158
+ </div>
159
+ </div>
160
+
161
+ <div class="glass-morphism col-span-1 md:col-span-3 rounded-xl shadow-xl p-8">
162
+ <div class="flex items-center justify-between mb-4">
163
+ <h3 class="font-bold text-gray-800 flex items-center">
164
+ <i data-feather="file-text" class="mr-2 text-blue-600"></i>
165
+ Lyrics Output
166
+ </h3>
167
+ <button id="downloadBtn"
168
+ class="hidden bg-green-500 hover:bg-green-600 text-white font-medium py-2 px-4 rounded-full transition duration-300 flex items-center text-sm">
169
+ <i data-feather="download-cloud" class="mr-1"></i>
170
+ Download
171
+ </button>
172
+ </div>
173
+
174
+ <iframe id="lyricsOutputIframe"
175
+ class="p-6 bg-white rounded-lg min-h-[300px] w-full whitespace-pre-line border border-gray-100 text-gray-700 overflow-auto max-h-[500px] md:max-h-[1000px] h-[500px] md:h-[1000px]"
176
+ srcdoc="No lyrics available yet. Upload an audio file and click convert."
177
+ ></iframe>
178
+ </div>
179
+ </div>
180
+
181
+ <footer class="mt-12 text-center text-gray-500 text-sm">
182
+ <p>Powered by AI transcription technology</p>
183
+ <p class="mt-1">© 2025 Audio to Lyrics Converter</p>
184
+ </footer>
185
+ </div>
186
+
187
+ <script>
188
+ // Initialize Feather icons
189
+ feather.replace();
190
+
191
+ const audioFile = document.getElementById('audioFile');
192
+ const browseBtn = document.getElementById('browseBtn');
193
+ const audioPlayer = document.getElementById('audioPlayer');
194
+ const convertBtn = document.getElementById('convertBtn');
195
+ const lyricsOutput = document.getElementById('lyricsOutputIframe');
196
+ const loadingIndicator = document.getElementById('loadingIndicator');
197
+ const downloadBtn = document.getElementById('downloadBtn');
198
+ const dropzone = document.getElementById('dropzone');
199
+ const fileInfoContainer = document.getElementById('fileInfoContainer');
200
+ const fileName = document.getElementById('fileName');
201
+ const fileSize = document.getElementById('fileSize');
202
+ const removeFileBtn = document.getElementById('removeFileBtn');
203
+
204
+ // Handle browse button click
205
+ browseBtn.addEventListener('click', () => {
206
+ audioFile.click();
207
+ });
208
+
209
+ // Format file size
210
+ function formatFileSize(bytes) {
211
+ if (bytes === 0) return '0 Bytes';
212
+ const k = 1024;
213
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
214
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
215
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
216
+ }
217
+
218
+ // Display file info
219
+ function displayFileInfo(file) {
220
+ fileName.textContent = file.name;
221
+ fileSize.textContent = formatFileSize(file.size);
222
+ fileInfoContainer.style.display = 'flex';
223
+
224
+ // Enable convert button and show audio player
225
+ convertBtn.disabled = false;
226
+ convertBtn.classList.add('pulse');
227
+
228
+ const audioUrl = URL.createObjectURL(file);
229
+ audioPlayer.src = audioUrl;
230
+ audioPlayer.hidden = false;
231
+
232
+ // Reset output area
233
+ lyricsOutput.srcdoc = "No lyrics available yet. Upload an audio file and click convert.";
234
+ downloadBtn.classList.add('hidden');
235
+ }
236
+
237
+ // Handle file selection
238
+ audioFile.addEventListener('change', (e) => {
239
+ const file = e.target.files[0];
240
+ if (file) {
241
+ displayFileInfo(file);
242
+ }
243
+ });
244
+
245
+ // Handle remove file button
246
+ removeFileBtn.addEventListener('click', () => {
247
+ audioFile.value = '';
248
+ fileInfoContainer.style.display = 'none';
249
+ audioPlayer.hidden = true;
250
+ audioPlayer.src = '';
251
+ convertBtn.disabled = true;
252
+ convertBtn.classList.remove('pulse');
253
+ lyricsOutput.srcdoc = "No lyrics available yet. Upload an audio file and click convert.";
254
+ downloadBtn.classList.add('hidden');
255
+ });
256
+
257
+ // Handle drag and drop
258
+ ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
259
+ dropzone.addEventListener(eventName, (e) => {
260
+ e.preventDefault();
261
+ e.stopPropagation();
262
+ }, false);
263
+ });
264
+
265
+ ['dragenter', 'dragover'].forEach(eventName => {
266
+ dropzone.addEventListener(eventName, () => {
267
+ dropzone.classList.add('dragover');
268
+ }, false);
269
+ });
270
+
271
+ ['dragleave', 'drop'].forEach(eventName => {
272
+ dropzone.addEventListener(eventName, () => {
273
+ dropzone.classList.remove('dragover');
274
+ }, false);
275
+ });
276
+
277
+ dropzone.addEventListener('drop', (e) => {
278
+ const file = e.dataTransfer.files[0];
279
+ if (file && file.type.startsWith('audio/')) {
280
+ audioFile.files = e.dataTransfer.files;
281
+ displayFileInfo(file);
282
+ }
283
+ }, false);
284
+
285
+ // Handle convert button click
286
+ convertBtn.addEventListener('click', async () => {
287
+ const file = audioFile.files[0];
288
+ if (!file) {
289
+ alert('Please select an audio file first');
290
+ return;
291
+ }
292
+
293
+ // Show loading indicator
294
+ loadingIndicator.classList.remove('hidden');
295
+ convertBtn.disabled = true;
296
+ convertBtn.classList.remove('pulse');
297
+
298
+ const formData = new FormData();
299
+ formData.append('file', file);
300
+
301
+ try {
302
+ const response = await fetch('/convert', {
303
+ method: 'POST',
304
+ body: formData
305
+ });
306
+
307
+ const result = await response.json();
308
+
309
+ if (response.ok) {
310
+ lyricsOutput.srcdoc = result.lyrics; // Render in iframe
311
+ downloadBtn.classList.remove('hidden');
312
+ } else {
313
+ lyricsOutput.srcdoc = `Error: ${result.error}`;
314
+ }
315
+ } catch (error) {
316
+ lyricsOutput.srcdoc = `Error: ${error.message}`;
317
+ } finally {
318
+ // Hide loading indicator
319
+ loadingIndicator.classList.add('hidden');
320
+ convertBtn.disabled = false;
321
+ }
322
+ });
323
+
324
+ // Handle download button click
325
+ downloadBtn.addEventListener('click', () => {
326
+ const lyrics = lyricsOutput.srcdoc;
327
+ const blob = new Blob([lyrics], { type: 'text/html' });
328
+ const url = URL.createObjectURL(blob);
329
+
330
+ const a = document.createElement('a');
331
+ a.href = url;
332
+ a.download = 'lyrics.html';
333
+ document.body.appendChild(a);
334
+ a.click();
335
+ document.body.removeChild(a);
336
+ URL.revokeObjectURL(url);
337
+ });
338
+ </script>
339
+ </body>
340
+
341
+ </html>