Spaces:
Running
Running
Download index.html from lolzxd/anycoder-8a97fb77: direct link, hf CLI and curl.
- Browser
- Download file 17.8 kB
-
https://huggingface.co/spaces/lolzxd/anycoder-8a97fb77/resolve/main/index.html
- Command line
-
hf download hf://spaces/lolzxd/anycoder-8a97fb77/index.html
-
curl -L -o index.html https://huggingface.co/spaces/lolzxd/anycoder-8a97fb77/resolve/main/index.html
17.8 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>OmniVoice | Realtime Audio Interface</title> | |
| <!-- FontAwesome for Icons --> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <!-- Google Fonts --> | |
| <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;800&family=Space+Grotesk:wght@500;700" rel="stylesheet"> | |
| <style> | |
| :root { | |
| --bg-color: #050505; | |
| --surface-color: #121212; | |
| --primary-accent: #00f2ff; | |
| --secondary-accent: #7000ff; | |
| --text-color: #e0e0e0; | |
| --glass-border: rgba(255, 255, 255, 0.1); | |
| --glass-bg: rgba(20, 20, 20, 0.6); | |
| --font-main: 'Inter', sans-serif; | |
| --font-display: 'Space Grotesk', sans-serif; | |
| } | |
| * { | |
| box-sizing: box-box; | |
| margin: 0; | |
| padding: 0; | |
| } | |
| body { | |
| background-color: var(--bg-color); | |
| color: var(--text-color); | |
| font-family: var(--font-main); | |
| height: 100vh; | |
| overflow: hidden; | |
| display: flex; | |
| flex-direction: column; | |
| background-image: | |
| radial-gradient(circle at 50% 10%, rgba(0, 242, 255, 0.15) 0%, transparent 40%), | |
| radial-gradient(circle at 80% 80%, rgba(112, 0, 255, 0.15) 0%, transparent 40%); | |
| } | |
| /* --- Header --- */ | |
| header { | |
| padding: 1.5rem 2rem; | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| z-index: 10; | |
| } | |
| .brand { | |
| font-family: var(--font-display); | |
| font-weight: 700; | |
| font-size: 1.5rem; | |
| letter-spacing: -1px; | |
| color: white; | |
| display: flex; | |
| align-items: center; | |
| gap: 10px; | |
| } | |
| .brand i { color: var(--primary-accent); } | |
| .anycoder-link { | |
| font-size: 0.85rem; | |
| background: rgba(255,255,255,0.05); | |
| padding: 8px 16px; | |
| border-radius: 20px; | |
| text-decoration: none; | |
| color: #888; | |
| border: 1px solid var(--glass-border); | |
| transition: all 0.3s ease; | |
| font-weight: 600; | |
| } | |
| .anycoder-link:hover { | |
| background: rgba(0, 242, 255, 0.1); | |
| color: var(--primary-accent); | |
| border-color: var(--primary-accent); | |
| } | |
| /* --- Main Interface --- */ | |
| main { | |
| flex: 1; | |
| position: relative; | |
| display: flex; | |
| flex-direction: column; | |
| align-items: center; | |
| justify-content: center; | |
| overflow: hidden; | |
| } | |
| /* Visualizer Container */ | |
| .visualizer-container { | |
| position: relative; | |
| width: 400px; | |
| height: 400px; | |
| margin-bottom: 2rem; | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| } | |
| canvas { | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| width: 100%; | |
| height: 100%; | |
| z-index: 2; | |
| } | |
| .core-glow { | |
| width: 100px; | |
| height: 100px; | |
| background: radial-gradient(circle, var(--primary-accent) 0%, transparent 70%); | |
| border-radius: 50%; | |
| opacity: 0.5; | |
| filter: blur(20px); | |
| animation: pulse 2s infinite ease-in-out; | |
| z-index: 1; | |
| } | |
| @keyframes pulse { | |
| 0% { transform: scale(1); opacity: 0.4; } | |
| 50% { transform: scale(1.2); opacity: 0.6; } | |
| 100% { transform: scale(1); opacity: 0.4; } | |
| } | |
| /* --- Controls & UI --- */ | |
| .ui-panel { | |
| width: 90%; | |
| max-width: 600px; | |
| background: var(--glass-bg); | |
| backdrop-filter: blur(12px); | |
| border: 1px solid var(--glass-border); | |
| border-radius: 24px; | |
| padding: 2rem; | |
| display: flex; | |
| flex-direction: column; | |
| gap: 1.5rem; | |
| box-shadow: 0 20px 50px rgba(0,0,0,0.5); | |
| z-index: 5; | |
| } | |
| .status-bar { | |
| display: flex; | |
| justify-content: space-between; | |
| font-size: 0.9rem; | |
| color: #666; | |
| text-transform: uppercase; | |
| letter-spacing: 1px; | |
| font-weight: 600; | |
| } | |
| .status-indicator { | |
| display: flex; | |
| align-items: center; | |
| gap: 8px; | |
| } | |
| .status-dot { | |
| width: 8px; | |
| height: 8px; | |
| background: #333; | |
| border-radius: 50%; | |
| transition: background 0.3s; | |
| } | |
| .status-dot.active { background: var(--primary-accent); box-shadow: 0 0 10px var(--primary-accent); } | |
| .status-dot.processing { background: var(--secondary-accent); box-shadow: 0 0 10px var(--secondary-accent); } | |
| .transcript-area { | |
| height: 120px; | |
| overflow-y: auto; | |
| font-size: 1rem; | |
| line-height: 1.6; | |
| color: #ccc; | |
| border-left: 2px solid var(--glass-border); | |
| padding-left: 1rem; | |
| } | |
| .transcript-area::-webkit-scrollbar { width: 4px; } | |
| .transcript-area::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; } | |
| .controls { | |
| display: grid; | |
| grid-template-columns: 1fr 1fr; | |
| gap: 1rem; | |
| } | |
| .btn { | |
| background: transparent; | |
| border: 1px solid var(--glass-border); | |
| color: white; | |
| padding: 1rem; | |
| border-radius: 12px; | |
| font-family: var(--font-display); | |
| font-weight: 700; | |
| cursor: pointer; | |
| transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| gap: 10px; | |
| text-transform: uppercase; | |
| font-size: 0.9rem; | |
| } | |
| .btn:hover { | |
| background: rgba(255,255,255,0.05); | |
| transform: translateY(-2px); | |
| } | |
| .btn-primary { | |
| background: var(--primary-accent); | |
| color: #000; | |
| border: none; | |
| box-shadow: 0 0 20px rgba(0, 242, 255, 0.3); | |
| } | |
| .btn-primary:hover { | |
| background: #fff; | |
| box-shadow: 0 0 30px rgba(0, 242, 255, 0.6); | |
| } | |
| .btn-danger { | |
| background: rgba(255, 50, 50, 0.1); | |
| border-color: rgba(255, 50, 50, 0.3); | |
| color: #ff5050; | |
| } | |
| .btn-danger:hover { | |
| background: rgba(255, 50, 50, 0.2); | |
| } | |
| /* --- Responsive --- */ | |
| @media (max-width: 600px) { | |
| .visualizer-container { width: 300px; height: 300px; } | |
| .ui-panel { width: 95%; padding: 1.5rem; } | |
| .controls { grid-template-columns: 1fr; } | |
| .brand { font-size: 1.2rem; } | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <header> | |
| <div class="brand"> | |
| <i class="fa-solid fa-wave-square"></i> | |
| OmniVoice | |
| </div> | |
| <a href="https://huggingface.co/spaces/akhaliq/anycoder" class="anycoder-link" target="_blank"> | |
| Built with anycoder <i class="fa-solid fa-arrow-up-right-from-square"></i> | |
| </a> | |
| </header> | |
| <main> | |
| <div class="visualizer-container"> | |
| <div class="core-glow"></div> | |
| <canvas id="visualizer"></canvas> | |
| </div> | |
| <div class="ui-panel"> | |
| <div class="status-bar"> | |
| <div class="status-indicator"> | |
| <div class="status-dot" id="mic-status"></div> | |
| <span id="status-text">SYSTEM IDLE</span> | |
| </div> | |
| <div class="volume-indicator"> | |
| <i class="fa-solid fa-volume-high"></i> | |
| </div> | |
| </div> | |
| <div class="transcript-area" id="transcript"> | |
| <span style="opacity: 0.5;">Waiting for audio input...</span> | |
| </div> | |
| <div class="controls"> | |
| <button class="btn btn-primary" id="start-btn"> | |
| <i class="fa-solid fa-microphone"></i> Listen | |
| </button> | |
| <button class="btn btn-danger" id="stop-btn"> | |
| <i class="fa-solid fa-stop"></i> Stop | |
| </button> | |
| <button class="btn" id="speak-btn"> | |
| <i class="fa-solid fa-volume-high"></i> Test Voice | |
| </button> | |
| </div> | |
| </div> | |
| </main> | |
| <script> | |
| // --- Audio Visualizer Logic --- | |
| const canvas = document.getElementById('visualizer'); | |
| const ctx = canvas.getContext('2d'); | |
| let audioContext, analyser, microphone, javascriptNode; | |
| let isListening = false; | |
| let animationId; | |
| // Resize canvas for high DPI | |
| function resizeCanvas() { | |
| const container = canvas.parentElement; | |
| canvas.width = container.clientWidth; | |
| canvas.height = container.clientHeight; | |
| } | |
| window.addEventListener('resize', resizeCanvas); | |
| resizeCanvas(); | |
| // --- Voice Interaction Logic (Speech Recognition) --- | |
| const transcriptEl = document.getElementById('transcript'); | |
| const statusText = document.getElementById('status-text'); | |
| const micStatus = document.getElementById('mic-status'); | |
| // Check browser support | |
| const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; | |
| let recognizer; | |
| if (SpeechRecognition) { | |
| recognizer = new SpeechRecognition(); | |
| recognizer.continuous = true; | |
| recognizer.intermediateResults = true; | |
| recognizer.onresult = (event) => { | |
| let interimTranscript = ''; | |
| let finalTranscript = ''; | |
| for (let i = event.resultIndex; i < event.results.length; ++i) { | |
| if (event.results[i].isFinal) { | |
| finalTranscript += event.results[i][0].transcript; | |
| processVoiceCommand(finalTranscript); | |
| } else { | |
| interimTranscript += event.results[i][0].transcript; | |
| } | |
| } | |
| if (interimTranscript) { | |
| transcriptEl.innerText = `Listening: ${interimTranscript}`; | |
| micStatus.classList.add('processing'); | |
| } | |
| if (finalTranscript) { | |
| transcriptEl.innerText = `You said: "${finalTranscript}"`; | |
| micStatus.classList.remove('processing'); | |
| micStatus.classList.add('active'); | |
| } | |
| }; | |
| recognizer.onerror = (event) => { | |
| console.error('Speech recognition error', event.error); | |
| transcriptEl.innerText = "Error: " + event.error; | |
| }; | |
| recognizer.onend = () => { | |
| micStatus.classList.remove('active'); | |
| statusText.innerText = "SYSTEM IDLE"; | |
| }; | |
| } else { | |
| transcriptEl.innerText = "Speech Recognition not supported in this browser."; | |
| } | |
| // --- Audio Context / Visualizer --- | |
| async function startVisualizer() { | |
| try { | |
| audioContext = new (window.AudioContext || window.webkitAudioContext)(); | |
| analyser = audioContext.createAnalyser(); | |
| const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); | |
| microphone = audioContext.createMediaStreamSource(stream); | |
| microphone.connect(analyser); | |
| analyser.fftSize = 2048; | |
| isListening = true; | |
| draw(); | |
| statusText.innerText = "AUDIO INPUT ACTIVE"; | |
| micStatus.classList.add('active'); | |
| transcriptEl.innerText = "Visualizing audio frequency..."; | |
| } catch (err) { | |
| console.error('The audioContext failed', err); | |
| transcriptEl.innerText = "Error: Microphone access denied or blocked."; | |
| } | |
| } | |
| function stopVisualizer() { | |
| if (audioContext) { | |
| audioContext.close(); | |
| audioContext = null; | |
| } | |
| isListening = false; | |
| if (animationId) clearTimeout(animationId); | |
| micStatus.classList.remove('active'); | |
| statusText.innerText = "SYSTEM IDLE"; | |
| // Clear canvas | |
| ctx.clearRect(0, 0, canvas.width, canvas.height); | |
| } | |
| function draw() { | |
| if (!isListening) return; | |
| const width = canvas.width; | |
| const height = canvas.height; | |
| const centerX = width / 2; | |
| const centerY = height / 2; | |
| ctx.clearRect(0, 0, width, height); | |
| const bufferLength = analyser.frequencyBinCount; | |
| const dataArray = new Uint8Array(bufferLength); | |
| analyser.getByteFrequencyData(dataArray); | |
| // Calculate average volume for pulsing effect | |
| let sum = 0; | |
| for(let i = 0; i < bufferLength; i++) { | |
| sum += dataArray[i]; | |
| } | |
| const average = sum / bufferLength; | |
| const radius = 50 + (average * 0.5); // Dynamic radius | |
| // Draw Circular Spectrum | |
| ctx.beginPath(); | |
| ctx.arc(centerX, centerY, radius, 0, 2 * Math.PI); | |
| ctx.strokeStyle = "rgba(0, 242, 255, 0.2)"; | |
| ctx.lineWidth = 2; | |
| ctx.stroke(); | |
| // Draw Frequency Bars | |
| const bars = 60; // Number of bars to draw | |
| const step = (Math.PI * 2) / bars; | |
| for (let i = 0; i < bars; i++) { | |
| // Get data from lower frequencies mostly | |
| const value = dataArray[i * 4]; | |
| const barHeight = value * 1.5; | |
| const angle = i * step; | |
| // Calculate start and end points for the bar | |
| const x1 = centerX + Math.cos(angle) * radius; | |
| const y1 = centerY + Math.sin(angle) * radius; | |
| const x2 = centerX + Math.cos(angle) * (radius + barHeight); | |
| const y2 = centerY + Math.sin(angle) * (radius + barHeight); | |
| ctx.beginPath(); | |
| ctx.moveTo(x1, y1); | |
| ctx.lineTo(x2, y2); | |
| // Gradient color based on height | |
| const hue = (i / bars) * 360; | |
| ctx.strokeStyle = `hsl(${hue}, 100%, 50%)`; | |
| ctx.lineWidth = 3; | |
| ctx.lineCap = 'round'; | |
| ctx.stroke(); | |
| } | |
| animationId = requestAnimationFrame(draw); | |
| } | |
| // --- Voice Command Simulation --- | |
| function processVoiceCommand(text) { | |
| // Simple keyword matching to simulate "AI" response | |
| text = text.toLowerCase(); | |
| let response = ""; | |
| if (text.includes("hello") || text.includes("hi")) { | |
| response = "Hello! I am ready to assist you with audio processing."; | |
| } else if (text.includes("time")) { | |
| response = "The current time is " + new Date().toLocaleTimeString(); | |
| } else if (text.includes("status")) { | |
| response = "System status: All audio inputs are functioning normally."; | |
| } else if (text.includes("stop")) { | |
| response = "Stopping audio processing..."; | |
| stopVisualizer(); | |
| if(recognizer) recognizer.stop(); | |
| } else if (text.includes("start") || text.includes("listen")) { | |
| response = "Starting audio capture mode."; | |
| startVisualizer(); | |
| if(recognizer) recognizer.start(); | |
| } else { | |
| response = "I heard: " + text + ". I am currently a client-side demo, but I can visualize your voice!"; | |
| } | |
| speak(response); | |
| } | |
| // --- Text to Speech --- | |
| function speak(text) { | |
| if ('speechSynthesis' in window) { | |
| const utterance = new SpeechSynthesisUtterance(text); | |
| utterance.voice = speechSynthesis.getVoices()[0]; // Default voice | |
| utterance.rate = 1; | |
| utterance.pitch = 1; | |
| speechSynthesis.speak(utterance); | |
| transcriptEl.innerText = `System: "${text}"`; | |
| } | |
| } | |
| // --- Button Handlers --- | |
| document.getElementById('start-btn').addEventListener('click', () => { | |
| startVisualizer(); | |
| if(recognizer) recognizer.start(); | |
| }); | |
| document.getElementById('stop-btn').addEventListener('click', () => { | |
| stopVisualizer(); | |
| if(recognizer) recognizer.stop(); | |
| }); | |
| document.getElementById('speak-btn').addEventListener('click', () => { | |
| speak("This is a test of the OmniVoice system. Audio visualization is active."); | |
| }); | |
| </script> | |
| </body> | |
| </html> |