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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>Song Generator</title>
|
| 7 |
+
<script src="https://cdn.jsdelivr.net/npm/react@18.0.0/umd/react.development.js"></script>
|
| 8 |
+
<script src="https://cdn.jsdelivr.net/npm/react-dom@18.0.0/umd/react-dom.development.js"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/@babel/standalone/babel.js"></script>
|
| 10 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 11 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"></link>
|
| 12 |
+
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
| 13 |
+
<style>
|
| 14 |
+
body {
|
| 15 |
+
font-family: 'Poppins', sans-serif;
|
| 16 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 17 |
+
min-height: 100vh;
|
| 18 |
+
}
|
| 19 |
+
.glass-morphism {
|
| 20 |
+
background: rgba(255, 255, 255, 0.1);
|
| 21 |
+
backdrop-filter: blur(10px);
|
| 22 |
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
| 23 |
+
}
|
| 24 |
+
.song-line {
|
| 25 |
+
animation: fadeIn 0.5s ease-in-out;
|
| 26 |
+
}
|
| 27 |
+
@keyframes fadeIn {
|
| 28 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 29 |
+
to { opacity: 1; transform: translateY(0); }
|
| 30 |
+
}
|
| 31 |
+
.typing-animation {
|
| 32 |
+
overflow: hidden;
|
| 33 |
+
border-right: 3px solid;
|
| 34 |
+
white-space: nowrap;
|
| 35 |
+
animation: typing 3.5s steps(40, end), blink-caret 0.75s step-end infinite;
|
| 36 |
+
}
|
| 37 |
+
@keyframes typing {
|
| 38 |
+
from { width: 0 }
|
| 39 |
+
to { width: 100% }
|
| 40 |
+
}
|
| 41 |
+
@keyframes blink-caret {
|
| 42 |
+
from, to { border-color: transparent }
|
| 43 |
+
50% { border-color: white; }
|
| 44 |
+
}
|
| 45 |
+
</style>
|
| 46 |
+
</head>
|
| 47 |
+
<body>
|
| 48 |
+
<div id="root"></div>
|
| 49 |
+
|
| 50 |
+
<script type="text/babel">
|
| 51 |
+
const { useState, useEffect } = React;
|
| 52 |
+
|
| 53 |
+
const SongGenerator = () => {
|
| 54 |
+
const [prompt, setPrompt] = useState('');
|
| 55 |
+
const [generatedSong, setGeneratedSong] = useState(null);
|
| 56 |
+
const [isGenerating, setIsGenerating] = useState(false);
|
| 57 |
+
const [showSuccess, setShowSuccess] = useState(false);
|
| 58 |
+
|
| 59 |
+
const generateSong = () => {
|
| 60 |
+
if (!prompt.trim()) return;
|
| 61 |
+
|
| 62 |
+
setIsGenerating(true);
|
| 63 |
+
setShowSuccess(false);
|
| 64 |
+
|
| 65 |
+
// Simulate API call
|
| 66 |
+
setTimeout(() => {
|
| 67 |
+
const song = generateMockSong(prompt);
|
| 68 |
+
setGeneratedSong(song);
|
| 69 |
+
setIsGenerating(false);
|
| 70 |
+
setShowSuccess(true);
|
| 71 |
+
}, 2000);
|
| 72 |
+
};
|
| 73 |
+
|
| 74 |
+
const generateMockSong = (prompt) => {
|
| 75 |
+
const themes = ['love', 'freedom', 'nature', 'dreams', 'adventure', 'memories'];
|
| 76 |
+
const moods = ['happy', 'sad', 'energetic', 'calm', 'reflective'];
|
| 77 |
+
const structures = [
|
| 78 |
+
['Verse 1', 'Pre-Chorus', 'Chorus', 'Verse 2', 'Chorus', 'Bridge', 'Chorus', 'Outro'],
|
| 79 |
+
['Intro', 'Verse', 'Chorus', 'Verse', 'Chorus', 'Bridge', 'Chorus', 'Outro'],
|
| 80 |
+
['Verse', 'Chorus', 'Verse', 'Chorus', 'Bridge', 'Chorus', 'Outro']
|
| 81 |
+
];
|
| 82 |
+
|
| 83 |
+
const structure = structures[Math.floor(Math.random() * structures.length)];
|
| 84 |
+
const theme = themes[Math.floor(Math.random() * themes.length)];
|
| 85 |
+
const mood = moods[Math.floor(Math.random() * moods.length)];
|
| 86 |
+
|
| 87 |
+
const lines = [];
|
| 88 |
+
structure.forEach(section => {
|
| 89 |
+
lines.push(`[${section}]`);
|
| 90 |
+
for (let i = 0; i < 4; i++) {
|
| 91 |
+
const line = generateLine(prompt, theme, mood);
|
| 92 |
+
lines.push(line);
|
| 93 |
+
}
|
| 94 |
+
});
|
| 95 |
+
|
| 96 |
+
return {
|
| 97 |
+
title: `Song: ${prompt.charAt(0).toUpperCase() + prompt.slice(1)}`,
|
| 98 |
+
artist: 'AI Composer',
|
| 99 |
+
theme,
|
| 100 |
+
mood,
|
| 101 |
+
structure,
|
| 102 |
+
lyrics: lines
|
| 103 |
+
};
|
| 104 |
+
};
|
| 105 |
+
|
| 106 |
+
const generateLine = (prompt, theme, mood) => {
|
| 107 |
+
const words = {
|
| 108 |
+
love: ['heart', 'soul', 'kiss', 'embrace', 'forever', 'together', 'passion', 'romance'],
|
| 109 |
+
freedom: ['sky', 'fly', 'open', 'wings', 'break', 'free', 'wild', 'unbound'],
|
| 110 |
+
nature: ['sun', 'moon', 'stars', 'river', 'mountain', 'forest', 'ocean', 'breeze'],
|
| 111 |
+
dreams: ['night', 'sleep', 'wonder', 'magic', 'vision', 'future', 'hope', 'imagination'],
|
| 112 |
+
adventure: ['journey', 'explore', 'discover', 'path', 'road', 'destination', 'expedition', 'quest'],
|
| 113 |
+
memories: ['past', 'time', 'remember', 'yesterday', 'childhood', 'nostalgia', 'moments', 'stories']
|
| 114 |
+
};
|
| 115 |
+
|
| 116 |
+
const moodWords = {
|
| 117 |
+
happy: ['bright', 'smile', 'joy', 'laugh', 'dance', 'sing', 'cheer', 'glee'],
|
| 118 |
+
sad: ['tears', 'cry', 'pain', 'lost', 'alone', 'dark', 'shadow', 'grief'],
|
| 119 |
+
energetic: ['run', 'jump', 'power', 'strong', 'fast', 'rush', 'drive', 'force'],
|
| 120 |
+
calm: ['peace', 'quiet', 'still', 'serene', 'tranquil', 'soft', 'gentle', 'slow'],
|
| 121 |
+
reflective: ['think', 'wonder', 'question', 'search', 'find', 'understand', 'realize', 'contemplate']
|
| 122 |
+
};
|
| 123 |
+
|
| 124 |
+
const themeWords = words[theme] || words.love;
|
| 125 |
+
const moodWord = moodWords[mood] || moodWords.happy;
|
| 126 |
+
|
| 127 |
+
const lineWords = [];
|
| 128 |
+
for (let i = 0; i < 5; i++) {
|
| 129 |
+
const word = Math.random() > 0.5 ?
|
| 130 |
+
themeWords[Math.floor(Math.random() * themeWords.length)] :
|
| 131 |
+
moodWord[Math.floor(Math.random() * moodWord.length)];
|
| 132 |
+
lineWords.push(word);
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
return lineWords.join(' ');
|
| 136 |
+
};
|
| 137 |
+
|
| 138 |
+
const copyToClipboard = () => {
|
| 139 |
+
const text = generatedSong.lyrics.join('
|
| 140 |
+
');
|
| 141 |
+
navigator.clipboard.writeText(text);
|
| 142 |
+
alert('Song lyrics copied to clipboard!');
|
| 143 |
+
};
|
| 144 |
+
|
| 145 |
+
const downloadSong = () => {
|
| 146 |
+
const text = generatedSong.lyrics.join('
|
| 147 |
+
');
|
| 148 |
+
const blob = new Blob([text], { type: 'text/plain' });
|
| 149 |
+
const url = window.URL.createObjectURL(blob);
|
| 150 |
+
const a = document.createElement('a');
|
| 151 |
+
a.href = url;
|
| 152 |
+
a.download = `${generatedSong.title}.txt`;
|
| 153 |
+
document.body.appendChild(a);
|
| 154 |
+
a.click();
|
| 155 |
+
document.body.removeChild(a);
|
| 156 |
+
window.URL.revokeObjectURL(url);
|
| 157 |
+
};
|
| 158 |
+
|
| 159 |
+
return (
|
| 160 |
+
<div className="min-h-screen p-4">
|
| 161 |
+
<header className="text-center py-6">
|
| 162 |
+
<a href="https://huggingface.co/spaces/akhaliq/anycoder" className="text-white text-xl font-semibold hover:underline">
|
| 163 |
+
Built with anycoder
|
| 164 |
+
</a>
|
| 165 |
+
</header>
|
| 166 |
+
|
| 167 |
+
<main className="max-w-4xl mx-auto">
|
| 168 |
+
<div className="glass-morphism rounded-2xl p-8 shadow-2xl">
|
| 169 |
+
<h1 className="text-4xl font-bold text-white text-center mb-8">
|
| 170 |
+
<i className="fas fa-music mr-3"></i>
|
| 171 |
+
AI Song Generator
|
| 172 |
+
</h1>
|
| 173 |
+
|
| 174 |
+
<div className="mb-6">
|
| 175 |
+
<label className="block text-white text-sm font-medium mb-2">
|
| 176 |
+
Enter your song prompt:
|
| 177 |
+
</label>
|
| 178 |
+
<div className="flex gap-3">
|
| 179 |
+
<input
|
| 180 |
+
type="text"
|
| 181 |
+
value={prompt}
|
| 182 |
+
onChange={(e) => setPrompt(e.target.value)}
|
| 183 |
+
placeholder="e.g., love story in Paris, summer adventure, lost memories"
|
| 184 |
+
className="flex-1 px-4 py-3 rounded-lg bg-white bg-opacity-20 text-white placeholder-gray-300 border border-white border-opacity-30 focus:outline-none focus:ring-2 focus:ring-white focus:ring-opacity-50"
|
| 185 |
+
/>
|
| 186 |
+
<button
|
| 187 |
+
onClick={generateSong}
|
| 188 |
+
disabled={isGenerating || !prompt.trim()}
|
| 189 |
+
className="px-6 py-3 bg-white text-purple-600 font-semibold rounded-lg hover:bg-opacity-90 transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
|
| 190 |
+
>
|
| 191 |
+
{isGenerating ? (
|
| 192 |
+
<span className="flex items-center">
|
| 193 |
+
<i className="fas fa-spinner fa-spin mr-2"></i>
|
| 194 |
+
Generating...
|
| 195 |
+
</span>
|
| 196 |
+
) : (
|
| 197 |
+
<span className="flex items-center">
|
| 198 |
+
<i className="fas fa-magic mr-2"></i>
|
| 199 |
+
Generate
|
| 200 |
+
</span>
|
| 201 |
+
)}
|
| 202 |
+
</button>
|
| 203 |
+
</div>
|
| 204 |
+
</div>
|
| 205 |
+
|
| 206 |
+
{showSuccess && (
|
| 207 |
+
<div className="mb-6 p-4 bg-green-500 bg-opacity-20 border border-green-400 rounded-lg text-green-100">
|
| 208 |
+
<i className="fas fa-check-circle mr-2"></i>
|
| 209 |
+
Song generated successfully!
|
| 210 |
+
</div>
|
| 211 |
+
)}
|
| 212 |
+
|
| 213 |
+
{generatedSong && (
|
| 214 |
+
<div className="bg-white bg-opacity-10 rounded-lg p-6">
|
| 215 |
+
<div className="flex justify-between items-start mb-4">
|
| 216 |
+
<div>
|
| 217 |
+
<h2 className="text-2xl font-bold text-white">{generatedSong.title}</h2>
|
| 218 |
+
<p className="text-gray-300">by {generatedSong.artist}</p>
|
| 219 |
+
<div className="flex gap-4 mt-2">
|
| 220 |
+
<span className="text-sm text-gray-300">
|
| 221 |
+
<i className="fas fa-tag mr-1"></i>
|
| 222 |
+
Theme: {generatedSong.theme}
|
| 223 |
+
</span>
|
| 224 |
+
<span className="text-sm text-gray-300">
|
| 225 |
+
<i className="fas fa-heart mr-1"></i>
|
| 226 |
+
Mood: {generatedSong.mood}
|
| 227 |
+
</span>
|
| 228 |
+
</div>
|
| 229 |
+
</div>
|
| 230 |
+
<div className="flex gap-2">
|
| 231 |
+
<button
|
| 232 |
+
onClick={copyToClipboard}
|
| 233 |
+
className="px-3 py-1 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors"
|
| 234 |
+
>
|
| 235 |
+
<i className="fas fa-copy mr-1"></i>
|
| 236 |
+
Copy
|
| 237 |
+
</button>
|
| 238 |
+
<button
|
| 239 |
+
onClick={downloadSong}
|
| 240 |
+
className="px-3 py-1 bg-green-500 text-white rounded hover:bg-green-600 transition-colors"
|
| 241 |
+
>
|
| 242 |
+
<i className="fas fa-download mr-1"></i>
|
| 243 |
+
Download
|
| 244 |
+
</button>
|
| 245 |
+
</div>
|
| 246 |
+
</div>
|
| 247 |
+
|
| 248 |
+
<div className="song-lyrics">
|
| 249 |
+
{generatedSong.lyrics.map((line, index) => (
|
| 250 |
+
<div
|
| 251 |
+
key={index}
|
| 252 |
+
className="song-line text-white mb-2"
|
| 253 |
+
style={{ animationDelay: `${index * 0.1}s` }}
|
| 254 |
+
>
|
| 255 |
+
{line}
|
| 256 |
+
</div>
|
| 257 |
+
))}
|
| 258 |
+
</div>
|
| 259 |
+
</div>
|
| 260 |
+
)}
|
| 261 |
+
|
| 262 |
+
<div className="mt-8 text-center text-gray-300 text-sm">
|
| 263 |
+
<p>Enter any prompt to generate unique song lyrics</p>
|
| 264 |
+
<p className="mt-2">Try prompts like: "space adventure", "rainy day memories", "city lights", "ocean waves"</p>
|
| 265 |
+
</div>
|
| 266 |
+
</div>
|
| 267 |
+
</main>
|
| 268 |
+
</div>
|
| 269 |
+
);
|
| 270 |
+
};
|
| 271 |
+
|
| 272 |
+
ReactDOM.render(<SongGenerator />, document.getElementById('root'));
|
| 273 |
+
</script>
|
| 274 |
+
</body>
|
| 275 |
+
</html>
|