Boobs00 commited on
Commit
a5ec1db
·
verified ·
1 Parent(s): 149ab62

Add 3 files

Browse files
Files changed (3) hide show
  1. README.md +7 -5
  2. index.html +410 -19
  3. prompts.txt +1 -0
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Code As Art Generator
3
- emoji: 🔥
4
- colorFrom: yellow
5
- colorTo: yellow
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: code-as-art-generator
3
+ emoji: 🐳
4
+ colorFrom: pink
5
+ colorTo: red
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,410 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="https://cdn.tailwindcss.com">
6
+ <title>Code as Art Generator</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <style>
9
+ @import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=VT323&display=swap');
10
+
11
+ body {
12
+ font-family: 'Space Mono', monospace;
13
+ background-color: #0f172a;
14
+ color: #e2e8f0;
15
+ overflow-x: hidden;
16
+ }
17
+
18
+ .code-art {
19
+ background-color: #1e293b;
20
+ border: 1px solid #334155;
21
+ border-radius: 0.5rem;
22
+ font-family: 'VT323', monospace;
23
+ white-space: pre;
24
+ overflow-x: auto;
25
+ tab-size: 2;
26
+ }
27
+
28
+ .pulse {
29
+ animation: pulse 2s infinite;
30
+ }
31
+
32
+ @keyframes pulse {
33
+ 0% { opacity: 0.7; }
34
+ 50% { opacity: 1; }
35
+ 100% { opacity: 0.7; }
36
+ }
37
+
38
+ .glow {
39
+ text-shadow: 0 0 5px #38bdf8, 0 0 10px #38bdf8;
40
+ }
41
+
42
+ .gradient-text {
43
+ background: linear-gradient(90deg, #38bdf8, #818cf8, #c084fc);
44
+ -webkit-background-clip: text;
45
+ background-clip: text;
46
+ color: transparent;
47
+ }
48
+
49
+ .typing-cursor {
50
+ display: inline-block;
51
+ width: 10px;
52
+ height: 24px;
53
+ background: #38bdf8;
54
+ margin-left: 5px;
55
+ animation: blink 1s step-end infinite;
56
+ }
57
+
58
+ @keyframes blink {
59
+ from, to { opacity: 1; }
60
+ 50% { opacity: 0; }
61
+ }
62
+ </style>
63
+ </head>
64
+ <body class="min-h-screen flex flex-col">
65
+ <header class="py-6 px-4 sm:px-6 lg:px-8 border-b border-slate-700">
66
+ <div class="max-w-7xl mx-auto flex justify-between items-center">
67
+ <h1 class="text-3xl font-bold gradient-text">Code as Art Generator</h1>
68
+ <div class="flex items-center space-x-4">
69
+ <button id="recordBtn" class="px-4 py-2 bg-sky-600 hover:bg-sky-700 rounded-md font-medium flex items-center">
70
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" viewBox="0 0 20 20" fill="currentColor">
71
+ <path fill-rule="evenodd" d="M7 4a3 3 0 016 0v4a3 3 0 11-6 0V4zm4 10.93A7.001 7.001 0 0017 8a1 1 0 10-2 0A5 5 0 015 8a1 1 0 00-2 0 7.001 7.001 0 006 6.93V17H6a1 1 0 100 2h8a1 1 0 100-2h-3v-2.07z" clip-rule="evenodd" />
72
+ </svg>
73
+ Start Recording
74
+ </button>
75
+ <button id="generateBtn" class="px-4 py-2 bg-purple-600 hover:bg-purple-700 rounded-md font-medium flex items-center" disabled>
76
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" viewBox="0 0 20 20" fill="currentColor">
77
+ <path fill-rule="evenodd" d="M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z" clip-rule="evenodd" />
78
+ </svg>
79
+ Generate Art
80
+ </button>
81
+ </div>
82
+ </div>
83
+ </header>
84
+
85
+ <main class="flex-grow p-4 sm:p-6 lg:p-8">
86
+ <div class="max-w-7xl mx-auto grid grid-cols-1 lg:grid-cols-2 gap-8">
87
+ <div class="space-y-6">
88
+ <div class="bg-slate-800 rounded-xl p-6 shadow-lg">
89
+ <h2 class="text-xl font-semibold mb-4 text-sky-400">Your Spoken Words</h2>
90
+ <div id="transcriptContainer" class="min-h-48 p-4 bg-slate-900 rounded-lg border border-slate-700">
91
+ <p id="transcript" class="text-slate-300">Press "Start Recording" to begin capturing your words...</p>
92
+ <div id="status" class="mt-2 text-sm text-slate-500 flex items-center">
93
+ <div id="recordingIndicator" class="hidden items-center">
94
+ <span class="relative flex h-3 w-3 mr-2">
95
+ <span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-red-500 opacity-75"></span>
96
+ <span class="relative inline-flex rounded-full h-3 w-3 bg-red-500"></span>
97
+ </span>
98
+ <span>Recording...</span>
99
+ </div>
100
+ </div>
101
+ </div>
102
+ </div>
103
+
104
+ <div class="bg-slate-800 rounded-xl p-6 shadow-lg">
105
+ <h2 class="text-xl font-semibold mb-4 text-purple-400">Code Transformation</h2>
106
+ <div class="min-h-48 p-4 bg-slate-900 rounded-lg border border-slate-700 code-art">
107
+ <div id="codePreview">
108
+ <span class="text-slate-500">// Your words will be transformed into code here</span>
109
+ <span class="typing-cursor"></span>
110
+ </div>
111
+ </div>
112
+ </div>
113
+ </div>
114
+
115
+ <div class="bg-slate-800 rounded-xl p-6 shadow-lg">
116
+ <div class="flex justify-between items-center mb-4">
117
+ <h2 class="text-xl font-semibold text-emerald-400">Generated Art</h2>
118
+ <button id="downloadBtn" class="px-3 py-1 bg-emerald-600 hover:bg-emerald-700 rounded-md text-sm" disabled>
119
+ Download Art
120
+ </button>
121
+ </div>
122
+ <div id="artContainer" class="min-h-[500px] bg-slate-900 rounded-lg border border-slate-700 flex items-center justify-center overflow-hidden relative">
123
+ <div id="artDisplay" class="w-full h-full p-4 flex items-center justify-center">
124
+ <p class="text-slate-600 text-center">Your code-generated art will appear here<br>after you click "Generate Art"</p>
125
+ </div>
126
+ <div id="loadingOverlay" class="absolute inset-0 bg-slate-900/80 flex items-center justify-center hidden">
127
+ <div class="text-center">
128
+ <div class="inline-block animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-emerald-500 mb-4"></div>
129
+ <p class="text-emerald-400 font-mono">Generating artistic code...</p>
130
+ </div>
131
+ </div>
132
+ </div>
133
+ </div>
134
+ </div>
135
+ </main>
136
+
137
+ <footer class="py-4 px-4 sm:px-6 lg:px-8 border-t border-slate-700 text-center text-sm text-slate-500">
138
+ <p>Code as Art Generator - Transform your spoken words into visual code art</p>
139
+ </footer>
140
+
141
+ <script>
142
+ document.addEventListener('DOMContentLoaded', () => {
143
+ const recordBtn = document.getElementById('recordBtn');
144
+ const generateBtn = document.getElementById('generateBtn');
145
+ const downloadBtn = document.getElementById('downloadBtn');
146
+ const transcript = document.getElementById('transcript');
147
+ const codePreview = document.getElementById('codePreview');
148
+ const artDisplay = document.getElementById('artDisplay');
149
+ const recordingIndicator = document.getElementById('recordingIndicator');
150
+ const loadingOverlay = document.getElementById('loadingOverlay');
151
+
152
+ let recognition;
153
+ let isRecording = false;
154
+ let capturedText = '';
155
+
156
+ // Check if browser supports speech recognition
157
+ if ('webkitSpeechRecognition' in window) {
158
+ recognition = new webkitSpeechRecognition();
159
+ recognition.continuous = true;
160
+ recognition.interimResults = true;
161
+
162
+ recognition.onstart = () => {
163
+ isRecording = true;
164
+ recordBtn.innerHTML = `
165
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" viewBox="0 0 20 20" fill="currentColor">
166
+ <path fill-rule="evenodd" d="M7 4a3 3 0 016 0v4a3 3 0 11-6 0V4zm4 10.93A7.001 7.001 0 0017 8a1 1 0 10-2 0A5 5 0 015 8a1 1 0 00-2 0 7.001 7.001 0 006 6.93V17H6a1 1 0 100 2h8a1 1 0 100-2h-3v-2.07z" clip-rule="evenodd" />
167
+ </svg>
168
+ Stop Recording
169
+ `;
170
+ recordBtn.classList.remove('bg-sky-600', 'hover:bg-sky-700');
171
+ recordBtn.classList.add('bg-red-600', 'hover:bg-red-700');
172
+ recordingIndicator.classList.remove('hidden');
173
+ };
174
+
175
+ recognition.onend = () => {
176
+ isRecording = false;
177
+ recordBtn.innerHTML = `
178
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" viewBox="0 0 20 20" fill="currentColor">
179
+ <path fill-rule="evenodd" d="M7 4a3 3 0 016 0v4a3 3 0 11-6 0V4zm4 10.93A7.001 7.001 0 0017 8a1 1 0 10-2 0A5 5 0 015 8a1 1 0 00-2 0 7.001 7.001 0 006 6.93V17H6a1 1 0 100 2h8a1 1 0 100-2h-3v-2.07z" clip-rule="evenodd" />
180
+ </svg>
181
+ Start Recording
182
+ `;
183
+ recordBtn.classList.remove('bg-red-600', 'hover:bg-red-700');
184
+ recordBtn.classList.add('bg-sky-600', 'hover:bg-sky-700');
185
+ recordingIndicator.classList.add('hidden');
186
+
187
+ if (capturedText.trim().length > 0) {
188
+ generateBtn.disabled = false;
189
+ }
190
+ };
191
+
192
+ recognition.onresult = (event) => {
193
+ let interimTranscript = '';
194
+ let finalTranscript = '';
195
+
196
+ for (let i = event.resultIndex; i < event.results.length; i++) {
197
+ const transcript = event.results[i][0].transcript;
198
+ if (event.results[i].isFinal) {
199
+ finalTranscript += transcript;
200
+ } else {
201
+ interimTranscript += transcript;
202
+ }
203
+ }
204
+
205
+ if (finalTranscript) {
206
+ capturedText += finalTranscript + ' ';
207
+ transcript.textContent = capturedText;
208
+ updateCodePreview(capturedText);
209
+ }
210
+
211
+ // Show interim results
212
+ if (interimTranscript) {
213
+ transcript.textContent = capturedText + interimTranscript;
214
+ }
215
+ };
216
+
217
+ recognition.onerror = (event) => {
218
+ console.error('Speech recognition error', event.error);
219
+ transcript.textContent = 'Error: ' + event.error;
220
+ isRecording = false;
221
+ recordBtn.innerHTML = `
222
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" viewBox="0 0 20 20" fill="currentColor">
223
+ <path fill-rule="evenodd" d="M7 4a3 3 0 016 0v4a3 3 0 11-6 0V4zm4 10.93A7.001 7.001 0 0017 8a1 1 0 10-2 0A5 5 0 015 8a1 1 0 00-2 0 7.001 7.001 0 006 6.93V17H6a1 1 0 100 2h8a1 1 0 100-2h-3v-2.07z" clip-rule="evenodd" />
224
+ </svg>
225
+ Start Recording
226
+ `;
227
+ recordBtn.classList.remove('bg-red-600', 'hover:bg-red-700');
228
+ recordBtn.classList.add('bg-sky-600', 'hover:bg-sky-700');
229
+ recordingIndicator.classList.add('hidden');
230
+ };
231
+ } else {
232
+ recordBtn.disabled = true;
233
+ transcript.textContent = 'Speech recognition not supported in this browser. Try Chrome or Edge.';
234
+ }
235
+
236
+ // Toggle recording
237
+ recordBtn.addEventListener('click', () => {
238
+ if (isRecording) {
239
+ recognition.stop();
240
+ } else {
241
+ capturedText = '';
242
+ transcript.textContent = 'Listening...';
243
+ recognition.start();
244
+ }
245
+ });
246
+
247
+ // Generate code art
248
+ generateBtn.addEventListener('click', () => {
249
+ if (capturedText.trim().length === 0) return;
250
+
251
+ loadingOverlay.classList.remove('hidden');
252
+ downloadBtn.disabled = true;
253
+
254
+ // Simulate processing delay
255
+ setTimeout(() => {
256
+ generateCodeArt(capturedText);
257
+ loadingOverlay.classList.add('hidden');
258
+ downloadBtn.disabled = false;
259
+ }, 2000);
260
+ });
261
+
262
+ // Download art
263
+ downloadBtn.addEventListener('click', () => {
264
+ if (!artDisplay.innerHTML.includes('canvas')) return;
265
+
266
+ const canvas = document.querySelector('canvas');
267
+ const dataURL = canvas.toDataURL('image/png');
268
+ const link = document.createElement('a');
269
+ link.download = 'code-art.png';
270
+ link.href = dataURL;
271
+ link.click();
272
+ });
273
+
274
+ // Transform text into code preview
275
+ function updateCodePreview(text) {
276
+ // Simple transformation for demo purposes
277
+ const words = text.split(' ');
278
+ let code = '';
279
+
280
+ // Create a function declaration
281
+ code += `function createArt() {\n`;
282
+ code += ` // Generated from your words\n`;
283
+ code += ` let art = [];\n\n`;
284
+
285
+ // Add words as comments or code
286
+ words.forEach((word, i) => {
287
+ if (word.trim() === '') return;
288
+
289
+ if (i % 3 === 0) {
290
+ code += ` art.push("${word.trim()}");\n`;
291
+ } else if (i % 5 === 0) {
292
+ code += ` // ${word.trim()}\n`;
293
+ } else {
294
+ code += ` art.push(${Math.floor(Math.random() * 100)}); // ${word.trim()}\n`;
295
+ }
296
+ });
297
+
298
+ code += `\n return art;\n`;
299
+ code += `}\n\n`;
300
+ code += `// Execute the art generator\n`;
301
+ code += `const masterpiece = createArt();\n`;
302
+ code += `render(masterpiece);`;
303
+
304
+ codePreview.innerHTML = syntaxHighlight(code);
305
+ }
306
+
307
+ // Simple syntax highlighting
308
+ function syntaxHighlight(code) {
309
+ // Keywords
310
+ code = code.replace(/(function|return|let|const|var|if|else|for|while|push)\b/g, '<span class="text-purple-400">$1</span>');
311
+ // Strings
312
+ code = code.replace(/(".*?"|'.*?')/g, '<span class="text-emerald-400">$1</span>');
313
+ // Numbers
314
+ code = code.replace(/\b(\d+)\b/g, '<span class="text-amber-400">$1</span>');
315
+ // Comments
316
+ code = code.replace(/\/\/.*$/gm, '<span class="text-slate-500">$&</span>');
317
+ // Function calls
318
+ code = code.replace(/(\w+)\(/g, '<span class="text-sky-400">$1</span>(');
319
+
320
+ return code;
321
+ }
322
+
323
+ // Generate visual art from code
324
+ function generateCodeArt(text) {
325
+ // Clear previous art
326
+ artDisplay.innerHTML = '';
327
+
328
+ // Create canvas
329
+ const canvas = document.createElement('canvas');
330
+ canvas.width = artDisplay.clientWidth;
331
+ canvas.height = artDisplay.clientHeight;
332
+ artDisplay.appendChild(canvas);
333
+
334
+ const ctx = canvas.getContext('2d');
335
+
336
+ // Generate art based on text
337
+ const words = text.split(' ');
338
+ const colors = ['#38bdf8', '#818cf8', '#c084fc', '#f472b6', '#f97316'];
339
+
340
+ // Background gradient
341
+ const gradient = ctx.createLinearGradient(0, 0, canvas.width, canvas.height);
342
+ gradient.addColorStop(0, '#0f172a');
343
+ gradient.addColorStop(1, '#1e293b');
344
+ ctx.fillStyle = gradient;
345
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
346
+
347
+ // Draw elements based on words
348
+ words.forEach((word, i) => {
349
+ if (word.trim() === '') return;
350
+
351
+ const x = Math.random() * canvas.width;
352
+ const y = Math.random() * canvas.height;
353
+ const size = 10 + (word.length * 2);
354
+ const color = colors[i % colors.length];
355
+ const rotation = Math.random() * 360;
356
+
357
+ ctx.save();
358
+ ctx.translate(x, y);
359
+ ctx.rotate(rotation * Math.PI / 180);
360
+
361
+ // Alternate between shapes
362
+ if (i % 3 === 0) {
363
+ // Rectangle
364
+ ctx.fillStyle = color;
365
+ ctx.globalAlpha = 0.7;
366
+ ctx.fillRect(-size/2, -size/2, size, size);
367
+ } else if (i % 5 === 0) {
368
+ // Circle
369
+ ctx.beginPath();
370
+ ctx.fillStyle = color;
371
+ ctx.globalAlpha = 0.5;
372
+ ctx.arc(0, 0, size/2, 0, Math.PI * 2);
373
+ ctx.fill();
374
+ } else {
375
+ // Text
376
+ ctx.font = `${size/2}px 'VT323', monospace`;
377
+ ctx.fillStyle = color;
378
+ ctx.globalAlpha = 0.9;
379
+ ctx.fillText(word, 0, 0);
380
+ }
381
+
382
+ ctx.restore();
383
+ });
384
+
385
+ // Add connecting lines
386
+ ctx.strokeStyle = 'rgba(124, 58, 237, 0.3)';
387
+ ctx.lineWidth = 1;
388
+
389
+ for (let i = 0; i < words.length - 1; i++) {
390
+ if (i % 2 === 0 && i < words.length - 2) {
391
+ const x1 = (i / words.length) * canvas.width + (Math.random() * 50 - 25);
392
+ const y1 = (Math.sin(i) * canvas.height/3) + canvas.height/2 + (Math.random() * 50 - 25);
393
+ const x2 = ((i+2) / words.length) * canvas.width + (Math.random() * 50 - 25);
394
+ const y2 = (Math.sin(i+2) * canvas.height/3) + canvas.height/2 + (Math.random() * 50 - 25);
395
+
396
+ ctx.beginPath();
397
+ ctx.moveTo(x1, y1);
398
+ ctx.bezierCurveTo(
399
+ x1 + 100, y1 + 50,
400
+ x2 - 100, y2 - 50,
401
+ x2, y2
402
+ );
403
+ ctx.stroke();
404
+ }
405
+ }
406
+ }
407
+ });
408
+ </script>
409
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Boobs00/code-as-art-generator" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
410
+ </html>
prompts.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ Never had a website idea. Like, if you were going to put something onto a website and like, instead of writing a book you've made a website instead, if I had to do it, I would create the content, is it at generating lives? Yeah, I've been doing that. Just uh, I'm an artist and now lately. I've been messing with code as art. And right now it's just recording all the words that we're saying are being reported and made into text, which is then generated into code and it'll end up as well. I promise of this ai that we'll make it into a website.It's generates the website.So from whatever we've said part, we just go ahead and hit