shahid202 commited on
Commit
0659f06
·
verified ·
1 Parent(s): f7308d4

Update static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +43 -0
static/index.html CHANGED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <style>
5
+ body { background: #050505; color: #00ff41; font-family: 'Courier New', monospace; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; }
6
+ #log { border: 1px solid #00ff41; width: 80%; height: 300px; overflow-y: scroll; padding: 10px; margin-bottom: 20px; }
7
+ button { background: #000; color: #00ff41; border: 1px solid #00ff41; padding: 15px; cursor: pointer; }
8
+ </style>
9
+ </head>
10
+ <body>
11
+ <h2>JARVIS SYSTEM ONLINE</h2>
12
+ <div id="log"></div>
13
+ <input type="text" id="input" placeholder="Type command..." style="background:#000; color:#00ff41; border: 1px solid #00ff41; padding: 10px; width: 80%;">
14
+ <button onclick="send()">SEND COMMAND</button>
15
+
16
+ <script>
17
+ const audioCtx = new (window.AudioContext || window.webkitAudioContext)({sampleRate: 24000});
18
+ const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
19
+ const ws = new WebSocket(`${protocol}//${window.location.host}/ws/chat`);
20
+ ws.binaryType = 'arraybuffer';
21
+ let nextStartTime = 0;
22
+
23
+ ws.onmessage = async (event) => {
24
+ const data = new Float32Array(event.data);
25
+ const buffer = audioCtx.createBuffer(1, data.length, 24000);
26
+ buffer.copyToChannel(data, 0);
27
+ const source = audioCtx.createBufferSource();
28
+ source.buffer = buffer;
29
+ source.connect(audioCtx.destination);
30
+ const start = Math.max(audioCtx.currentTime, nextStartTime);
31
+ source.start(start);
32
+ nextStartTime = start + buffer.duration;
33
+ document.getElementById('log').innerHTML += "<div>[SYSTEM]: Generating Audio...</div>";
34
+ };
35
+
36
+ function send() {
37
+ const msg = document.getElementById('input').value;
38
+ ws.send(msg);
39
+ document.getElementById('log').innerHTML += "<div>[USER]: " + msg + "</div>";
40
+ }
41
+ </script>
42
+ </body>
43
+ </html>