Spaces:
Sleeping
Sleeping
Update static/script.js
Browse files- static/script.js +3 -9
static/script.js
CHANGED
|
@@ -4,7 +4,6 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
| 4 |
const submitBtn = document.getElementById('submitBtn');
|
| 5 |
const dropZone = document.getElementById('dropZone');
|
| 6 |
|
| 7 |
-
// Handle File Selection
|
| 8 |
fileInput.addEventListener('change', function(e) {
|
| 9 |
if (this.files && this.files[0]) {
|
| 10 |
fileNameDisplay.textContent = this.files[0].name;
|
|
@@ -14,7 +13,6 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
| 14 |
}
|
| 15 |
});
|
| 16 |
|
| 17 |
-
// Drag and Drop support
|
| 18 |
dropZone.addEventListener('dragover', (e) => {
|
| 19 |
e.preventDefault();
|
| 20 |
dropZone.classList.add('dragover');
|
|
@@ -31,7 +29,6 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
| 31 |
if (e.dataTransfer.files && e.dataTransfer.files[0]) {
|
| 32 |
fileInput.files = e.dataTransfer.files;
|
| 33 |
|
| 34 |
-
// Trigger the change event manually
|
| 35 |
const event = new Event('change');
|
| 36 |
fileInput.dispatchEvent(event);
|
| 37 |
}
|
|
@@ -49,12 +46,10 @@ async function makePrediction() {
|
|
| 49 |
return;
|
| 50 |
}
|
| 51 |
|
| 52 |
-
|
| 53 |
-
submitBtn.innerText = "Extracting Features & Analyzing... (This may take 5-10 seconds)";
|
| 54 |
submitBtn.disabled = true;
|
| 55 |
submitBtn.style.opacity = "0.7";
|
| 56 |
|
| 57 |
-
// Create FormData object to send the file
|
| 58 |
const formData = new FormData();
|
| 59 |
formData.append('audio_file', fileInput.files[0]);
|
| 60 |
|
|
@@ -69,12 +64,12 @@ async function makePrediction() {
|
|
| 69 |
if (response.ok) {
|
| 70 |
const genre = result.prediction;
|
| 71 |
const confidence = result.confidence || 0;
|
| 72 |
-
const barColor = '#
|
| 73 |
|
| 74 |
resultCard.innerHTML = `
|
| 75 |
<div class="result-box">
|
| 76 |
<p style="color: #9ca3af; font-size: 0.9rem; letter-spacing: 1px; margin-bottom:10px;">PREDICTED GENRE</p>
|
| 77 |
-
<div style="font-size: 2.5rem; font-weight: 800; margin: 15px 0; color: #
|
| 78 |
<p style="margin-bottom: 20px; color: #e0e0e0;">Audio feature extraction and classification complete.</p>
|
| 79 |
|
| 80 |
<div style="text-align: left; width: 100%; background: #1c1c2e; padding: 15px; border-radius: 8px; border: 1px solid #2e2e42;">
|
|
@@ -97,7 +92,6 @@ async function makePrediction() {
|
|
| 97 |
alert("Server Error: Make sure the Flask app is running.");
|
| 98 |
}
|
| 99 |
|
| 100 |
-
// Reset Button
|
| 101 |
submitBtn.innerText = originalText;
|
| 102 |
submitBtn.disabled = false;
|
| 103 |
submitBtn.style.opacity = "1";
|
|
|
|
| 4 |
const submitBtn = document.getElementById('submitBtn');
|
| 5 |
const dropZone = document.getElementById('dropZone');
|
| 6 |
|
|
|
|
| 7 |
fileInput.addEventListener('change', function(e) {
|
| 8 |
if (this.files && this.files[0]) {
|
| 9 |
fileNameDisplay.textContent = this.files[0].name;
|
|
|
|
| 13 |
}
|
| 14 |
});
|
| 15 |
|
|
|
|
| 16 |
dropZone.addEventListener('dragover', (e) => {
|
| 17 |
e.preventDefault();
|
| 18 |
dropZone.classList.add('dragover');
|
|
|
|
| 29 |
if (e.dataTransfer.files && e.dataTransfer.files[0]) {
|
| 30 |
fileInput.files = e.dataTransfer.files;
|
| 31 |
|
|
|
|
| 32 |
const event = new Event('change');
|
| 33 |
fileInput.dispatchEvent(event);
|
| 34 |
}
|
|
|
|
| 46 |
return;
|
| 47 |
}
|
| 48 |
|
| 49 |
+
submitBtn.innerText = "Extracting Features & Analyzing... \n(This may take 5-10 seconds)";
|
|
|
|
| 50 |
submitBtn.disabled = true;
|
| 51 |
submitBtn.style.opacity = "0.7";
|
| 52 |
|
|
|
|
| 53 |
const formData = new FormData();
|
| 54 |
formData.append('audio_file', fileInput.files[0]);
|
| 55 |
|
|
|
|
| 64 |
if (response.ok) {
|
| 65 |
const genre = result.prediction;
|
| 66 |
const confidence = result.confidence || 0;
|
| 67 |
+
const barColor = '#7e57c2';
|
| 68 |
|
| 69 |
resultCard.innerHTML = `
|
| 70 |
<div class="result-box">
|
| 71 |
<p style="color: #9ca3af; font-size: 0.9rem; letter-spacing: 1px; margin-bottom:10px;">PREDICTED GENRE</p>
|
| 72 |
+
<div style="font-size: 2.5rem; font-weight: 800; margin: 15px 0; color: #7e57c2; text-transform: capitalize;">${genre}</div>
|
| 73 |
<p style="margin-bottom: 20px; color: #e0e0e0;">Audio feature extraction and classification complete.</p>
|
| 74 |
|
| 75 |
<div style="text-align: left; width: 100%; background: #1c1c2e; padding: 15px; border-radius: 8px; border: 1px solid #2e2e42;">
|
|
|
|
| 92 |
alert("Server Error: Make sure the Flask app is running.");
|
| 93 |
}
|
| 94 |
|
|
|
|
| 95 |
submitBtn.innerText = originalText;
|
| 96 |
submitBtn.disabled = false;
|
| 97 |
submitBtn.style.opacity = "1";
|