Create df3-aesthetic-v2
Browse filesGemini said
I've added a handy "Clear All" button right below the drop zone, along with an indicator that dynamically changes the drop zone's appearance (turning it blue with a success badge) to clearly show when audio files have been successfully imported into your workstation!
- df3-aesthetic-v2 +873 -0
df3-aesthetic-v2
ADDED
|
@@ -0,0 +1,873 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en" class="dark">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>DeepFilterNet Pro | Offline Audio Studio</title>
|
| 7 |
+
|
| 8 |
+
<!-- PWA Setup (Generated Inline) -->
|
| 9 |
+
<script>
|
| 10 |
+
const manifest = {
|
| 11 |
+
name: "DeepFilterNet Pro",
|
| 12 |
+
short_name: "DFN Pro",
|
| 13 |
+
start_url: ".",
|
| 14 |
+
display: "standalone",
|
| 15 |
+
background_color: "#0f172a",
|
| 16 |
+
theme_color: "#3b82f6",
|
| 17 |
+
icons: [{
|
| 18 |
+
src: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233b82f6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z'/%3E%3Cpath d='M19 10v2a7 7 0 0 1-14 0v-2'/%3E%3Cline x1='12' x2='12' y1='19' y2='22'/%3E%3C/svg%3E",
|
| 19 |
+
sizes: "512x512",
|
| 20 |
+
type: "image/svg+xml"
|
| 21 |
+
}]
|
| 22 |
+
};
|
| 23 |
+
const manifestLink = document.createElement('link');
|
| 24 |
+
manifestLink.rel = 'manifest';
|
| 25 |
+
manifestLink.href = 'data:application/manifest+json;charset=utf-8,' + encodeURIComponent(JSON.stringify(manifest));
|
| 26 |
+
document.head.appendChild(manifestLink);
|
| 27 |
+
|
| 28 |
+
if ('serviceWorker' in navigator) {
|
| 29 |
+
const swCode = `
|
| 30 |
+
self.addEventListener('install', (e) => self.skipWaiting());
|
| 31 |
+
self.addEventListener('activate', (e) => self.clients.claim());
|
| 32 |
+
self.addEventListener('fetch', (e) => {});
|
| 33 |
+
`;
|
| 34 |
+
const blob = new Blob([swCode], { type: 'application/javascript' });
|
| 35 |
+
navigator.serviceWorker.register(URL.createObjectURL(blob)).catch(console.error);
|
| 36 |
+
}
|
| 37 |
+
</script>
|
| 38 |
+
|
| 39 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 40 |
+
<script src="https://unpkg.com/lucide@latest"></script>
|
| 41 |
+
|
| 42 |
+
<!-- External Libs for Batching and MP3 Encoding -->
|
| 43 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
|
| 44 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/lamejs/1.2.1/lame.min.js"></script>
|
| 45 |
+
|
| 46 |
+
<script>
|
| 47 |
+
tailwind.config = {
|
| 48 |
+
darkMode: 'class',
|
| 49 |
+
theme: {
|
| 50 |
+
extend: {
|
| 51 |
+
colors: { primary: { 50: '#eff6ff', 100: '#dbeafe', 500: '#3b82f6', 600: '#2563eb', 900: '#1e3a8a' } }
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
</script>
|
| 56 |
+
<style>
|
| 57 |
+
.drag-active { border-color: #3b82f6 !important; background-color: rgba(59, 130, 246, 0.1) !important; }
|
| 58 |
+
.hidden { display: none !important; }
|
| 59 |
+
.spinner { animation: spin 1s linear infinite; }
|
| 60 |
+
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
|
| 61 |
+
/* Custom Scrollbar for Queue */
|
| 62 |
+
::-webkit-scrollbar { width: 6px; }
|
| 63 |
+
::-webkit-scrollbar-track { background: transparent; }
|
| 64 |
+
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 4px; }
|
| 65 |
+
.dark ::-webkit-scrollbar-thumb { background: #334155; }
|
| 66 |
+
::-webkit-scrollbar-thumb:hover { background: #64748b; }
|
| 67 |
+
.dark ::-webkit-scrollbar-thumb:hover { background: #475569; }
|
| 68 |
+
</style>
|
| 69 |
+
</head>
|
| 70 |
+
<body class="bg-slate-50 dark:bg-slate-900 text-slate-800 dark:text-slate-200 min-h-screen font-sans selection:bg-primary-500 selection:text-white pb-12 overflow-x-hidden transition-colors duration-200">
|
| 71 |
+
|
| 72 |
+
<div class="max-w-7xl mx-auto px-4 pt-8">
|
| 73 |
+
|
| 74 |
+
<!-- Header -->
|
| 75 |
+
<header class="flex flex-col md:flex-row items-center justify-between mb-6 gap-4 pb-4">
|
| 76 |
+
<div class="flex items-center gap-4">
|
| 77 |
+
<div class="inline-flex items-center justify-center p-3 bg-white dark:bg-primary-900/50 rounded-2xl border border-slate-200 dark:border-primary-500/30 text-primary-600 dark:text-primary-500 shadow-[0_0_15px_rgba(59,130,246,0.2)]">
|
| 78 |
+
<i data-lucide="mic" class="w-6 h-6"></i>
|
| 79 |
+
<i data-lucide="sparkles" class="w-4 h-4 absolute transform translate-x-3 -translate-y-3 text-yellow-500 dark:text-yellow-400"></i>
|
| 80 |
+
</div>
|
| 81 |
+
<div>
|
| 82 |
+
<h1 class="text-3xl font-bold text-slate-900 dark:text-white tracking-tight">DeepFilterNet Pro</h1>
|
| 83 |
+
<p class="text-slate-500 dark:text-slate-400 text-sm flex items-center gap-1">
|
| 84 |
+
<i data-lucide="shield-check" class="w-3 h-3 text-emerald-500 dark:text-green-400"></i> Local & Offline processing
|
| 85 |
+
</p>
|
| 86 |
+
</div>
|
| 87 |
+
</div>
|
| 88 |
+
|
| 89 |
+
<!-- Global Output Settings & Theme -->
|
| 90 |
+
<div class="flex items-center gap-4 flex-wrap justify-center">
|
| 91 |
+
<label class="flex items-center gap-2 cursor-pointer group bg-white dark:bg-slate-800 px-3 py-1.5 rounded-lg border border-slate-200 dark:border-slate-700 shadow-sm transition-colors duration-200">
|
| 92 |
+
<input type="checkbox" id="normalizeCheck" checked class="w-4 h-4 rounded border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-700 text-primary-500 focus:ring-primary-500 cursor-pointer">
|
| 93 |
+
<span class="text-sm font-medium text-slate-600 dark:text-slate-300 group-hover:text-slate-900 dark:group-hover:text-white transition-colors">Auto-Normalize</span>
|
| 94 |
+
</label>
|
| 95 |
+
|
| 96 |
+
<div class="flex items-center bg-slate-100 dark:bg-slate-900 rounded-lg p-1 border border-slate-200 dark:border-slate-700 shadow-sm transition-colors duration-200">
|
| 97 |
+
<button id="formatWav" class="px-3 py-1.5 text-xs font-bold rounded-md bg-primary-600 text-white transition-all shadow-sm">WAV</button>
|
| 98 |
+
<button id="formatMp3" class="px-3 py-1.5 text-xs font-bold rounded-md text-slate-500 dark:text-slate-400 hover:text-slate-800 dark:hover:text-white transition-all">MP3</button>
|
| 99 |
+
</div>
|
| 100 |
+
|
| 101 |
+
<button id="themeToggle" class="p-2 rounded-xl bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 text-slate-500 dark:text-slate-400 hover:text-primary-500 transition-colors shadow-sm">
|
| 102 |
+
<i data-lucide="sun" class="w-5 h-5 hidden dark:block text-yellow-400"></i>
|
| 103 |
+
<i data-lucide="moon" class="w-5 h-5 block dark:hidden"></i>
|
| 104 |
+
</button>
|
| 105 |
+
</div>
|
| 106 |
+
</header>
|
| 107 |
+
|
| 108 |
+
<!-- Aesthetic Pro Controls Dashboard -->
|
| 109 |
+
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-8">
|
| 110 |
+
<!-- Noise Reduction -->
|
| 111 |
+
<div class="bg-white dark:bg-slate-800/80 p-5 rounded-xl border border-slate-200 dark:border-slate-700 shadow-sm hover:shadow-md transition-shadow duration-200 flex flex-col gap-3">
|
| 112 |
+
<div class="flex justify-between items-center">
|
| 113 |
+
<label class="text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider flex items-center gap-2">
|
| 114 |
+
<i data-lucide="cpu" class="w-4 h-4 text-primary-500"></i> Noise Reduction
|
| 115 |
+
</label>
|
| 116 |
+
<span id="noiseLevelValue" class="text-sm text-primary-600 dark:text-primary-400 font-bold bg-primary-50 dark:bg-primary-900/30 px-2 py-0.5 rounded">100%</span>
|
| 117 |
+
</div>
|
| 118 |
+
<input type="range" id="noiseLevel" min="0" max="100" value="100" class="w-full accent-primary-500 h-2 bg-slate-200 dark:bg-slate-700 rounded-lg cursor-pointer mt-1">
|
| 119 |
+
</div>
|
| 120 |
+
|
| 121 |
+
<!-- Bass -->
|
| 122 |
+
<div class="bg-white dark:bg-slate-800/80 p-5 rounded-xl border border-slate-200 dark:border-slate-700 shadow-sm hover:shadow-md transition-shadow duration-200 flex flex-col gap-3">
|
| 123 |
+
<div class="flex justify-between items-center">
|
| 124 |
+
<label class="text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider flex items-center gap-2">
|
| 125 |
+
<i data-lucide="speaker" class="w-4 h-4 text-emerald-500"></i> Bass EQ
|
| 126 |
+
</label>
|
| 127 |
+
<span id="bassVal" class="text-sm text-emerald-600 dark:text-emerald-400 font-bold bg-emerald-50 dark:bg-emerald-900/30 px-2 py-0.5 rounded">0dB</span>
|
| 128 |
+
</div>
|
| 129 |
+
<input type="range" id="eqBass" min="-12" max="12" value="0" step="0.5" class="w-full accent-emerald-500 h-2 bg-slate-200 dark:bg-slate-700 rounded-lg cursor-pointer mt-1">
|
| 130 |
+
</div>
|
| 131 |
+
|
| 132 |
+
<!-- Treble -->
|
| 133 |
+
<div class="bg-white dark:bg-slate-800/80 p-5 rounded-xl border border-slate-200 dark:border-slate-700 shadow-sm hover:shadow-md transition-shadow duration-200 flex flex-col gap-3">
|
| 134 |
+
<div class="flex justify-between items-center">
|
| 135 |
+
<label class="text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider flex items-center gap-2">
|
| 136 |
+
<i data-lucide="audio-waveform" class="w-4 h-4 text-amber-500"></i> Treble EQ
|
| 137 |
+
</label>
|
| 138 |
+
<span id="trebleVal" class="text-sm text-amber-600 dark:text-amber-400 font-bold bg-amber-50 dark:bg-amber-900/30 px-2 py-0.5 rounded">0dB</span>
|
| 139 |
+
</div>
|
| 140 |
+
<input type="range" id="eqTreble" min="-12" max="12" value="0" step="0.5" class="w-full accent-amber-500 h-2 bg-slate-200 dark:bg-slate-700 rounded-lg cursor-pointer mt-1">
|
| 141 |
+
</div>
|
| 142 |
+
|
| 143 |
+
<!-- Gain -->
|
| 144 |
+
<div class="bg-white dark:bg-slate-800/80 p-5 rounded-xl border border-slate-200 dark:border-slate-700 shadow-sm hover:shadow-md transition-shadow duration-200 flex flex-col gap-3">
|
| 145 |
+
<div class="flex justify-between items-center">
|
| 146 |
+
<label class="text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider flex items-center gap-2">
|
| 147 |
+
<i data-lucide="volume-2" class="w-4 h-4 text-rose-500"></i> Output Gain
|
| 148 |
+
</label>
|
| 149 |
+
<span id="gainVal" class="text-sm text-rose-600 dark:text-rose-400 font-bold bg-rose-50 dark:bg-rose-900/30 px-2 py-0.5 rounded">0dB</span>
|
| 150 |
+
</div>
|
| 151 |
+
<input type="range" id="eqGain" min="-12" max="12" value="0" step="0.5" class="w-full accent-rose-500 h-2 bg-slate-200 dark:bg-slate-700 rounded-lg cursor-pointer mt-1">
|
| 152 |
+
</div>
|
| 153 |
+
</div>
|
| 154 |
+
|
| 155 |
+
<main class="grid lg:grid-cols-[300px_1fr] gap-6">
|
| 156 |
+
<!-- Sidebar: Upload & Queue -->
|
| 157 |
+
<aside class="flex flex-col gap-4">
|
| 158 |
+
<div class="flex flex-col gap-2">
|
| 159 |
+
<div id="dropzone" class="bg-white dark:bg-transparent border-2 border-dashed border-slate-300 dark:border-slate-600 rounded-2xl p-6 text-center cursor-pointer transition-all duration-200 hover:border-primary-500 dark:hover:border-primary-500 dark:hover:bg-slate-800/80 group">
|
| 160 |
+
<input type="file" id="fileInput" accept="audio/*" multiple class="hidden">
|
| 161 |
+
<i data-lucide="file-audio" id="dropzoneIcon" class="w-8 h-8 mx-auto text-slate-400 group-hover:text-primary-500 transition-colors mb-2"></i>
|
| 162 |
+
<h3 class="font-semibold text-slate-700 dark:text-white text-sm">Add Audio Files</h3>
|
| 163 |
+
<p class="text-slate-500 text-xs mt-1">Drag & Drop or Click</p>
|
| 164 |
+
</div>
|
| 165 |
+
|
| 166 |
+
<!-- Indicator & Clear Action -->
|
| 167 |
+
<div id="dropzoneActions" class="hidden flex justify-between items-center px-2 transition-all duration-200">
|
| 168 |
+
<span class="text-xs text-emerald-600 dark:text-emerald-400 font-medium flex items-center gap-1">
|
| 169 |
+
<i data-lucide="check-circle-2" class="w-3 h-3"></i> <span id="dropzoneIndicatorText">Audio added</span>
|
| 170 |
+
</span>
|
| 171 |
+
<button id="clearAllBtn" class="text-xs text-red-500 hover:text-red-600 dark:hover:text-red-400 font-medium flex items-center gap-1 transition-colors cursor-pointer z-10">
|
| 172 |
+
<i data-lucide="trash-2" class="w-3 h-3"></i> Clear All
|
| 173 |
+
</button>
|
| 174 |
+
</div>
|
| 175 |
+
</div>
|
| 176 |
+
|
| 177 |
+
<div class="bg-white dark:bg-slate-800 rounded-2xl border border-slate-200 dark:border-slate-700 flex-1 flex flex-col overflow-hidden max-h-[600px] shadow-sm">
|
| 178 |
+
<div class="p-4 border-b border-slate-200 dark:border-slate-700 flex justify-between items-center bg-slate-50 dark:bg-slate-800/90">
|
| 179 |
+
<h3 class="font-semibold text-slate-800 dark:text-white flex items-center gap-2">
|
| 180 |
+
<i data-lucide="list-video" class="w-4 h-4 text-slate-500"></i> Batch Queue
|
| 181 |
+
</h3>
|
| 182 |
+
<span id="queueCount" class="bg-slate-200 dark:bg-slate-700 text-xs px-2 py-0.5 rounded-full text-slate-600 dark:text-slate-300 font-medium">0 files</span>
|
| 183 |
+
</div>
|
| 184 |
+
<div id="fileList" class="overflow-y-auto flex-1 p-2 space-y-1">
|
| 185 |
+
<!-- Queue items render here -->
|
| 186 |
+
<div class="p-4 text-center text-slate-400 dark:text-slate-500 text-sm italic empty-state">Queue is empty.</div>
|
| 187 |
+
</div>
|
| 188 |
+
|
| 189 |
+
<div class="p-4 border-t border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-800/90 space-y-3">
|
| 190 |
+
<button id="processBtn" disabled class="w-full flex items-center justify-center gap-2 bg-primary-600 disabled:bg-slate-200 dark:disabled:bg-slate-700 disabled:text-slate-400 dark:disabled:text-slate-500 hover:bg-primary-500 text-white px-4 py-2.5 rounded-xl font-medium transition-all shadow-sm disabled:shadow-none">
|
| 191 |
+
<i data-lucide="cpu" class="w-4 h-4"></i> Start Processing
|
| 192 |
+
</button>
|
| 193 |
+
<button id="downloadZipBtn" class="hidden w-full flex items-center justify-center gap-2 bg-emerald-600 hover:bg-emerald-500 text-white px-4 py-2.5 rounded-xl font-medium transition-all shadow-[0_0_15px_rgba(16,185,129,0.2)]">
|
| 194 |
+
<i data-lucide="archive" class="w-4 h-4"></i> Download ZIP
|
| 195 |
+
</button>
|
| 196 |
+
</div>
|
| 197 |
+
</div>
|
| 198 |
+
|
| 199 |
+
<p class="text-[10px] text-center text-slate-400 dark:text-slate-500 font-mono mt-[-5px]">
|
| 200 |
+
Shortcuts: [Space] Play, [←/→] Seek, [Del] Remove
|
| 201 |
+
</p>
|
| 202 |
+
</aside>
|
| 203 |
+
|
| 204 |
+
<!-- Main Workspace -->
|
| 205 |
+
<section class="bg-white dark:bg-slate-800 rounded-2xl border border-slate-200 dark:border-slate-700 flex flex-col overflow-hidden min-h-[400px] shadow-sm">
|
| 206 |
+
|
| 207 |
+
<div id="workspaceEmpty" class="flex-1 flex flex-col items-center justify-center text-slate-400 dark:text-slate-500 p-10">
|
| 208 |
+
<i data-lucide="activity" class="w-16 h-16 text-slate-300 dark:text-slate-700 mb-4"></i>
|
| 209 |
+
<p class="text-lg text-slate-500 dark:text-slate-400">Select a file from the queue to edit</p>
|
| 210 |
+
</div>
|
| 211 |
+
|
| 212 |
+
<div id="workspaceActive" class="hidden flex-1 flex flex-col">
|
| 213 |
+
<!-- File Header -->
|
| 214 |
+
<div class="p-5 border-b border-slate-200 dark:border-slate-700 flex justify-between items-center bg-slate-50 dark:bg-slate-900/40">
|
| 215 |
+
<h2 id="activeFileName" class="text-xl font-bold text-slate-800 dark:text-white truncate max-w-[60%]">filename.wav</h2>
|
| 216 |
+
|
| 217 |
+
<!-- A/B Toggle -->
|
| 218 |
+
<div id="abToggleContainer" class="hidden bg-slate-200 dark:bg-slate-900 p-1 rounded-lg border border-slate-300 dark:border-slate-700 flex items-center shadow-inner">
|
| 219 |
+
<button id="btnOriginal" class="px-4 py-1.5 text-xs font-bold rounded-md bg-white dark:bg-slate-700 text-slate-800 dark:text-white transition-all shadow-sm">Original</button>
|
| 220 |
+
<button id="btnCleaned" class="px-4 py-1.5 text-xs font-bold rounded-md text-slate-500 dark:text-slate-400 hover:text-slate-800 dark:hover:text-white transition-all">Cleaned</button>
|
| 221 |
+
</div>
|
| 222 |
+
</div>
|
| 223 |
+
|
| 224 |
+
<!-- Waveform Area with Zoom -->
|
| 225 |
+
<div class="flex-1 flex flex-col justify-center p-6 bg-slate-50 dark:bg-slate-900/20 relative">
|
| 226 |
+
<!-- Zoom Slider -->
|
| 227 |
+
<div class="absolute top-4 right-6 flex items-center gap-2 bg-white/90 dark:bg-slate-900/80 px-2 py-1.5 rounded-lg border border-slate-200 dark:border-slate-700 z-10 shadow-sm backdrop-blur">
|
| 228 |
+
<i data-lucide="zoom-out" class="w-3 h-3 text-slate-400 dark:text-slate-500"></i>
|
| 229 |
+
<input type="range" id="zoomSlider" min="0" max="200" value="0" title="Adjust Zoom (0 = Fit)" class="w-24 accent-primary-500 h-1 bg-slate-200 dark:bg-slate-700 rounded-lg cursor-pointer">
|
| 230 |
+
<i data-lucide="zoom-in" class="w-3 h-3 text-slate-400 dark:text-slate-500"></i>
|
| 231 |
+
</div>
|
| 232 |
+
|
| 233 |
+
<div id="waveform" class="w-full"></div>
|
| 234 |
+
<div id="timeDisplay" class="absolute bottom-4 right-6 text-xs font-mono text-slate-500 dark:text-slate-400 bg-white/90 dark:bg-slate-900/80 px-2 py-1 rounded shadow-sm border border-slate-200 dark:border-slate-700">00:00 / 00:00</div>
|
| 235 |
+
</div>
|
| 236 |
+
|
| 237 |
+
<!-- Trimming & Controls -->
|
| 238 |
+
<div class="p-5 border-t border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800/80">
|
| 239 |
+
<div class="flex flex-col md:flex-row gap-6 items-center justify-between">
|
| 240 |
+
|
| 241 |
+
<!-- Playback -->
|
| 242 |
+
<div class="flex items-center gap-3">
|
| 243 |
+
<button id="playBtn" class="w-14 h-14 flex items-center justify-center bg-primary-600 hover:bg-primary-500 text-white rounded-full transition-all shadow-lg hover:scale-105">
|
| 244 |
+
<span id="iconPlayWrap" class="flex items-center justify-center ml-1"><i data-lucide="play" class="w-6 h-6 fill-current"></i></span>
|
| 245 |
+
<span id="iconPauseWrap" class="hidden items-center justify-center"><i data-lucide="pause" class="w-6 h-6 fill-current"></i></span>
|
| 246 |
+
</button>
|
| 247 |
+
</div>
|
| 248 |
+
|
| 249 |
+
<!-- Trimming -->
|
| 250 |
+
<div class="flex items-center gap-2 flex-1 max-w-xl">
|
| 251 |
+
<i data-lucide="scissors" class="w-4 h-4 text-slate-400 dark:text-slate-500"></i>
|
| 252 |
+
<div class="flex items-center gap-2 bg-slate-50 dark:bg-slate-900 p-2 rounded-lg border border-slate-200 dark:border-slate-700 flex-1">
|
| 253 |
+
<div class="flex-1 flex flex-col">
|
| 254 |
+
<label class="text-[10px] font-semibold text-slate-500 uppercase ml-1">Start (sec)</label>
|
| 255 |
+
<div class="flex gap-1 mt-0.5">
|
| 256 |
+
<input type="number" id="trimStart" step="0.1" min="0" value="0.0" class="w-full bg-white dark:bg-slate-800 text-slate-900 dark:text-white text-sm px-2 py-1 rounded border border-slate-200 dark:border-slate-600 focus:border-primary-500 outline-none font-mono">
|
| 257 |
+
<button id="setStartBtn" title="Set to current playhead" class="px-2 bg-slate-200 dark:bg-slate-700 hover:bg-slate-300 dark:hover:bg-slate-600 rounded text-slate-600 dark:text-slate-300 transition-colors"><i data-lucide="map-pin" class="w-3 h-3"></i></button>
|
| 258 |
+
</div>
|
| 259 |
+
</div>
|
| 260 |
+
<div class="w-4 border-t border-slate-300 dark:border-slate-600"></div>
|
| 261 |
+
<div class="flex-1 flex flex-col">
|
| 262 |
+
<label class="text-[10px] font-semibold text-slate-500 uppercase ml-1">End (sec)</label>
|
| 263 |
+
<div class="flex gap-1 mt-0.5">
|
| 264 |
+
<input type="number" id="trimEnd" step="0.1" min="0" value="0.0" class="w-full bg-white dark:bg-slate-800 text-slate-900 dark:text-white text-sm px-2 py-1 rounded border border-slate-200 dark:border-slate-600 focus:border-primary-500 outline-none font-mono">
|
| 265 |
+
<button id="setEndBtn" title="Set to current playhead" class="px-2 bg-slate-200 dark:bg-slate-700 hover:bg-slate-300 dark:hover:bg-slate-600 rounded text-slate-600 dark:text-slate-300 transition-colors"><i data-lucide="map-pin" class="w-3 h-3"></i></button>
|
| 266 |
+
</div>
|
| 267 |
+
</div>
|
| 268 |
+
</div>
|
| 269 |
+
</div>
|
| 270 |
+
|
| 271 |
+
<!-- Download Single -->
|
| 272 |
+
<div>
|
| 273 |
+
<button id="downloadSingleBtn" class="hidden flex items-center gap-2 bg-slate-200 dark:bg-slate-700 hover:bg-slate-300 dark:hover:bg-slate-600 text-slate-800 dark:text-white px-4 py-3 rounded-lg text-sm font-medium transition-all border border-slate-300 dark:border-transparent">
|
| 274 |
+
<i data-lucide="download" class="w-4 h-4"></i> Save
|
| 275 |
+
</button>
|
| 276 |
+
</div>
|
| 277 |
+
|
| 278 |
+
</div>
|
| 279 |
+
</div>
|
| 280 |
+
</div>
|
| 281 |
+
|
| 282 |
+
<!-- Global Overlay for App Status -->
|
| 283 |
+
<div id="globalStatus" class="hidden absolute inset-0 bg-white/90 dark:bg-slate-900/80 backdrop-blur-sm z-50 flex flex-col items-center justify-center rounded-2xl">
|
| 284 |
+
<i data-lucide="loader-2" class="w-12 h-12 text-primary-500 spinner mb-4"></i>
|
| 285 |
+
<h3 id="globalStatusTitle" class="text-xl font-bold text-slate-900 dark:text-white mb-2">Initializing AI Engine...</h3>
|
| 286 |
+
<p id="globalStatusDesc" class="text-slate-500 dark:text-slate-400 text-sm max-w-sm text-center">Loading DeepFilterNet WebAssembly core.</p>
|
| 287 |
+
|
| 288 |
+
<div class="w-64 bg-slate-200 dark:bg-slate-800 rounded-full h-2 mt-6 overflow-hidden border border-slate-300 dark:border-slate-700">
|
| 289 |
+
<div id="globalProgressBar" class="bg-primary-500 h-2 rounded-full transition-all duration-300" style="width: 0%"></div>
|
| 290 |
+
</div>
|
| 291 |
+
</div>
|
| 292 |
+
|
| 293 |
+
</section>
|
| 294 |
+
</main>
|
| 295 |
+
</div>
|
| 296 |
+
|
| 297 |
+
<script type="module">
|
| 298 |
+
import WaveSurfer from 'https://unpkg.com/wavesurfer.js@7/dist/wavesurfer.esm.js';
|
| 299 |
+
|
| 300 |
+
// --- HUGGING FACE DIRECT FETCH INTERCEPTOR ---
|
| 301 |
+
if (typeof window.SharedArrayBuffer === 'undefined') { window.SharedArrayBuffer = window.ArrayBuffer; }
|
| 302 |
+
const originalFetch = window.fetch;
|
| 303 |
+
window.fetch = async function(...args) {
|
| 304 |
+
let request = args[0];
|
| 305 |
+
let reqUrl = typeof request === 'string' ? request : (request && request.url);
|
| 306 |
+
if (reqUrl && typeof reqUrl === 'string') {
|
| 307 |
+
let newUrl = null;
|
| 308 |
+
if (reqUrl.includes('df_bg.wasm')) newUrl = 'https://huggingface.co/trysem/DeepFilterNet3/resolve/main/df_bg.wasm';
|
| 309 |
+
else if (reqUrl.includes('DeepFilterNet3_onnx.tar.gz')) newUrl = 'https://huggingface.co/trysem/DeepFilterNet3/resolve/main/DeepFilterNet3_onnx.tar.gz';
|
| 310 |
+
if (newUrl) args[0] = request instanceof Request ? new Request(newUrl, request) : newUrl;
|
| 311 |
+
}
|
| 312 |
+
return originalFetch.apply(this, args);
|
| 313 |
+
};
|
| 314 |
+
|
| 315 |
+
// --- STATE MANAGEMENT ---
|
| 316 |
+
const state = {
|
| 317 |
+
files: [],
|
| 318 |
+
activeId: null,
|
| 319 |
+
settings: { format: 'wav', normalize: true, noiseLevel: 100, bass: 0, treble: 0, gain: 0 },
|
| 320 |
+
dfNetProc: null,
|
| 321 |
+
wavesurfer: null,
|
| 322 |
+
playbackMode: 'original'
|
| 323 |
+
};
|
| 324 |
+
|
| 325 |
+
// --- UI BINDINGS ---
|
| 326 |
+
lucide.createIcons();
|
| 327 |
+
const UI = {
|
| 328 |
+
dropzone: document.getElementById('dropzone'), fileInput: document.getElementById('fileInput'),
|
| 329 |
+
dropzoneActions: document.getElementById('dropzoneActions'), dropzoneIndicatorText: document.getElementById('dropzoneIndicatorText'),
|
| 330 |
+
clearAllBtn: document.getElementById('clearAllBtn'), dropzoneIcon: document.getElementById('dropzoneIcon'),
|
| 331 |
+
fileList: document.getElementById('fileList'), queueCount: document.getElementById('queueCount'),
|
| 332 |
+
processBtn: document.getElementById('processBtn'), downloadZipBtn: document.getElementById('downloadZipBtn'),
|
| 333 |
+
workspaceEmpty: document.getElementById('workspaceEmpty'), workspaceActive: document.getElementById('workspaceActive'),
|
| 334 |
+
activeFileName: document.getElementById('activeFileName'), playBtn: document.getElementById('playBtn'),
|
| 335 |
+
iconPlayWrap: document.getElementById('iconPlayWrap'), iconPauseWrap: document.getElementById('iconPauseWrap'),
|
| 336 |
+
timeDisplay: document.getElementById('timeDisplay'), trimStart: document.getElementById('trimStart'),
|
| 337 |
+
trimEnd: document.getElementById('trimEnd'), abToggle: document.getElementById('abToggleContainer'),
|
| 338 |
+
btnOriginal: document.getElementById('btnOriginal'), btnCleaned: document.getElementById('btnCleaned'),
|
| 339 |
+
downloadSingleBtn: document.getElementById('downloadSingleBtn'), globalStatus: document.getElementById('globalStatus'),
|
| 340 |
+
statusTitle: document.getElementById('globalStatusTitle'), statusDesc: document.getElementById('globalStatusDesc'),
|
| 341 |
+
progressBar: document.getElementById('globalProgressBar'), themeToggle: document.getElementById('themeToggle'),
|
| 342 |
+
zoomSlider: document.getElementById('zoomSlider')
|
| 343 |
+
};
|
| 344 |
+
|
| 345 |
+
// --- THEME & SETTINGS LOGIC ---
|
| 346 |
+
UI.themeToggle.onclick = () => { document.documentElement.classList.toggle('dark'); };
|
| 347 |
+
|
| 348 |
+
document.getElementById('noiseLevel').addEventListener('input', (e) => {
|
| 349 |
+
state.settings.noiseLevel = parseInt(e.target.value, 10);
|
| 350 |
+
document.getElementById('noiseLevelValue').textContent = e.target.value + '%';
|
| 351 |
+
});
|
| 352 |
+
document.getElementById('normalizeCheck').addEventListener('change', (e) => state.settings.normalize = e.target.checked);
|
| 353 |
+
|
| 354 |
+
// EQ Settings
|
| 355 |
+
const updateEqLabel = (id, val) => { const v = parseFloat(val); document.getElementById(id).textContent = (v > 0 ? '+' : '') + v + 'dB'; };
|
| 356 |
+
document.getElementById('eqBass').addEventListener('input', (e) => { state.settings.bass = parseFloat(e.target.value); updateEqLabel('bassVal', e.target.value); });
|
| 357 |
+
document.getElementById('eqTreble').addEventListener('input', (e) => { state.settings.treble = parseFloat(e.target.value); updateEqLabel('trebleVal', e.target.value); });
|
| 358 |
+
document.getElementById('eqGain').addEventListener('input', (e) => { state.settings.gain = parseFloat(e.target.value); updateEqLabel('gainVal', e.target.value); });
|
| 359 |
+
|
| 360 |
+
// Format Toggle
|
| 361 |
+
const formatWav = document.getElementById('formatWav');
|
| 362 |
+
const formatMp3 = document.getElementById('formatMp3');
|
| 363 |
+
formatWav.onclick = () => { state.settings.format = 'wav'; formatWav.className = 'px-3 py-1.5 text-xs font-bold rounded-md bg-primary-600 text-white transition-all shadow-sm'; formatMp3.className = 'px-3 py-1.5 text-xs font-bold rounded-md text-slate-500 dark:text-slate-400 hover:text-slate-800 dark:hover:text-white transition-all'; };
|
| 364 |
+
formatMp3.onclick = () => { state.settings.format = 'mp3'; formatMp3.className = 'px-3 py-1.5 text-xs font-bold rounded-md bg-primary-600 text-white transition-all shadow-sm'; formatWav.className = 'px-3 py-1.5 text-xs font-bold rounded-md text-slate-500 dark:text-slate-400 hover:text-slate-800 dark:hover:text-white transition-all'; };
|
| 365 |
+
|
| 366 |
+
// --- DRAG & DROP LOGIC ---
|
| 367 |
+
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(e => UI.dropzone.addEventListener(e, ev => { ev.preventDefault(); ev.stopPropagation(); }, false));
|
| 368 |
+
['dragenter', 'dragover'].forEach(e => UI.dropzone.addEventListener(e, () => UI.dropzone.classList.add('drag-active'), false));
|
| 369 |
+
['dragleave', 'drop'].forEach(e => UI.dropzone.addEventListener(e, () => UI.dropzone.classList.remove('drag-active'), false));
|
| 370 |
+
|
| 371 |
+
UI.dropzone.addEventListener('drop', (e) => handleFiles(e.dataTransfer.files));
|
| 372 |
+
UI.dropzone.addEventListener('click', () => UI.fileInput.click());
|
| 373 |
+
UI.fileInput.addEventListener('change', (e) => handleFiles(e.target.files));
|
| 374 |
+
|
| 375 |
+
UI.clearAllBtn.onclick = () => {
|
| 376 |
+
state.files = [];
|
| 377 |
+
state.activeId = null;
|
| 378 |
+
UI.workspaceActive.classList.add('hidden');
|
| 379 |
+
UI.workspaceEmpty.classList.remove('hidden');
|
| 380 |
+
if (state.wavesurfer) {
|
| 381 |
+
state.wavesurfer.destroy();
|
| 382 |
+
state.wavesurfer = null;
|
| 383 |
+
}
|
| 384 |
+
UI.fileInput.value = '';
|
| 385 |
+
renderQueue();
|
| 386 |
+
};
|
| 387 |
+
|
| 388 |
+
// --- KEYBOARD SHORTCUTS ---
|
| 389 |
+
document.addEventListener('keydown', (e) => {
|
| 390 |
+
if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return;
|
| 391 |
+
if (!state.activeId) return;
|
| 392 |
+
|
| 393 |
+
switch(e.code) {
|
| 394 |
+
case 'Space':
|
| 395 |
+
e.preventDefault();
|
| 396 |
+
if (state.wavesurfer) state.wavesurfer.playPause();
|
| 397 |
+
break;
|
| 398 |
+
case 'ArrowLeft':
|
| 399 |
+
e.preventDefault();
|
| 400 |
+
if (state.wavesurfer) state.wavesurfer.skip(-5);
|
| 401 |
+
break;
|
| 402 |
+
case 'ArrowRight':
|
| 403 |
+
e.preventDefault();
|
| 404 |
+
if (state.wavesurfer) state.wavesurfer.skip(5);
|
| 405 |
+
break;
|
| 406 |
+
case 'Delete':
|
| 407 |
+
case 'Backspace':
|
| 408 |
+
e.preventDefault();
|
| 409 |
+
removeFile(state.activeId);
|
| 410 |
+
break;
|
| 411 |
+
}
|
| 412 |
+
});
|
| 413 |
+
|
| 414 |
+
// --- FILE HANDLING & QUEUE ---
|
| 415 |
+
function handleFiles(files) {
|
| 416 |
+
let added = false;
|
| 417 |
+
for (let f of files) {
|
| 418 |
+
if (!f.type.startsWith('audio/')) continue;
|
| 419 |
+
const id = 'f_' + Date.now() + Math.random().toString(36).substr(2, 5);
|
| 420 |
+
state.files.push({
|
| 421 |
+
id, file: f, name: f.name, originalUrl: URL.createObjectURL(f),
|
| 422 |
+
cleanedUrl: null, status: 'pending', duration: 0, startTrim: 0, endTrim: 0
|
| 423 |
+
});
|
| 424 |
+
added = true;
|
| 425 |
+
}
|
| 426 |
+
if (added) {
|
| 427 |
+
renderQueue();
|
| 428 |
+
UI.processBtn.disabled = false;
|
| 429 |
+
if (!state.activeId && state.files.length > 0) selectFile(state.files[0].id);
|
| 430 |
+
}
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
+
function renderQueue() {
|
| 434 |
+
UI.fileList.innerHTML = '';
|
| 435 |
+
UI.queueCount.textContent = `${state.files.length} file${state.files.length !== 1 ? 's' : ''}`;
|
| 436 |
+
|
| 437 |
+
// Toggle Dropzone Actions and Visual Indicator
|
| 438 |
+
if (state.files.length > 0) {
|
| 439 |
+
UI.dropzoneActions.classList.remove('hidden');
|
| 440 |
+
UI.dropzoneIndicatorText.textContent = `${state.files.length} file(s) ready`;
|
| 441 |
+
UI.dropzone.classList.remove('border-slate-300', 'dark:border-slate-600');
|
| 442 |
+
UI.dropzone.classList.add('border-primary-400', 'dark:border-primary-500', 'bg-primary-50/50', 'dark:bg-primary-900/20');
|
| 443 |
+
UI.dropzoneIcon.classList.remove('text-slate-400');
|
| 444 |
+
UI.dropzoneIcon.classList.add('text-primary-500');
|
| 445 |
+
} else {
|
| 446 |
+
UI.dropzoneActions.classList.add('hidden');
|
| 447 |
+
UI.dropzone.classList.add('border-slate-300', 'dark:border-slate-600');
|
| 448 |
+
UI.dropzone.classList.remove('border-primary-400', 'dark:border-primary-500', 'bg-primary-50/50', 'dark:bg-primary-900/20');
|
| 449 |
+
UI.dropzoneIcon.classList.add('text-slate-400');
|
| 450 |
+
UI.dropzoneIcon.classList.remove('text-primary-500');
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
if (state.files.length === 0) {
|
| 454 |
+
UI.fileList.innerHTML = '<div class="p-4 text-center text-slate-400 dark:text-slate-500 text-sm italic empty-state">Queue is empty.</div>';
|
| 455 |
+
UI.processBtn.disabled = true;
|
| 456 |
+
return;
|
| 457 |
+
}
|
| 458 |
+
|
| 459 |
+
state.files.forEach(item => {
|
| 460 |
+
const el = document.createElement('div');
|
| 461 |
+
const isActive = item.id === state.activeId;
|
| 462 |
+
|
| 463 |
+
let icon = '<i data-lucide="clock" class="w-4 h-4 text-slate-400"></i>';
|
| 464 |
+
if(item.status === 'processing') icon = '<i data-lucide="loader-2" class="w-4 h-4 text-primary-500 spinner"></i>';
|
| 465 |
+
if(item.status === 'done') icon = '<i data-lucide="check-circle-2" class="w-4 h-4 text-emerald-500 dark:text-emerald-400"></i>';
|
| 466 |
+
|
| 467 |
+
el.className = `p-3 rounded-lg flex items-center justify-between cursor-pointer border transition-all ${isActive ? 'bg-primary-50 dark:bg-primary-900/20 border-primary-500/50' : 'bg-white dark:bg-slate-900 border-slate-200 dark:border-slate-700 hover:border-slate-300 dark:hover:border-slate-500'}`;
|
| 468 |
+
el.innerHTML = `
|
| 469 |
+
<div class="flex items-center gap-3 overflow-hidden">
|
| 470 |
+
${icon}
|
| 471 |
+
<span class="text-sm truncate text-slate-700 dark:text-slate-200 ${isActive ? 'font-semibold' : ''}">${item.name}</span>
|
| 472 |
+
</div>
|
| 473 |
+
<button class="p-1 text-slate-400 hover:text-red-500 dark:hover:text-red-400 remove-btn transition-colors" data-id="${item.id}">
|
| 474 |
+
<i data-lucide="x" class="w-4 h-4"></i>
|
| 475 |
+
</button>
|
| 476 |
+
`;
|
| 477 |
+
el.onclick = (e) => { if(!e.target.closest('.remove-btn')) selectFile(item.id); };
|
| 478 |
+
el.querySelector('.remove-btn').onclick = () => removeFile(item.id);
|
| 479 |
+
UI.fileList.appendChild(el);
|
| 480 |
+
});
|
| 481 |
+
lucide.createIcons();
|
| 482 |
+
|
| 483 |
+
const doneCount = state.files.filter(f => f.status === 'done').length;
|
| 484 |
+
UI.downloadZipBtn.classList.toggle('hidden', doneCount < 1);
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
function removeFile(id) {
|
| 488 |
+
state.files = state.files.filter(f => f.id !== id);
|
| 489 |
+
if (state.activeId === id) {
|
| 490 |
+
state.activeId = null;
|
| 491 |
+
UI.workspaceActive.classList.add('hidden');
|
| 492 |
+
UI.workspaceEmpty.classList.remove('hidden');
|
| 493 |
+
if (state.wavesurfer) state.wavesurfer.destroy();
|
| 494 |
+
state.wavesurfer = null;
|
| 495 |
+
}
|
| 496 |
+
renderQueue();
|
| 497 |
+
}
|
| 498 |
+
|
| 499 |
+
// --- WORKSPACE & WAVESURFER ---
|
| 500 |
+
async function selectFile(id) {
|
| 501 |
+
state.activeId = id;
|
| 502 |
+
renderQueue();
|
| 503 |
+
const item = state.files.find(f => f.id === id);
|
| 504 |
+
|
| 505 |
+
UI.workspaceEmpty.classList.add('hidden');
|
| 506 |
+
UI.workspaceActive.classList.remove('hidden');
|
| 507 |
+
UI.activeFileName.textContent = item.name;
|
| 508 |
+
|
| 509 |
+
if (item.status === 'done') {
|
| 510 |
+
UI.abToggle.classList.remove('hidden');
|
| 511 |
+
UI.downloadSingleBtn.classList.remove('hidden');
|
| 512 |
+
setPlaybackMode('cleaned', item);
|
| 513 |
+
} else {
|
| 514 |
+
UI.abToggle.classList.add('hidden');
|
| 515 |
+
UI.downloadSingleBtn.classList.add('hidden');
|
| 516 |
+
setPlaybackMode('original', item);
|
| 517 |
+
}
|
| 518 |
+
|
| 519 |
+
initWavesurfer(item);
|
| 520 |
+
}
|
| 521 |
+
|
| 522 |
+
function initWavesurfer(item) {
|
| 523 |
+
if (state.wavesurfer) state.wavesurfer.destroy();
|
| 524 |
+
|
| 525 |
+
state.wavesurfer = WaveSurfer.create({
|
| 526 |
+
container: '#waveform',
|
| 527 |
+
waveColor: '#94a3b8',
|
| 528 |
+
progressColor: '#3b82f6',
|
| 529 |
+
cursorColor: '#60a5fa',
|
| 530 |
+
barWidth: 2,
|
| 531 |
+
barGap: 1,
|
| 532 |
+
barRadius: 2,
|
| 533 |
+
height: 120,
|
| 534 |
+
normalize: true,
|
| 535 |
+
});
|
| 536 |
+
|
| 537 |
+
const loadUrl = state.playbackMode === 'cleaned' ? item.cleanedUrl : item.originalUrl;
|
| 538 |
+
state.wavesurfer.load(loadUrl);
|
| 539 |
+
|
| 540 |
+
// By passing 0 to zoom initially, it defaults to fitting within the container boundary
|
| 541 |
+
UI.zoomSlider.value = 0;
|
| 542 |
+
|
| 543 |
+
state.wavesurfer.on('ready', () => {
|
| 544 |
+
const duration = state.wavesurfer.getDuration();
|
| 545 |
+
if (item.duration === 0) {
|
| 546 |
+
item.duration = duration;
|
| 547 |
+
item.endTrim = duration;
|
| 548 |
+
}
|
| 549 |
+
|
| 550 |
+
UI.trimStart.max = duration;
|
| 551 |
+
UI.trimEnd.max = duration;
|
| 552 |
+
UI.trimStart.value = item.startTrim.toFixed(1);
|
| 553 |
+
UI.trimEnd.value = item.endTrim.toFixed(1);
|
| 554 |
+
|
| 555 |
+
updateTimeDisplay();
|
| 556 |
+
|
| 557 |
+
// Reset Play Icon State
|
| 558 |
+
UI.iconPlayWrap.classList.remove('hidden');
|
| 559 |
+
UI.iconPlayWrap.classList.add('flex');
|
| 560 |
+
UI.iconPauseWrap.classList.add('hidden');
|
| 561 |
+
UI.iconPauseWrap.classList.remove('flex');
|
| 562 |
+
});
|
| 563 |
+
|
| 564 |
+
state.wavesurfer.on('audioprocess', updateTimeDisplay);
|
| 565 |
+
state.wavesurfer.on('seek', updateTimeDisplay);
|
| 566 |
+
|
| 567 |
+
// Morph Play Button accurately without erasing Lucide SVG mappings
|
| 568 |
+
state.wavesurfer.on('play', () => {
|
| 569 |
+
UI.iconPlayWrap.classList.add('hidden');
|
| 570 |
+
UI.iconPlayWrap.classList.remove('flex');
|
| 571 |
+
UI.iconPauseWrap.classList.remove('hidden');
|
| 572 |
+
UI.iconPauseWrap.classList.add('flex');
|
| 573 |
+
});
|
| 574 |
+
state.wavesurfer.on('pause', () => {
|
| 575 |
+
UI.iconPauseWrap.classList.add('hidden');
|
| 576 |
+
UI.iconPauseWrap.classList.remove('flex');
|
| 577 |
+
UI.iconPlayWrap.classList.remove('hidden');
|
| 578 |
+
UI.iconPlayWrap.classList.add('flex');
|
| 579 |
+
});
|
| 580 |
+
}
|
| 581 |
+
|
| 582 |
+
UI.zoomSlider.addEventListener('input', (e) => {
|
| 583 |
+
if (state.wavesurfer) state.wavesurfer.zoom(Number(e.target.value));
|
| 584 |
+
});
|
| 585 |
+
|
| 586 |
+
function updateTimeDisplay() {
|
| 587 |
+
if(!state.wavesurfer) return;
|
| 588 |
+
const cur = state.wavesurfer.getCurrentTime();
|
| 589 |
+
const tot = state.wavesurfer.getDuration() || 0;
|
| 590 |
+
UI.timeDisplay.textContent = `${formatTime(cur)} / ${formatTime(tot)}`;
|
| 591 |
+
|
| 592 |
+
const item = state.files.find(f => f.id === state.activeId);
|
| 593 |
+
if(item && item.status === 'pending') {
|
| 594 |
+
if (cur > item.endTrim && state.wavesurfer.isPlaying()) {
|
| 595 |
+
state.wavesurfer.pause();
|
| 596 |
+
state.wavesurfer.setTime(item.startTrim);
|
| 597 |
+
}
|
| 598 |
+
}
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
function formatTime(sec) {
|
| 602 |
+
const m = Math.floor(sec / 60);
|
| 603 |
+
const s = Math.floor(sec % 60);
|
| 604 |
+
return `${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`;
|
| 605 |
+
}
|
| 606 |
+
|
| 607 |
+
UI.playBtn.onclick = () => state.wavesurfer && state.wavesurfer.playPause();
|
| 608 |
+
|
| 609 |
+
document.getElementById('setStartBtn').onclick = () => {
|
| 610 |
+
if(!state.wavesurfer) return;
|
| 611 |
+
UI.trimStart.value = state.wavesurfer.getCurrentTime().toFixed(1);
|
| 612 |
+
saveTrim();
|
| 613 |
+
};
|
| 614 |
+
document.getElementById('setEndBtn').onclick = () => {
|
| 615 |
+
if(!state.wavesurfer) return;
|
| 616 |
+
UI.trimEnd.value = state.wavesurfer.getCurrentTime().toFixed(1);
|
| 617 |
+
saveTrim();
|
| 618 |
+
};
|
| 619 |
+
UI.trimStart.onchange = saveTrim;
|
| 620 |
+
UI.trimEnd.onchange = saveTrim;
|
| 621 |
+
|
| 622 |
+
function saveTrim() {
|
| 623 |
+
const item = state.files.find(f => f.id === state.activeId);
|
| 624 |
+
if(!item || item.status !== 'pending') return;
|
| 625 |
+
let start = parseFloat(UI.trimStart.value) || 0;
|
| 626 |
+
let end = parseFloat(UI.trimEnd.value) || item.duration;
|
| 627 |
+
if(start < 0) start = 0;
|
| 628 |
+
if(end > item.duration) end = item.duration;
|
| 629 |
+
if(start >= end) start = end - 0.1;
|
| 630 |
+
|
| 631 |
+
UI.trimStart.value = start.toFixed(1);
|
| 632 |
+
UI.trimEnd.value = end.toFixed(1);
|
| 633 |
+
item.startTrim = start;
|
| 634 |
+
item.endTrim = end;
|
| 635 |
+
}
|
| 636 |
+
|
| 637 |
+
// A/B Toggle Logic
|
| 638 |
+
UI.btnOriginal.onclick = () => setPlaybackMode('original', state.files.find(f=>f.id===state.activeId));
|
| 639 |
+
UI.btnCleaned.onclick = () => setPlaybackMode('cleaned', state.files.find(f=>f.id===state.activeId));
|
| 640 |
+
|
| 641 |
+
function setPlaybackMode(mode, item) {
|
| 642 |
+
if (!item || !state.wavesurfer) return;
|
| 643 |
+
state.playbackMode = mode;
|
| 644 |
+
|
| 645 |
+
if (mode === 'original') {
|
| 646 |
+
UI.btnOriginal.className = 'px-4 py-1.5 text-xs font-bold rounded-md bg-white dark:bg-slate-700 text-slate-800 dark:text-white transition-all shadow-sm';
|
| 647 |
+
UI.btnCleaned.className = 'px-4 py-1.5 text-xs font-bold rounded-md text-slate-500 dark:text-slate-400 hover:text-slate-800 dark:hover:text-white transition-all';
|
| 648 |
+
state.wavesurfer.setOptions({ waveColor: '#94a3b8', progressColor: '#cbd5e1' });
|
| 649 |
+
} else {
|
| 650 |
+
UI.btnCleaned.className = 'px-4 py-1.5 text-xs font-bold rounded-md bg-primary-600 text-white transition-all shadow-sm';
|
| 651 |
+
UI.btnOriginal.className = 'px-4 py-1.5 text-xs font-bold rounded-md text-slate-500 dark:text-slate-400 hover:text-slate-800 dark:hover:text-white transition-all';
|
| 652 |
+
state.wavesurfer.setOptions({ waveColor: '#1e3a8a', progressColor: '#3b82f6' });
|
| 653 |
+
}
|
| 654 |
+
|
| 655 |
+
const curTime = state.wavesurfer.getCurrentTime();
|
| 656 |
+
const wasPlaying = state.wavesurfer.isPlaying();
|
| 657 |
+
|
| 658 |
+
state.wavesurfer.load(mode === 'cleaned' ? item.cleanedUrl : item.originalUrl).then(() => {
|
| 659 |
+
state.wavesurfer.setTime(curTime);
|
| 660 |
+
if(wasPlaying) state.wavesurfer.play();
|
| 661 |
+
});
|
| 662 |
+
}
|
| 663 |
+
|
| 664 |
+
// --- PROCESSING ENGINE (THE HEAVY LIFTING) ---
|
| 665 |
+
function setGlobalStatus(show, title='', desc='', progress=0) {
|
| 666 |
+
if (!show) { UI.globalStatus.classList.add('hidden'); return; }
|
| 667 |
+
UI.globalStatus.classList.remove('hidden');
|
| 668 |
+
UI.statusTitle.textContent = title;
|
| 669 |
+
UI.statusDesc.textContent = desc;
|
| 670 |
+
UI.progressBar.style.width = `${progress}%`;
|
| 671 |
+
}
|
| 672 |
+
|
| 673 |
+
UI.processBtn.onclick = async () => {
|
| 674 |
+
const pending = state.files.filter(f => f.status === 'pending');
|
| 675 |
+
if (pending.length === 0) return;
|
| 676 |
+
|
| 677 |
+
setGlobalStatus(true, "Initializing AI Engine...", "Loading DeepFilterNet WebAssembly core.", 10);
|
| 678 |
+
|
| 679 |
+
try {
|
| 680 |
+
if (!state.dfNetProc) {
|
| 681 |
+
const dfModule = await import('https://esm.sh/deepfilternet3-noise-filter@1.2.1');
|
| 682 |
+
const ProcessorClass = dfModule.DeepFilterNet3Core || dfModule.DeepFilterNoiseFilterProcessor;
|
| 683 |
+
|
| 684 |
+
state.dfNetProc = new ProcessorClass({
|
| 685 |
+
sampleRate: 48000,
|
| 686 |
+
noiseReductionLevel: state.settings.noiseLevel,
|
| 687 |
+
assetConfig: { cdnUrl: 'https://huggingface.co/trysem/DeepFilterNet3/resolve/main' }
|
| 688 |
+
});
|
| 689 |
+
await state.dfNetProc.initialize();
|
| 690 |
+
} else {
|
| 691 |
+
state.dfNetProc.noiseReductionLevel = state.settings.noiseLevel;
|
| 692 |
+
}
|
| 693 |
+
|
| 694 |
+
const audioCtx = new (window.AudioContext || window.webkitAudioContext)({ sampleRate: 48000 });
|
| 695 |
+
|
| 696 |
+
for (let i = 0; i < pending.length; i++) {
|
| 697 |
+
const item = pending[i];
|
| 698 |
+
item.status = 'processing';
|
| 699 |
+
renderQueue();
|
| 700 |
+
|
| 701 |
+
const p = 10 + Math.floor((i / pending.length) * 90);
|
| 702 |
+
setGlobalStatus(true, `Processing File ${i+1} of ${pending.length}`, `Cleaning: ${item.name}`, p);
|
| 703 |
+
|
| 704 |
+
const arrayBuffer = await item.file.arrayBuffer();
|
| 705 |
+
let decodedBuffer = await audioCtx.decodeAudioData(arrayBuffer);
|
| 706 |
+
|
| 707 |
+
if (item.endTrim > 0 && (item.startTrim > 0 || item.endTrim < decodedBuffer.duration)) {
|
| 708 |
+
const startSample = Math.floor(item.startTrim * 48000);
|
| 709 |
+
let endSample = Math.floor(item.endTrim * 48000);
|
| 710 |
+
if (endSample > decodedBuffer.length) endSample = decodedBuffer.length;
|
| 711 |
+
|
| 712 |
+
const len = endSample - startSample;
|
| 713 |
+
const trimmed = new AudioContext({sampleRate:48000}).createBuffer(decodedBuffer.numberOfChannels, len, 48000);
|
| 714 |
+
for(let c=0; c<decodedBuffer.numberOfChannels; c++){
|
| 715 |
+
trimmed.copyToChannel(decodedBuffer.getChannelData(c).subarray(startSample, endSample), c);
|
| 716 |
+
}
|
| 717 |
+
decodedBuffer = trimmed;
|
| 718 |
+
}
|
| 719 |
+
|
| 720 |
+
const offlineCtx = new OfflineAudioContext(1, decodedBuffer.length, 48000);
|
| 721 |
+
const sourceNode = offlineCtx.createBufferSource();
|
| 722 |
+
|
| 723 |
+
if (decodedBuffer.numberOfChannels > 1) {
|
| 724 |
+
const mono = offlineCtx.createBuffer(1, decodedBuffer.length, 48000);
|
| 725 |
+
const data = mono.getChannelData(0), left = decodedBuffer.getChannelData(0), right = decodedBuffer.getChannelData(1);
|
| 726 |
+
for (let j = 0; j < decodedBuffer.length; j++) data[j] = (left[j] + right[j]) / 2;
|
| 727 |
+
sourceNode.buffer = mono;
|
| 728 |
+
} else {
|
| 729 |
+
sourceNode.buffer = decodedBuffer;
|
| 730 |
+
}
|
| 731 |
+
|
| 732 |
+
// Audio Pipeline: Source -> DeepFilterNet -> Bass -> Treble -> Gain -> Destination
|
| 733 |
+
const dfNode = await state.dfNetProc.createAudioWorkletNode(offlineCtx);
|
| 734 |
+
|
| 735 |
+
const bassEq = offlineCtx.createBiquadFilter();
|
| 736 |
+
bassEq.type = 'lowshelf';
|
| 737 |
+
bassEq.frequency.value = 250;
|
| 738 |
+
bassEq.gain.value = state.settings.bass;
|
| 739 |
+
|
| 740 |
+
const trebleEq = offlineCtx.createBiquadFilter();
|
| 741 |
+
trebleEq.type = 'highshelf';
|
| 742 |
+
trebleEq.frequency.value = 4000;
|
| 743 |
+
trebleEq.gain.value = state.settings.treble;
|
| 744 |
+
|
| 745 |
+
const gainNode = offlineCtx.createGain();
|
| 746 |
+
gainNode.gain.value = Math.pow(10, state.settings.gain / 20);
|
| 747 |
+
|
| 748 |
+
sourceNode.connect(dfNode);
|
| 749 |
+
dfNode.connect(bassEq);
|
| 750 |
+
bassEq.connect(trebleEq);
|
| 751 |
+
trebleEq.connect(gainNode);
|
| 752 |
+
gainNode.connect(offlineCtx.destination);
|
| 753 |
+
|
| 754 |
+
sourceNode.start(0);
|
| 755 |
+
|
| 756 |
+
const renderedBuffer = await offlineCtx.startRendering();
|
| 757 |
+
|
| 758 |
+
if (state.settings.normalize) {
|
| 759 |
+
const dat = renderedBuffer.getChannelData(0);
|
| 760 |
+
let max = 0;
|
| 761 |
+
for(let j=0; j<dat.length; j++) { if(Math.abs(dat[j]) > max) max = Math.abs(dat[j]); }
|
| 762 |
+
if (max > 0) {
|
| 763 |
+
const multiplier = 0.95 / max;
|
| 764 |
+
for(let j=0; j<dat.length; j++) dat[j] *= multiplier;
|
| 765 |
+
}
|
| 766 |
+
}
|
| 767 |
+
|
| 768 |
+
let outBlob;
|
| 769 |
+
if (state.settings.format === 'mp3') {
|
| 770 |
+
setGlobalStatus(true, `Encoding MP3...`, `Compressing: ${item.name}`, p+5);
|
| 771 |
+
outBlob = encodeToMP3(renderedBuffer);
|
| 772 |
+
} else {
|
| 773 |
+
outBlob = audioBufferToWav(renderedBuffer);
|
| 774 |
+
}
|
| 775 |
+
|
| 776 |
+
item.cleanedUrl = URL.createObjectURL(outBlob);
|
| 777 |
+
item.blob = outBlob;
|
| 778 |
+
item.status = 'done';
|
| 779 |
+
decodedBuffer = null;
|
| 780 |
+
}
|
| 781 |
+
|
| 782 |
+
setGlobalStatus(false);
|
| 783 |
+
renderQueue();
|
| 784 |
+
if(state.activeId) selectFile(state.activeId);
|
| 785 |
+
|
| 786 |
+
} catch (err) {
|
| 787 |
+
console.error(err);
|
| 788 |
+
alert("An error occurred during processing. Check console.");
|
| 789 |
+
setGlobalStatus(false);
|
| 790 |
+
}
|
| 791 |
+
};
|
| 792 |
+
|
| 793 |
+
// --- ENCODERS ---
|
| 794 |
+
function audioBufferToWav(buffer) {
|
| 795 |
+
const numOfChan = buffer.numberOfChannels, len = buffer.length * numOfChan * 2 + 44;
|
| 796 |
+
const view = new DataView(new ArrayBuffer(len)), channels = [];
|
| 797 |
+
let offset = 0, pos = 0;
|
| 798 |
+
const setU16 = d => { view.setUint16(offset, d, true); offset += 2; };
|
| 799 |
+
const setU32 = d => { view.setUint32(offset, d, true); offset += 4; };
|
| 800 |
+
|
| 801 |
+
setU32(0x46464952); setU32(len - 8); setU32(0x45564157); setU32(0x20746d66); setU32(16); setU16(1); setU16(numOfChan);
|
| 802 |
+
setU32(buffer.sampleRate); setU32(buffer.sampleRate * 2 * numOfChan); setU16(numOfChan * 2); setU16(16); setU32(0x61746164); setU32(len - pos - 4);
|
| 803 |
+
|
| 804 |
+
for(let i=0; i<numOfChan; i++) channels.push(buffer.getChannelData(i));
|
| 805 |
+
|
| 806 |
+
while(pos < buffer.length) {
|
| 807 |
+
for(let i=0; i<numOfChan; i++) {
|
| 808 |
+
let s = Math.max(-1, Math.min(1, channels[i][pos]));
|
| 809 |
+
setU16(s < 0 ? s * 0x8000 : s * 0x7FFF);
|
| 810 |
+
}
|
| 811 |
+
pos++;
|
| 812 |
+
}
|
| 813 |
+
return new Blob([view.buffer], { type: "audio/wav" });
|
| 814 |
+
}
|
| 815 |
+
|
| 816 |
+
function encodeToMP3(audioBuffer) {
|
| 817 |
+
const encoder = new lamejs.Mp3Encoder(1, audioBuffer.sampleRate, 192);
|
| 818 |
+
const samples = audioBuffer.getChannelData(0);
|
| 819 |
+
const mp3Data = [];
|
| 820 |
+
const blockSize = 1152;
|
| 821 |
+
const int16Samples = new Int16Array(samples.length);
|
| 822 |
+
|
| 823 |
+
for (let i = 0; i < samples.length; i++) {
|
| 824 |
+
let s = Math.max(-1, Math.min(1, samples[i]));
|
| 825 |
+
int16Samples[i] = s < 0 ? s * 0x8000 : s * 0x7FFF;
|
| 826 |
+
}
|
| 827 |
+
|
| 828 |
+
for (let i = 0; i < int16Samples.length; i += blockSize) {
|
| 829 |
+
const chunk = int16Samples.subarray(i, i + blockSize);
|
| 830 |
+
const buf = encoder.encodeBuffer(chunk);
|
| 831 |
+
if (buf.length > 0) mp3Data.push(buf);
|
| 832 |
+
}
|
| 833 |
+
|
| 834 |
+
const flush = encoder.flush();
|
| 835 |
+
if (flush.length > 0) mp3Data.push(flush);
|
| 836 |
+
return new Blob(mp3Data, { type: 'audio/mp3' });
|
| 837 |
+
}
|
| 838 |
+
|
| 839 |
+
// --- DOWNLOAD ACTIONS ---
|
| 840 |
+
UI.downloadSingleBtn.onclick = () => {
|
| 841 |
+
const item = state.files.find(f => f.id === state.activeId);
|
| 842 |
+
if(!item || !item.cleanedUrl) return;
|
| 843 |
+
const ext = state.settings.format === 'mp3' ? '.mp3' : '.wav';
|
| 844 |
+
const a = document.createElement('a');
|
| 845 |
+
a.href = item.cleanedUrl;
|
| 846 |
+
a.download = `Cleaned_${item.name.replace(/\.[^/.]+$/, "")}${ext}`;
|
| 847 |
+
a.click();
|
| 848 |
+
};
|
| 849 |
+
|
| 850 |
+
UI.downloadZipBtn.onclick = async () => {
|
| 851 |
+
const doneFiles = state.files.filter(f => f.status === 'done');
|
| 852 |
+
if(doneFiles.length === 0) return;
|
| 853 |
+
|
| 854 |
+
const zip = new JSZip();
|
| 855 |
+
const ext = state.settings.format === 'mp3' ? '.mp3' : '.wav';
|
| 856 |
+
|
| 857 |
+
doneFiles.forEach(f => {
|
| 858 |
+
const safeName = `Cleaned_${f.name.replace(/\.[^/.]+$/, "")}${ext}`;
|
| 859 |
+
zip.file(safeName, f.blob);
|
| 860 |
+
});
|
| 861 |
+
|
| 862 |
+
setGlobalStatus(true, "Zipping files...", "Compressing your audio batch");
|
| 863 |
+
const content = await zip.generateAsync({type:"blob"});
|
| 864 |
+
setGlobalStatus(false);
|
| 865 |
+
|
| 866 |
+
const a = document.createElement('a');
|
| 867 |
+
a.href = URL.createObjectURL(content);
|
| 868 |
+
a.download = "DeepFilterNet_Batch.zip";
|
| 869 |
+
a.click();
|
| 870 |
+
};
|
| 871 |
+
</script>
|
| 872 |
+
</body>
|
| 873 |
+
</html>
|