Spaces:
Running
Running
Update index.html
Browse files12345678910111213141516171819<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width" /><title>My static Space</title><link rel="stylesheet" href="style.css" /></head><body><div class="card"><h1>Welcome to your static Space!</h1><p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p><p>Also don't forget to check the<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.</p></div></body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Neural Radio Learning Interface</title><style>body {background: #000;color: #0f0;font-family: monospace;padding: 20px;margin: 0;}.container {max-width: 1000px;margin: 0 auto;}.radio-source {border: 1px solid #0f0;padding: 10px;margin: 10px 0;}.visualizer {display: grid;grid-template-columns: 1fr 1fr;gap: 10px;margin: 10px 0;}canvas {background: #111;border: 1px solid #0f0;width: 100%;height: 100px;}.controls {display: flex;gap: 10px;margin: 10px 0;}button {background: #111;color: #0f0;border: 1px solid #0f0;padding: 10px 20px;cursor: pointer;}button:hover {background: #0f0;color: #000;}.status {border: 1px solid #0f0;padding: 10px;margin: 10px 0;}.meter {width: 100%;height: 20px;background: #111;border: 1px solid #0f0;margin: 5px 0;}.meter-fill {height: 100%;background: #0f0;width: 0%;transition: width 0.3s;}.memory-bank {border: 1px solid #0f0;padding: 10px;margin: 10px 0;height: 150px;overflow-y: auto;}.neural-response {border: 1px solid #0f0;padding: 10px;margin: 10px 0;}@keyframes pulse {0% { opacity: 1; }50% { opacity: 0.5; }100% { opacity: 1; }}.recording {color: #f00;animation: pulse 1s infinite;display: none;}.active .recording {display: inline;}</style></head><body><div class="container"><h2>Neural Radio Learning Interface</h2><div class="radio-source"><h3>Radio Source</h3><audio id="radioStream" crossorigin="anonymous"><source src="http://stream.live.vc.bbcmedia.co.uk/bbc_world_service" type="audio/mpeg"></audio><div>Status: <span id="radioStatus">Not connected</span></div></div><div class="visualizer"><div><div>Input Signal</div><canvas id="inputVisual"></canvas></div><div><div>Radio Signal</div><canvas id="radioVisual"></canvas></div></div><div class="status"><div>Neural Learning Progress:</div><div class="meter"><div class="meter-fill" id="learningMeter"></div></div><div>Pattern Recognition:</div><div class="meter"><div class="meter-fill" id="patternMeter"></div></div></div><div class="controls"><button id="startBtn">Start Learning</button><button id="stopBtn">Stop</button><button id="respondBtn">Force Response</button><span class="recording">● Recording</span></div><div class="memory-bank"><h3>Memory Bank</h3><div id="memories"></div></div><div class="neural-response"><h3>Neural Response</h3><div id="response">Waiting for input...</div></div></div><script>class NeuralRadioInterface {constructor() {this.audioContext = null;this.radioAnalyser = null;this.micAnalyser = null;this.isLearning = false;this.memories = [];this.learningProgress = 0;this.patternStrength = 0;this.initializeUI();this.setupEventListeners();}initializeUI() {this.inputCanvas = document.getElementById('inputVisual');this.radioCanvas = document.getElementById('radioVisual');this.learningMeter = document.getElementById('learningMeter');this.patternMeter = document.getElementById('patternMeter');this.memoriesDiv = document.getElementById('memories');this.responseDiv = document.getElementById('response');this.radioStatus = document.getElementById('radioStatus');}setupEventListeners() {document.getElementById('startBtn').onclick = () => this.start();document.getElementById('stopBtn').onclick = () => this.stop();document.getElementById('respondBtn').onclick = () => this.generateResponse();const radio = document.getElementById('radioStream');radio.onplay = () => this.radioStatus.textContent = 'Connected';radio.onerror = () => this.radioStatus.textContent = 'Error connecting';}async start() {try {this.audioContext = new AudioContext();// Setup microphone inputconst micStream = await navigator.mediaDevices.getUserMedia({audio: true});const micSource = this.audioContext.createMediaStreamSource(micStream);this.micAnalyser = this.audioContext.createAnalyser();micSource.connect(this.micAnalyser);// Setup radio inputconst radio = document.getElementById('radioStream');radio.play();const radioSource = this.audioContext.createMediaElementSource(radio);this.radioAnalyser = this.audioContext.createAnalyser();radioSource.connect(this.radioAnalyser);radioSource.connect(this.audioContext.destination);this.isLearning = true;document.body.classList.add('active');this.learn();this.updateVisuals();this.monitorInput();} catch(err) {console.error('Error:', err);this.responseDiv.textContent = 'Error: ' + err.message;}}stop() {this.isLearning = false;document.getElementById('radioStream').pause();document.body.classList.remove('active');if(this.audioContext) {this.audioContext.close();}}learn() {if(!this.isLearning) return;// Simulate learning from radio streamif(this.learningProgress < 100) {this.learningProgress += Math.random() * 0.5;this.learningMeter.style.width = this.learningProgress + '%';}// Store simulated memoriesif(Math.random() < 0.1) {const memory = `Learned pattern ${Math.floor(Math.random() * 1000)} at ${new Date().toLocaleTimeString()}`;this.memories.unshift(memory);if(this.memories.length > 10) this.memories.pop();this.updateMemories();}setTimeout(() => this.learn(), 100);}monitorInput() {if(!this.isLearning) return;const bufferLength = this.micAnalyser.frequencyBinCount;const dataArray = new Uint8Array(bufferLength);this.micAnalyser.getByteTimeDomainData(dataArray);// Analyze input and trigger responselet sum = 0;for(let i = 0; i < bufferLength; i++) {sum += Math.abs(dataArray[i] - 128);}const inputLevel = sum / bufferLength;this.patternStrength = Math.min(100, this.patternStrength + (inputLevel > 10 ? 5 : -2));this.patternMeter.style.width = this.patternStrength + '%';if(this.patternStrength > 80) {this.generateResponse();this.patternStrength = 0;}setTimeout(() => this.monitorInput(), 100);}generateResponse() {const responses = ['Analyzing input pattern...','Pattern matched! Generating response...','Processing neural pathways...','Synthesizing radio fragments...','Generating response from learned patterns...'];this.responseDiv.textContent = responses[Math.floor(Math.random() * responses.length)];// Simulate audio responseconst oscillator = this.audioContext.createOscillator();const gain = this.audioContext.createGain();oscillator.connect(gain);gain.connect(this.audioContext.destination);oscillator.frequency.setValueAtTime(440, this.audioContext.currentTime);gain.gain.setValueAtTime(0.1, this.audioContext.currentTime);gain.gain.exponentialRampToValueAtTime(0.001, this.audioContext.currentTime + 0.5);oscillator.start();oscillator.stop(this.audioContext.currentTime + 0.5);}updateVisuals() {if(!this.isLearning) return;// Draw input visualizationif(this.micAnalyser) {const inputData = new Uint8Array(this.micAnalyser.frequencyBinCount);this.micAnalyser.getByteTimeDomainData(inputData);this.drawWaveform(this.inputCanvas, inputData, '#0f0');}// Draw radio visualizationif(this.radioAnalyser) {const radioData = new Uint8Array(this.radioAnalyser.frequencyBinCount);this.radioAnalyser.getByteTimeDomainData(radioData);this.drawWaveform(this.radioCanvas, radioData, '#f00');}requestAnimationFrame(() => this.updateVisuals());}drawWaveform(canvas, dataArray, color) {const ctx = canvas.getContext('2d');const width = canvas.width;const height = canvas.height;ctx.fillStyle = '#111';ctx.fillRect(0, 0, width, height);ctx.lineWidth = 2;ctx.strokeStyle = color;ctx.beginPath();const sliceWidth = width / dataArray.length;let x = 0;for(let i = 0; i < dataArray.length; i++) {const v = dataArray[i] / 128.0;const y = v * height/2;if(i === 0) ctx.moveTo(x, y);else ctx.lineTo(x, y);x += sliceWidth;}ctx.lineTo(width, height/2);ctx.stroke();}updateMemories() {this.memoriesDiv.innerHTML = this.memories.map(m => `<div>${m}</div>`).join('');}}window.onload = () => new NeuralRadioInterface();</script></body></html>
index.html+367-18