Spaces:
Sleeping
Sleeping
Delete interactive_report.html
Browse files- interactive_report.html +0 -313
interactive_report.html
DELETED
|
@@ -1,313 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>Truth Detection</title>
|
| 7 |
-
<!-- Tailwind CSS CDN -->
|
| 8 |
-
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
-
<!-- Inter font from Google Fonts -->
|
| 10 |
-
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
|
| 11 |
-
<style>
|
| 12 |
-
body {
|
| 13 |
-
font-family: 'Inter', sans-serif;
|
| 14 |
-
background-color: #f0f2f5; /* Light gray background */
|
| 15 |
-
display: flex;
|
| 16 |
-
justify-content: center;
|
| 17 |
-
align-items: center;
|
| 18 |
-
min-height: 100vh;
|
| 19 |
-
margin: 0;
|
| 20 |
-
padding: 20px;
|
| 21 |
-
box-sizing: border-box;
|
| 22 |
-
}
|
| 23 |
-
.container {
|
| 24 |
-
background-color: #ffffff;
|
| 25 |
-
border-radius: 1.5rem; /* More rounded corners */
|
| 26 |
-
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1); /* Softer shadow */
|
| 27 |
-
padding: 2.5rem; /* Increased padding */
|
| 28 |
-
max-width: 900px; /* Max width for better readability */
|
| 29 |
-
width: 100%;
|
| 30 |
-
display: flex;
|
| 31 |
-
flex-direction: column;
|
| 32 |
-
gap: 2rem; /* Space between sections */
|
| 33 |
-
}
|
| 34 |
-
.dashboard-card {
|
| 35 |
-
background-color: #f8fafd; /* Lighter background for cards */
|
| 36 |
-
border-radius: 1rem;
|
| 37 |
-
padding: 1.5rem;
|
| 38 |
-
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05); /* Inner shadow for depth */
|
| 39 |
-
display: flex;
|
| 40 |
-
flex-direction: column;
|
| 41 |
-
align-items: center;
|
| 42 |
-
justify-content: center;
|
| 43 |
-
text-align: center;
|
| 44 |
-
}
|
| 45 |
-
.upload-area {
|
| 46 |
-
border: 3px dashed #cbd5e1; /* Dashed border */
|
| 47 |
-
border-radius: 1rem;
|
| 48 |
-
padding: 2.5rem;
|
| 49 |
-
text-align: center;
|
| 50 |
-
cursor: pointer;
|
| 51 |
-
transition: all 0.3s ease;
|
| 52 |
-
background-color: #fdfefe; /* Very light background */
|
| 53 |
-
}
|
| 54 |
-
.upload-area:hover {
|
| 55 |
-
border-color: #6366f1; /* Purple on hover */
|
| 56 |
-
background-color: #eff6ff; /* Light blue on hover */
|
| 57 |
-
}
|
| 58 |
-
.upload-area.dragover {
|
| 59 |
-
border-color: #6366f1;
|
| 60 |
-
background-color: #eff6ff;
|
| 61 |
-
}
|
| 62 |
-
.file-input-label {
|
| 63 |
-
display: block;
|
| 64 |
-
cursor: pointer;
|
| 65 |
-
color: #4f46e5; /* Purple text for link */
|
| 66 |
-
font-weight: 600;
|
| 67 |
-
margin-top: 0.5rem;
|
| 68 |
-
}
|
| 69 |
-
.file-input-label:hover {
|
| 70 |
-
text-decoration: underline;
|
| 71 |
-
}
|
| 72 |
-
.predict-button {
|
| 73 |
-
background-color: #4f46e5; /* Purple button */
|
| 74 |
-
color: white;
|
| 75 |
-
padding: 0.75rem 1.5rem;
|
| 76 |
-
border-radius: 0.75rem; /* Rounded button */
|
| 77 |
-
font-weight: 600;
|
| 78 |
-
transition: background-color 0.3s ease, transform 0.2s ease;
|
| 79 |
-
box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3); /* Button shadow */
|
| 80 |
-
}
|
| 81 |
-
.predict-button:hover {
|
| 82 |
-
background-color: #4338ca; /* Darker purple on hover */
|
| 83 |
-
transform: translateY(-2px); /* Slight lift effect */
|
| 84 |
-
}
|
| 85 |
-
.predict-button:active {
|
| 86 |
-
transform: translateY(0);
|
| 87 |
-
box-shadow: 0 2px 5px rgba(79, 70, 229, 0.3);
|
| 88 |
-
}
|
| 89 |
-
.result-box {
|
| 90 |
-
background-color: #ecfdf5; /* Light green for true, light red for false */
|
| 91 |
-
border-left: 6px solid #10b981; /* Green border for true */
|
| 92 |
-
border-radius: 0.75rem;
|
| 93 |
-
padding: 1.5rem;
|
| 94 |
-
display: flex;
|
| 95 |
-
align-items: center;
|
| 96 |
-
gap: 1rem;
|
| 97 |
-
font-weight: 600;
|
| 98 |
-
color: #065f46; /* Dark green text */
|
| 99 |
-
transition: all 0.3s ease;
|
| 100 |
-
}
|
| 101 |
-
.result-box.false {
|
| 102 |
-
background-color: #fef2f2; /* Light red */
|
| 103 |
-
border-left-color: #ef4444; /* Red border */
|
| 104 |
-
color: #991b1b; /* Dark red text */
|
| 105 |
-
}
|
| 106 |
-
.message-box {
|
| 107 |
-
background-color: #fffbeb; /* Light yellow for info/warnings */
|
| 108 |
-
border-left: 6px solid #f59e0b;
|
| 109 |
-
border-radius: 0.75rem;
|
| 110 |
-
padding: 1rem;
|
| 111 |
-
color: #92400e;
|
| 112 |
-
font-weight: 500;
|
| 113 |
-
margin-top: 1rem;
|
| 114 |
-
display: none; /* Hidden by default */
|
| 115 |
-
}
|
| 116 |
-
</style>
|
| 117 |
-
</head>
|
| 118 |
-
<body>
|
| 119 |
-
<div class="container">
|
| 120 |
-
<!-- Header -->
|
| 121 |
-
<header class="text-center">
|
| 122 |
-
<h1 class="text-4xl font-extrabold text-gray-800 mb-2">Truth Detection</h1>
|
| 123 |
-
<p class="text-gray-600 text-lg">Upload an audio file to predict the truthfulness of a narrated story.</p>
|
| 124 |
-
</header>
|
| 125 |
-
|
| 126 |
-
<!-- Dashboard Section -->
|
| 127 |
-
<section class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
| 128 |
-
<div class="dashboard-card">
|
| 129 |
-
<p class="text-5xl font-bold text-green-600">91%</p>
|
| 130 |
-
<p class="text-gray-600 text-lg mt-2">Accuracy</p>
|
| 131 |
-
</div>
|
| 132 |
-
<div class="dashboard-card">
|
| 133 |
-
<p class="text-5xl font-bold text-blue-600">15+</p>
|
| 134 |
-
<p class="text-gray-600 text-lg mt-2">Languages Used</p>
|
| 135 |
-
</div>
|
| 136 |
-
</section>
|
| 137 |
-
|
| 138 |
-
<!-- Upload Section -->
|
| 139 |
-
<section>
|
| 140 |
-
<h2 class="text-2xl font-bold text-gray-800 mb-4">Upload Audio</h2>
|
| 141 |
-
<div id="uploadArea" class="upload-area">
|
| 142 |
-
<input type="file" id="audioFileInput" accept="audio/*" class="hidden">
|
| 143 |
-
<p class="text-gray-500 text-lg">Drag & drop your audio file here, or</p>
|
| 144 |
-
<label for="audioFileInput" class="file-input-label">browse to upload</label>
|
| 145 |
-
<p id="fileNameDisplay" class="text-gray-700 font-medium mt-2"></p>
|
| 146 |
-
</div>
|
| 147 |
-
<div id="messageBox" class="message-box"></div>
|
| 148 |
-
<button id="predictButton" class="predict-button w-full mt-6 opacity-50 cursor-not-allowed" disabled>
|
| 149 |
-
Analyze Truthfulness
|
| 150 |
-
</button>
|
| 151 |
-
</section>
|
| 152 |
-
|
| 153 |
-
<!-- Results Section -->
|
| 154 |
-
<section id="resultsSection" class="hidden">
|
| 155 |
-
<h2 class="text-2xl font-bold text-gray-800 mb-4">Prediction Result</h2>
|
| 156 |
-
<div id="predictionResult" class="result-box">
|
| 157 |
-
<svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8 text-green-600" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
| 158 |
-
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
|
| 159 |
-
</svg>
|
| 160 |
-
<span id="predictionText" class="text-xl">The story is likely TRUE.</span>
|
| 161 |
-
</div>
|
| 162 |
-
</section>
|
| 163 |
-
</div>
|
| 164 |
-
|
| 165 |
-
<script>
|
| 166 |
-
// Get references to DOM elements
|
| 167 |
-
const audioFileInput = document.getElementById('audioFileInput');
|
| 168 |
-
const fileNameDisplay = document.getElementById('fileNameDisplay');
|
| 169 |
-
const uploadArea = document.getElementById('uploadArea');
|
| 170 |
-
const predictButton = document.getElementById('predictButton');
|
| 171 |
-
const resultsSection = document.getElementById('resultsSection');
|
| 172 |
-
const predictionResult = document.getElementById('predictionResult');
|
| 173 |
-
const predictionText = document.getElementById('predictionText');
|
| 174 |
-
const messageBox = document.getElementById('messageBox');
|
| 175 |
-
|
| 176 |
-
let uploadedFile = null; // Variable to store the uploaded file
|
| 177 |
-
|
| 178 |
-
// Function to display messages in the message box
|
| 179 |
-
function showMessage(message, type = 'info') {
|
| 180 |
-
messageBox.textContent = message;
|
| 181 |
-
messageBox.className = 'message-box block'; // Show the box
|
| 182 |
-
if (type === 'error') {
|
| 183 |
-
messageBox.style.borderColor = '#ef4444';
|
| 184 |
-
messageBox.style.color = '#991b1b';
|
| 185 |
-
messageBox.style.backgroundColor = '#fef2f2';
|
| 186 |
-
} else { // info or default
|
| 187 |
-
messageBox.style.borderColor = '#f59e0b';
|
| 188 |
-
messageBox.style.color = '#92400e';
|
| 189 |
-
messageBox.style.backgroundColor = '#fffbeb';
|
| 190 |
-
}
|
| 191 |
-
}
|
| 192 |
-
|
| 193 |
-
// Function to hide the message box
|
| 194 |
-
function hideMessage() {
|
| 195 |
-
messageBox.style.display = 'none';
|
| 196 |
-
}
|
| 197 |
-
|
| 198 |
-
// Handle file selection via input
|
| 199 |
-
audioFileInput.addEventListener('change', (event) => {
|
| 200 |
-
if (event.target.files.length > 0) {
|
| 201 |
-
uploadedFile = event.target.files[0];
|
| 202 |
-
fileNameDisplay.textContent = `Selected file: ${uploadedFile.name}`;
|
| 203 |
-
predictButton.disabled = false;
|
| 204 |
-
predictButton.classList.remove('opacity-50', 'cursor-not-allowed');
|
| 205 |
-
hideMessage(); // Hide any previous messages
|
| 206 |
-
} else {
|
| 207 |
-
uploadedFile = null;
|
| 208 |
-
fileNameDisplay.textContent = '';
|
| 209 |
-
predictButton.disabled = true;
|
| 210 |
-
predictButton.classList.add('opacity-50', 'cursor-not-allowed');
|
| 211 |
-
}
|
| 212 |
-
resultsSection.classList.add('hidden'); // Hide results when a new file is selected
|
| 213 |
-
});
|
| 214 |
-
|
| 215 |
-
// Handle drag and drop
|
| 216 |
-
uploadArea.addEventListener('dragover', (event) => {
|
| 217 |
-
event.preventDefault(); // Prevent default to allow drop
|
| 218 |
-
uploadArea.classList.add('dragover');
|
| 219 |
-
});
|
| 220 |
-
|
| 221 |
-
uploadArea.addEventListener('dragleave', () => {
|
| 222 |
-
uploadArea.classList.remove('dragover');
|
| 223 |
-
});
|
| 224 |
-
|
| 225 |
-
uploadArea.addEventListener('drop', (event) => {
|
| 226 |
-
event.preventDefault();
|
| 227 |
-
uploadArea.classList.remove('dragover');
|
| 228 |
-
|
| 229 |
-
if (event.dataTransfer.files.length > 0) {
|
| 230 |
-
const file = event.dataTransfer.files[0];
|
| 231 |
-
// Check if the dropped file is an audio file
|
| 232 |
-
if (file.type.startsWith('audio/')) {
|
| 233 |
-
uploadedFile = file;
|
| 234 |
-
fileNameDisplay.textContent = `Selected file: ${uploadedFile.name}`;
|
| 235 |
-
predictButton.disabled = false;
|
| 236 |
-
predictButton.classList.remove('opacity-50', 'cursor-not-allowed');
|
| 237 |
-
hideMessage(); // Hide any previous messages
|
| 238 |
-
} else {
|
| 239 |
-
uploadedFile = null;
|
| 240 |
-
fileNameDisplay.textContent = '';
|
| 241 |
-
predictButton.disabled = true;
|
| 242 |
-
predictButton.classList.add('opacity-50', 'cursor-not-allowed');
|
| 243 |
-
showMessage('Please upload an audio file.', 'error');
|
| 244 |
-
}
|
| 245 |
-
}
|
| 246 |
-
resultsSection.classList.add('hidden'); // Hide results when a new file is dropped
|
| 247 |
-
});
|
| 248 |
-
|
| 249 |
-
// Modified prediction on button click to simulate API call
|
| 250 |
-
predictButton.addEventListener('click', async () => {
|
| 251 |
-
if (uploadedFile) {
|
| 252 |
-
predictButton.textContent = 'Analyzing...';
|
| 253 |
-
predictButton.disabled = true;
|
| 254 |
-
predictButton.classList.add('opacity-50', 'cursor-not-allowed');
|
| 255 |
-
resultsSection.classList.add('hidden'); // Hide previous results during analysis
|
| 256 |
-
hideMessage(); // Hide any previous messages
|
| 257 |
-
|
| 258 |
-
try {
|
| 259 |
-
// Create FormData to send the audio file
|
| 260 |
-
const formData = new FormData();
|
| 261 |
-
formData.append('audio_file', uploadedFile);
|
| 262 |
-
|
| 263 |
-
// Simulate fetching from a backend endpoint
|
| 264 |
-
// In a real application, replace '/predict-truth' with your actual backend API endpoint
|
| 265 |
-
// And the response would come from your Python Gradio app or a custom Flask/FastAPI endpoint
|
| 266 |
-
const response = await new Promise(resolve => setTimeout(() => {
|
| 267 |
-
// Simulate a random prediction result from the backend
|
| 268 |
-
const simulatedPrediction = Math.random() > 0.5 ? 'True Story' : 'Deceptive Story';
|
| 269 |
-
resolve({
|
| 270 |
-
ok: true,
|
| 271 |
-
json: () => Promise.resolve({ prediction: simulatedPrediction })
|
| 272 |
-
});
|
| 273 |
-
}, 2000)); // Simulate 2-second network delay
|
| 274 |
-
|
| 275 |
-
if (response.ok) {
|
| 276 |
-
const data = await response.json();
|
| 277 |
-
const prediction = data.prediction;
|
| 278 |
-
|
| 279 |
-
if (prediction === 'True Story') {
|
| 280 |
-
predictionText.textContent = 'The story is likely TRUE.';
|
| 281 |
-
predictionResult.classList.remove('false');
|
| 282 |
-
predictionResult.style.borderColor = '#10b981'; // Green border
|
| 283 |
-
predictionResult.querySelector('svg').style.color = '#10b981'; // Green icon
|
| 284 |
-
predictionResult.style.backgroundColor = '#ecfdf5'; // Light green background
|
| 285 |
-
predictionResult.style.color = '#065f46'; // Dark green text
|
| 286 |
-
} else {
|
| 287 |
-
predictionText.textContent = 'The story is likely FALSE (deceptive).';
|
| 288 |
-
predictionResult.classList.add('false');
|
| 289 |
-
predictionResult.style.borderColor = '#ef4444'; // Red border
|
| 290 |
-
predictionResult.querySelector('svg').style.color = '#ef4444'; // Red icon
|
| 291 |
-
predictionResult.style.backgroundColor = '#fef2f2'; // Light red background
|
| 292 |
-
predictionResult.style.color = '#991b1b'; // Dark red text
|
| 293 |
-
}
|
| 294 |
-
resultsSection.classList.remove('hidden'); // Show results section
|
| 295 |
-
} else {
|
| 296 |
-
showMessage('Prediction failed. Please try again.', 'error');
|
| 297 |
-
console.error('Backend response not OK:', response.status, response.statusText);
|
| 298 |
-
}
|
| 299 |
-
} catch (error) {
|
| 300 |
-
showMessage('An error occurred during analysis. Please try again.', 'error');
|
| 301 |
-
console.error('Error during fetch:', error);
|
| 302 |
-
} finally {
|
| 303 |
-
predictButton.textContent = 'Analyze Truthfulness'; // Reset button text
|
| 304 |
-
predictButton.disabled = false;
|
| 305 |
-
predictButton.classList.remove('opacity-50', 'cursor-not-allowed');
|
| 306 |
-
}
|
| 307 |
-
} else {
|
| 308 |
-
showMessage('Please upload an audio file first.', 'error');
|
| 309 |
-
}
|
| 310 |
-
});
|
| 311 |
-
</script>
|
| 312 |
-
</body>
|
| 313 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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