omar1232 commited on
Commit
ea2069e
·
verified ·
1 Parent(s): 4c13763

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +63 -139
index.html CHANGED
@@ -3,160 +3,84 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Advanced Audio Visualizer with Gradio</title>
7
- <script src="https://cdn.tailwindcss.com"></script>
8
- <script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
9
  <style>
10
- .visualizer-container {
11
- position: relative;
12
- width: 100%;
13
- height: 500px;
14
- background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
15
- border-radius: 16px;
16
- overflow: hidden;
17
- box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
18
- transition: background 0.5s;
19
  }
20
-
21
- .bar {
22
- position: absolute;
23
- bottom: 0;
24
- background: linear-gradient(to top, #00b4db, #0083b0);
25
- border-radius: 6px 6px 0 0;
26
- transition: height 0.1s cubic-bezier(0.4, 0, 0.2, 1);
27
  }
28
-
29
- .audio-wave {
30
- position: absolute;
31
- bottom: 0;
32
- left: 0;
33
- width: 100%;
34
- height: 120px;
35
- background: linear-gradient(to top, rgba(0, 180, 219, 0.2), transparent);
36
- transition: clip-path 0.1s;
37
  }
38
-
39
- .loading-spinner {
40
- display: none;
41
- position: absolute;
42
- top: 50%;
43
- left: 50%;
44
- transform: translate(-50%, -50%);
45
- border: 4px solid rgba(255,255,255,0.3);
46
- border-top: 4px solid #00b4db;
47
- border-radius: 50%;
48
- width: 40px;
49
- height: 40px;
50
- animation: spin 1s linear infinite;
51
  }
52
-
53
- @keyframes spin {
54
- 0% { transform: translate(-50%, -50%) rotate(0deg); }
55
- 100% { transform: translate(-50%, -50%) rotate(360deg); }
 
 
 
 
56
  }
57
-
58
- .bg-animated {
59
- animation: gradient 15s ease infinite;
60
- background-size: 400% 400%;
61
- }
62
-
63
- @keyframes gradient {
64
- 0% { background-position: 0% 50%; }
65
- 50% { background-position: 100% 50%; }
66
- 100% { background-position: 0% 50%; }
67
  }
68
  </style>
69
  </head>
70
- <body class="bg-gray-900 text-white min-h-screen flex flex-col items-center justify-center p-6">
71
- <div class="max-w-6xl w-full">
72
- <h1 class="text-5xl font-extrabold text-center bg-gradient-to-r from-cyan-400 to-pink-500 bg-clip-text text-transparent mb-6">
73
- Advanced Audio Visualizer
74
- </h1>
75
- <p class="text-gray-300 text-center mb-8 font-medium">Visualize audio frequencies using Gradio</p>
76
-
77
- <div class="visualizer-container mb-8 bg-animated" id="visualizer" style="background: linear-gradient(135deg, #1a1a2e, #16213e, #2a2a4e, #1a1a2e);">
78
- <div class="audio-wave" id="audioWave"></div>
79
- <div class="loading-spinner" id="loadingSpinner"></div>
80
- </div>
81
-
82
- <div class="mt-6">
83
- <iframe src="https://huggingface.co/spaces/omar1232/Advanced_Audio_Visualizer" width="100%" height="500" frameborder="0"></iframe>
84
- </div>
85
  </div>
86
 
87
  <script>
88
- document.addEventListener('DOMContentLoaded', () => {
89
- const visualizer = document.getElementById('visualizer');
90
- const audioWave = document.getElementById('audioWave');
91
- const loadingSpinner = document.getElementById('loadingSpinner');
92
- let bars = [];
93
- const barCount = 80;
94
- const barSpacing = 2;
95
-
96
- // Create bars
97
- function createBars() {
98
- visualizer.querySelectorAll('.bar').forEach(bar => bar.remove());
99
- bars = [];
100
-
101
- const containerWidth = visualizer.clientWidth;
102
- const barWidth = (containerWidth / barCount) - barSpacing;
103
-
104
- for (let i = 0; i < barCount; i++) {
105
- const bar = document.createElement('div');
106
- bar.className = 'bar';
107
- bar.style.left = `${i * (barWidth + barSpacing)}px`;
108
- bar.style.width = `${barWidth}px`;
109
- bar.style.height = '0px';
110
- visualizer.appendChild(bar);
111
- bars.push(bar);
112
- }
113
- }
114
-
115
- createBars();
116
-
117
- // Poll Gradio API for visualization data
118
- setInterval(async () => {
119
- try {
120
- // Fetch the latest visualization data from Gradio's JSON output
121
- const response = await fetch('https://huggingface.co/spaces/omar1232/Advanced_Audio_Visualizer/api/predict', {
122
- method: 'POST',
123
- headers: { 'Content-Type': 'application/json' },
124
- body: JSON.stringify({ data: [] }) // Adjust based on Gradio API
125
- });
126
- const data = await response.json();
127
- if (data && data.data && data.data[0]) {
128
- updateVisualization(data.data[0]); // First output is JSON
129
- }
130
- } catch (error) {
131
- console.error('Error fetching data:', error);
132
- }
133
- }, 500); // Poll every 500ms
134
-
135
- function updateVisualization(data) {
136
- const { frequencies } = data;
137
 
138
- // Update bars
139
- const freqCount = Math.min(frequencies.length, barCount);
140
- for (let i = 0; i < freqCount; i++) {
141
- const height = (frequencies[i] / Math.max(...frequencies)) * visualizer.clientHeight * 0.8;
142
- bars[i].style.height = `${height}px`;
 
143
  }
144
-
145
- // Update waveform
146
- const wavePoints = frequencies.map((f, i) => [
147
- (i / frequencies.length) * visualizer.clientWidth,
148
- visualizer.clientHeight * (1 - f / Math.max(...frequencies))
149
- ]);
150
- let wavePath = `path('M0 ${visualizer.clientHeight / 2} `;
151
- wavePoints.forEach(([x, y]) => {
152
- wavePath += `L${x} ${y} `;
153
- });
154
- wavePath += `L${visualizer.clientWidth} ${visualizer.clientHeight / 2} Z')`;
155
- audioWave.style.clipPath = wavePath;
156
  }
157
-
158
- window.addEventListener('resize', createBars);
159
- });
 
160
  </script>
161
  </body>
162
  </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Audio Transcriptor</title>
 
 
7
  <style>
8
+ body {
9
+ font-family: Arial, sans-serif;
10
+ background: #1a1a2e;
11
+ color: #fff;
12
+ text-align: center;
13
+ padding: 20px;
 
 
 
14
  }
15
+ .container {
16
+ max-width: 600px;
17
+ margin: 0 auto;
18
+ background: #16213e;
19
+ padding: 20px;
20
+ border-radius: 10px;
21
+ box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
22
  }
23
+ h1 {
24
+ margin-bottom: 20px;
 
 
 
 
 
 
 
25
  }
26
+ #language, #transcription {
27
+ margin: 10px 0;
28
+ padding: 10px;
29
+ background: #0f172a;
30
+ border-radius: 5px;
 
 
 
 
 
 
 
 
31
  }
32
+ #downloadLink {
33
+ display: inline-block;
34
+ margin-top: 10px;
35
+ padding: 10px 20px;
36
+ background: #00b4db;
37
+ color: #fff;
38
+ text-decoration: none;
39
+ border-radius: 5px;
40
  }
41
+ #downloadLink:hover {
42
+ background: #0083b0;
 
 
 
 
 
 
 
 
43
  }
44
  </style>
45
  </head>
46
+ <body>
47
+ <div class="container">
48
+ <h1>Audio Transcriptor</h1>
49
+ <p>Visit the Gradio app to upload or record audio: <a href="https://huggingface.co/spaces/omar1232/Advanced_Audio_Visualizer" target="_blank">Link</a></p>
50
+ <div id="language">Detected Language: Waiting...</div>
51
+ <div id="transcription">Transcription: Waiting...</div>
52
+ <a id="downloadLink" style="display: none;" href="#" download>Download Transcription</a>
 
 
 
 
 
 
 
 
53
  </div>
54
 
55
  <script>
56
+ async function fetchTranscription() {
57
+ try {
58
+ const response = await fetch('https://huggingface.co/spaces/omar1232/Advanced_Audio_Visualizer/api/predict', {
59
+ method: 'POST',
60
+ headers: { 'Content-Type': 'application/json' },
61
+ body: JSON.stringify({ fn_index: 0, data: [null, null] }) // Adjust based on Gradio API
62
+ });
63
+ const result = await response.json();
64
+ const [language, transcription, textFile] = result.data;
65
+
66
+ // Update UI
67
+ document.getElementById('language').textContent = `Detected Language: ${language || 'Unknown'}`;
68
+ document.getElementById('transcription').textContent = `Transcription: ${transcription || 'No transcription available'}`;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
+ // Update download link
71
+ if (textFile) {
72
+ const downloadLink = document.getElementById('downloadLink');
73
+ downloadLink.href = textFile;
74
+ downloadLink.style.display = 'inline-block';
75
+ downloadLink.textContent = 'Download Transcription';
76
  }
77
+ } catch (error) {
78
+ console.error('Error fetching transcription:', error);
 
 
 
 
 
 
 
 
 
 
79
  }
80
+ }
81
+
82
+ // Poll every 1 second
83
+ setInterval(fetchTranscription, 1000);
84
  </script>
85
  </body>
86
  </html>