Spaces:
Running
Running
Add 3 files
Browse files- README.md +7 -5
- index.html +158 -19
- prompts.txt +1 -0
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: audio-react-visualizer
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: purple
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,158 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>Audio Visualization Reacting to Beat</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: 300px;
|
| 14 |
+
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
| 15 |
+
border-radius: 12px;
|
| 16 |
+
overflow: hidden;
|
| 17 |
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
.bar {
|
| 21 |
+
position: absolute;
|
| 22 |
+
bottom: 0;
|
| 23 |
+
width: 8px;
|
| 24 |
+
background: linear-gradient(to top, #00b4db, #0083b0);
|
| 25 |
+
border-radius: 4px 4px 0 0;
|
| 26 |
+
transition: height 0.05s ease-out;
|
| 27 |
+
box-shadow: 0 0 10px rgba(0, 180, 219, 0.7);
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
.beat-circle {
|
| 31 |
+
position: absolute;
|
| 32 |
+
border-radius: 50%;
|
| 33 |
+
background: radial-gradient(circle, rgba(255,105,180,0.8) 0%, rgba(255,20,147,0.5) 70%, transparent 100%);
|
| 34 |
+
transform: translate(-50%, -50%);
|
| 35 |
+
opacity: 0;
|
| 36 |
+
transition: opacity 0.3s, transform 0.3s;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
.pulse {
|
| 40 |
+
animation: pulse 0.5s ease-out;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
@keyframes pulse {
|
| 44 |
+
0% { transform: scale(1); opacity: 0.8; }
|
| 45 |
+
100% { transform: scale(1.5); opacity: 0; }
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
.audio-wave {
|
| 49 |
+
position: absolute;
|
| 50 |
+
bottom: 0;
|
| 51 |
+
left: 0;
|
| 52 |
+
width: 100%;
|
| 53 |
+
height: 100px;
|
| 54 |
+
background: linear-gradient(to top, rgba(0, 180, 219, 0.1), transparent);
|
| 55 |
+
clip-path: polygon(0% 100%, 100% 100%, 100% 0%, 0% 0%);
|
| 56 |
+
}
|
| 57 |
+
</style>
|
| 58 |
+
</head>
|
| 59 |
+
<body class="bg-gray-900 text-white min-h-screen flex flex-col items-center justify-center p-4">
|
| 60 |
+
<div class="max-w-4xl w-full">
|
| 61 |
+
<h1 class="text-4xl font-bold mb-2 text-center bg-gradient-to-r from-cyan-400 to-pink-500 bg-clip-text text-transparent">
|
| 62 |
+
Audio React Visualizer
|
| 63 |
+
</h1>
|
| 64 |
+
<p class="text-gray-400 text-center mb-8">Visualization reacts to both frequency and beat detection</p>
|
| 65 |
+
|
| 66 |
+
<div class="visualizer-container mb-8" id="visualizer">
|
| 67 |
+
<div class="audio-wave" id="audioWave"></div>
|
| 68 |
+
</div>
|
| 69 |
+
|
| 70 |
+
<div class="flex flex-col md:flex-row gap-4 items-center justify-center">
|
| 71 |
+
<div class="flex-1">
|
| 72 |
+
<input type="file" id="audioUpload" accept="audio/*" class="hidden" />
|
| 73 |
+
<label for="audioUpload" class="cursor-pointer bg-gradient-to-r from-cyan-500 to-blue-500 hover:from-cyan-600 hover:to-blue-600 text-white font-bold py-3 px-6 rounded-lg flex items-center justify-center transition-all duration-300 shadow-lg hover:shadow-xl">
|
| 74 |
+
<i class="fas fa-music mr-2"></i> Choose Audio File
|
| 75 |
+
</label>
|
| 76 |
+
</div>
|
| 77 |
+
<div class="flex-1">
|
| 78 |
+
<button id="playButton" class="bg-gradient-to-r from-pink-500 to-purple-500 hover:from-pink-600 hover:to-purple-600 text-white font-bold py-3 px-6 rounded-lg w-full flex items-center justify-center transition-all duration-300 shadow-lg hover:shadow-xl">
|
| 79 |
+
<i class="fas fa-play mr-2"></i> Play Demo
|
| 80 |
+
</button>
|
| 81 |
+
</div>
|
| 82 |
+
</div>
|
| 83 |
+
|
| 84 |
+
<div class="mt-8 grid grid-cols-1 md:grid-cols-3 gap-4">
|
| 85 |
+
<div class="bg-gray-800 p-4 rounded-lg">
|
| 86 |
+
<h3 class="text-cyan-400 font-semibold mb-2"><i class="fas fa-sliders-h mr-2"></i>Controls</h3>
|
| 87 |
+
<div class="space-y-4">
|
| 88 |
+
<div>
|
| 89 |
+
<label class="block text-gray-400 mb-1">Sensitivity</label>
|
| 90 |
+
<input type="range" id="sensitivity" min="0.1" max="1" step="0.05" value="0.5" class="w-full accent-cyan-500">
|
| 91 |
+
</div>
|
| 92 |
+
<div>
|
| 93 |
+
<label class="block text-gray-400 mb-1">Bar Count</label>
|
| 94 |
+
<input type="range" id="barCount" min="20" max="200" step="10" value="80" class="w-full accent-pink-500">
|
| 95 |
+
</div>
|
| 96 |
+
</div>
|
| 97 |
+
</div>
|
| 98 |
+
|
| 99 |
+
<div class="bg-gray-800 p-4 rounded-lg">
|
| 100 |
+
<h3 class="text-purple-400 font-semibold mb-2"><i class="fas fa-chart-bar mr-2"></i>Audio Info</h3>
|
| 101 |
+
<div class="space-y-2">
|
| 102 |
+
<p>Status: <span id="status" class="text-pink-400">Waiting for audio</span></p>
|
| 103 |
+
<p>Beat: <span id="beatStatus" class="text-cyan-400">No beat detected</span></p>
|
| 104 |
+
<p>Volume: <span id="volumeLevel">0</span>%</p>
|
| 105 |
+
</div>
|
| 106 |
+
</div>
|
| 107 |
+
|
| 108 |
+
<div class="bg-gray-800 p-4 rounded-lg">
|
| 109 |
+
<h3 class="text-pink-400 font-semibold mb-2"><i class="fas fa-info-circle mr-2"></i>About</h3>
|
| 110 |
+
<p class="text-gray-400 text-sm">This visualization analyzes audio frequencies and detects beats in real-time. The bars represent different frequency ranges, while circles appear when beats are detected.</p>
|
| 111 |
+
</div>
|
| 112 |
+
</div>
|
| 113 |
+
</div>
|
| 114 |
+
|
| 115 |
+
<script>
|
| 116 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 117 |
+
// Audio elements
|
| 118 |
+
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
| 119 |
+
let audioSource = null;
|
| 120 |
+
let analyser = null;
|
| 121 |
+
let dataArray = null;
|
| 122 |
+
let isPlaying = false;
|
| 123 |
+
let animationId = null;
|
| 124 |
+
|
| 125 |
+
// Beat detection variables
|
| 126 |
+
let lastBeatTime = 0;
|
| 127 |
+
let beatThreshold = 1.5;
|
| 128 |
+
let beatHoldTime = 400; // ms
|
| 129 |
+
let beatDecayRate = 0.98;
|
| 130 |
+
let beatCutOff = 0;
|
| 131 |
+
|
| 132 |
+
// DOM elements
|
| 133 |
+
const visualizer = document.getElementById('visualizer');
|
| 134 |
+
const audioWave = document.getElementById('audioWave');
|
| 135 |
+
const playButton = document.getElementById('playButton');
|
| 136 |
+
const audioUpload = document.getElementById('audioUpload');
|
| 137 |
+
const statusElement = document.getElementById('status');
|
| 138 |
+
const beatStatusElement = document.getElementById('beatStatus');
|
| 139 |
+
const volumeLevelElement = document.getElementById('volumeLevel');
|
| 140 |
+
const sensitivityInput = document.getElementById('sensitivity');
|
| 141 |
+
const barCountInput = document.getElementById('barCount');
|
| 142 |
+
|
| 143 |
+
let barCount = parseInt(barCountInput.value);
|
| 144 |
+
let bars = [];
|
| 145 |
+
let sensitivity = parseFloat(sensitivityInput.value);
|
| 146 |
+
|
| 147 |
+
// Create initial bars
|
| 148 |
+
function createBars() {
|
| 149 |
+
// Clear existing bars
|
| 150 |
+
visualizer.querySelectorAll('.bar').forEach(bar => bar.remove());
|
| 151 |
+
bars = [];
|
| 152 |
+
|
| 153 |
+
const containerWidth = visualizer.clientWidth;
|
| 154 |
+
const barWidth = containerWidth / barCount;
|
| 155 |
+
|
| 156 |
+
for (let i = 0; i < barCount; i++) {
|
| 157 |
+
const bar = document.createElement('div
|
| 158 |
+
</html>
|
prompts.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
make audio viylation reacts to the beat and audio
|