Spaces:
Sleeping
Sleeping
Update index.html
Browse files- 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>
|
| 7 |
-
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
-
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
|
| 9 |
<style>
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
overflow: hidden;
|
| 17 |
-
box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
|
| 18 |
-
transition: background 0.5s;
|
| 19 |
}
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
border-radius:
|
| 26 |
-
|
| 27 |
}
|
| 28 |
-
|
| 29 |
-
|
| 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 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 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 |
-
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
}
|
| 57 |
-
|
| 58 |
-
|
| 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
|
| 71 |
-
<div class="
|
| 72 |
-
<h1
|
| 73 |
-
|
| 74 |
-
</
|
| 75 |
-
<
|
| 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 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 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
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
|
|
|
| 143 |
}
|
| 144 |
-
|
| 145 |
-
|
| 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 |
-
|
| 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>
|