Spaces:
Build error
Build error
Upload app.py with huggingface_hub
Browse files
app.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Built with anycoder
|
| 2 |
+
// https://huggingface.co/spaces/akhaliq/anycoder
|
| 3 |
+
|
| 4 |
+
import { useState, useEffect } from 'react';
|
| 5 |
+
import { Play, Pause, RotateCcw } from 'lucide-react';
|
| 6 |
+
|
| 7 |
+
const BeatBotGPT5 = () => {
|
| 8 |
+
const [isPlaying, setIsPlaying] = useState(false);
|
| 9 |
+
const [currentStep, setCurrentStep] = useState(0);
|
| 10 |
+
const [bpm] = useState(128);
|
| 11 |
+
|
| 12 |
+
// GPT-5 celebration beat pattern
|
| 13 |
+
const pattern = {
|
| 14 |
+
kick: [1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0],
|
| 15 |
+
snare: [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0],
|
| 16 |
+
hihat: [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],
|
| 17 |
+
clap: [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1],
|
| 18 |
+
};
|
| 19 |
+
|
| 20 |
+
const tracks = [
|
| 21 |
+
{ name: 'Kick', pattern: pattern.kick, color: 'bg-red-500' },
|
| 22 |
+
{ name: 'Snare', pattern: pattern.snare, color: 'bg-blue-500' },
|
| 23 |
+
{ name: 'Hi-Hat', pattern: pattern.hihat, color: 'bg-green-500' },
|
| 24 |
+
{ name: 'Clap', pattern: pattern.clap, color: 'bg-yellow-500' },
|
| 25 |
+
];
|
| 26 |
+
|
| 27 |
+
useEffect(() => {
|
| 28 |
+
if (!isPlaying) return;
|
| 29 |
+
|
| 30 |
+
const interval = setInterval(() => {
|
| 31 |
+
setCurrentStep((prev) => (prev + 1) % 16);
|
| 32 |
+
}, (60 / bpm / 4) * 1000);
|
| 33 |
+
|
| 34 |
+
return () => clearInterval(interval);
|
| 35 |
+
}, [isPlaying, bpm]);
|
| 36 |
+
|
| 37 |
+
const togglePlayback = () => setIsPlaying(!isPlaying);
|
| 38 |
+
const resetBeat = () => {
|
| 39 |
+
setIsPlaying(false);
|
| 40 |
+
setCurrentStep(0);
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
return (
|
| 44 |
+
<div className="min-h-screen bg-gradient-to-br from-purple-900 via-blue-900 to-indigo-900 text-white p-8">
|
| 45 |
+
<div className="max-w-6xl mx-auto">
|
| 46 |
+
<header className="text-center mb-12">
|
| 47 |
+
<h1 className="text-5xl font-bold mb-2 bg-gradient-to-r from-cyan-400 to-purple-400 bg-clip-text text-transparent">
|
| 48 |
+
Built with anycoder
|
| 49 |
+
</h1>
|
| 50 |
+
<h2 className="text-3xl font-semibold mb-4">π GPT-5 Celebration Beat π</h2>
|
| 51 |
+
<p className="text-xl text-gray-300">The future of AI never sounded so good</p>
|
| 52 |
+
</header>
|
| 53 |
+
|
| 54 |
+
<div className="bg-black bg-opacity-50 rounded-2xl p-8 backdrop-blur-lg">
|
| 55 |
+
<div className="flex justify-center gap-4 mb-8">
|
| 56 |
+
<button
|
| 57 |
+
onClick={togglePlayback}
|
| 58 |
+
className="flex items-center gap-2 px-6 py-3 bg-gradient-to-r from-purple-600 to-pink-600 rounded-full hover:from-purple-700 hover:to-pink-700 transition-all transform hover:scale-105"
|
| 59 |
+
>
|
| 60 |
+
{isPlaying ? <Pause size={24} /> : <Play size={24} />}
|
| 61 |
+
{isPlaying ? 'Pause' : 'Play'}
|
| 62 |
+
</button>
|
| 63 |
+
<button
|
| 64 |
+
onClick={resetBeat}
|
| 65 |
+
className="flex items-center gap-2 px-6 py-3 bg-gradient-to-r from-gray-600 to-gray-700 rounded-full hover:from-gray-700 hover:to-gray-800 transition-all transform hover:scale-105"
|
| 66 |
+
>
|
| 67 |
+
<RotateCcw size={24} />
|
| 68 |
+
Reset
|
| 69 |
+
</button>
|
| 70 |
+
</div>
|
| 71 |
+
|
| 72 |
+
<div className="space-y-4">
|
| 73 |
+
{tracks.map((track) => (
|
| 74 |
+
<div key={track.name} className="flex items-center gap-4">
|
| 75 |
+
<div className="w-20 text-right font-semibold">{track.name}</div>
|
| 76 |
+
<div className="flex gap-2">
|
| 77 |
+
{track.pattern.map((step, index) => (
|
| 78 |
+
<div
|
| 79 |
+
key={index}
|
| 80 |
+
className={`w-12 h-12 rounded-lg border-2 transition-all ${step ? track.color : 'bg-gray-800 border-gray-600'} ${currentStep === index && isPlaying ? 'ring-4 ring-white ring-opacity-50' : ''}`}
|
| 81 |
+
/>
|
| 82 |
+
))}
|
| 83 |
+
</div>
|
| 84 |
+
</div>
|
| 85 |
+
))}
|
| 86 |
+
</div>
|
| 87 |
+
|
| 88 |
+
<div className="mt-8 text-center">
|
| 89 |
+
<div className="text-2xl font-bold mb-2">{bpm} BPM</div>
|
| 90 |
+
<div className="text-lg text-gray-400">Step: {currentStep + 1} / 16</div>
|
| 91 |
+
</div>
|
| 92 |
+
</div>
|
| 93 |
+
|
| 94 |
+
<div className="mt-8 text-center text-gray-400">
|
| 95 |
+
<p>π₯ Drop the beat for GPT-5! π₯</p>
|
| 96 |
+
</div>
|
| 97 |
+
</div>
|
| 98 |
+
</div>
|
| 99 |
+
);
|
| 100 |
+
};
|
| 101 |
+
|
| 102 |
+
export default BeatBotGPT5;
|