tonyassi commited on
Commit
01160c7
·
verified ·
1 Parent(s): 30410b0

Upload templates_index3.html

Browse files
Files changed (1) hide show
  1. templates/templates_index3.html +304 -0
templates/templates_index3.html ADDED
@@ -0,0 +1,304 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>Flask Chat App</title>
5
+ <style>
6
+ body, html {
7
+ margin: 0;
8
+ padding: 0;
9
+ width: 100%;
10
+ height: 100%;
11
+ background-color: #fddde6;
12
+ display: flex;
13
+ flex-direction: column;
14
+ align-items: center;
15
+ justify-content: flex-start;
16
+ font-family: Arial, sans-serif;
17
+ font-weight: 300;
18
+ }
19
+ #video-container {
20
+ padding-top: 2%;
21
+ width: auto;
22
+ height: auto;
23
+ }
24
+ #video-container video {
25
+ width: auto;
26
+ height: 35vh;
27
+ }
28
+
29
+ #chat-container, #input-container {
30
+ width: 90%;
31
+ max-width: 1200px;
32
+ margin: 10px;
33
+ }
34
+ #chat-container {
35
+ flex: 1;
36
+ overflow-y: auto;
37
+ background-color: white;
38
+ border-radius: 10px;
39
+ padding: 2%;
40
+ box-shadow: 0 0 10px rgba(0,0,0,0.1);
41
+ display: flex;
42
+ flex-direction: column;
43
+ }
44
+ .chat-bubble {
45
+ margin: 5px;
46
+ padding: 10px;
47
+ border-radius: 10px;
48
+ max-width: 80%;
49
+ }
50
+ .user-bubble {
51
+ align-self: flex-end;
52
+ background-color: #e0e0e0;
53
+ }
54
+ .bot-bubble {
55
+ align-self: flex-start;
56
+ background-color: #ffb6c1;
57
+ color: white;
58
+ }
59
+ #input-container {
60
+ display: flex;
61
+ align-items: center;
62
+ padding-bottom: 2%;
63
+ }
64
+ #input-container input {
65
+ flex: 1;
66
+ padding: 10px;
67
+ border: 1px solid #ccc;
68
+ border-radius: 5px;
69
+ height: 2.5vh;
70
+ }
71
+
72
+ #input-container button {
73
+ padding: 0;
74
+ margin-left: 10px;
75
+ border: none;
76
+ background-color: transparent;
77
+ cursor: pointer;
78
+ height: calc(2.5vh + 15px);
79
+ display: flex;
80
+ align-items: center;
81
+ justify-content: center;
82
+ }
83
+
84
+ #input-container button img {
85
+ height: 100%;
86
+ width: auto;
87
+ }
88
+
89
+ /* New styles for the menu */
90
+ .menu {
91
+ position: absolute;
92
+ top: 10px;
93
+ left: 10px;
94
+ z-index: 1000;
95
+ }
96
+
97
+ .menu .hamburger {
98
+ display: block;
99
+ cursor: pointer;
100
+ width: 30px;
101
+ height: 30px;
102
+ }
103
+
104
+ .menu .hamburger div {
105
+ width: 100%;
106
+ height: 4px;
107
+ background-color: black;
108
+ margin: 5px 0;
109
+ transition: all 0.3s;
110
+ }
111
+
112
+ .menu-content {
113
+ display: none;
114
+ position: absolute;
115
+ top: 40px;
116
+ left: 0;
117
+ background-color: white;
118
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
119
+ border-radius: 5px;
120
+ overflow: hidden;
121
+ width: 150px;
122
+ }
123
+
124
+ .menu-content a {
125
+ display: block;
126
+ padding: 5px 10px;
127
+ color: black;
128
+ text-decoration: none;
129
+ transition: background-color 0.3s;
130
+ }
131
+
132
+ .menu-content a:hover {
133
+ background-color: #f0f0f0;
134
+ }
135
+
136
+ #audio-recording-container {
137
+ display: none;
138
+ align-items: center;
139
+ justify-content: center;
140
+ width: 90%;
141
+ max-width: 1200px;
142
+ margin: 10px;
143
+ padding-top: 7%;
144
+ }
145
+
146
+ #audio-record-button {
147
+ width: 150px;
148
+ height: 150px;
149
+ background-color: #e1fceb;
150
+ color: black;
151
+ border-radius: 50%;
152
+ cursor: pointer;
153
+ display: flex;
154
+ align-items: center;
155
+ justify-content: center;
156
+ font-size: 16px;
157
+ font-weight: bold;
158
+ border: 5px solid white;
159
+ box-shadow: 0 0 20px 5px rgba(255, 255, 255, 0.8);
160
+
161
+ }
162
+ #audio-record-button.recording {
163
+ background-color: #f44336;
164
+ box-shadow: 0 0 20px 10px rgba(255, 255, 255, 1);
165
+ }
166
+ </style>
167
+ </head>
168
+ <body>
169
+ <div class="menu">
170
+ <div class="hamburger" onclick="toggleMenu()">
171
+ <div></div>
172
+ <div></div>
173
+ <div></div>
174
+ </div>
175
+ <div class="menu-content" id="menu-content">
176
+ <a href="#" onclick="showTextChat()">Text Chat</a>
177
+ <a href="#" onclick="showAudioChat()">Audio Chat</a>
178
+ <a href="#">Settings</a>
179
+ </div>
180
+ </div>
181
+
182
+ <div id="video-container">
183
+ <video src="https://cdn-lfs-us-1.huggingface.co/repos/61/c4/61c4367976a0aef9d7ba3bb5650c0efc98207f17f6d3a4a71d3d7f9b265578a3/159ba43daee671b34e01d65c7b753bac22c139f653eeeaf3c6da1220b7c9ecf0?response-content-disposition=inline%3B+filename*%3DUTF-8%27%27lucy-vid-1.mp4%3B+filename%3D%22lucy-vid-1.mp4%22%3B&response-content-type=video%2Fmp4&Expires=1723399367&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTcyMzM5OTM2N319LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2RuLWxmcy11cy0xLmh1Z2dpbmdmYWNlLmNvL3JlcG9zLzYxL2M0LzYxYzQzNjc5NzZhMGFlZjlkN2JhM2JiNTY1MGMwZWZjOTgyMDdmMTdmNmQzYTRhNzFkM2Q3ZjliMjY1NTc4YTMvMTU5YmE0M2RhZWU2NzFiMzRlMDFkNjVjN2I3NTNiYWMyMmMxMzlmNjUzZWVlYWYzYzZkYTEyMjBiN2M5ZWNmMD9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSomcmVzcG9uc2UtY29udGVudC10eXBlPSoifV19&Signature=PqaCnSHH9xJ%7E-TgkrZ0mH96bbPf7IJBnJWZHYqNU4hFKRa0N9ibxdFm5HAWySMOCNrVGMVTzGjTWAX8gmcQNfHtDRL%7EfX%7El8zZpP2tErEm4Q8AmjhmYTWDATBG0pXCJQtaSjesQK3q9RQ2yMEiJDC9VWa2OhiBJW25LnL%7EAqPLiNpX8sRs07boI677XDmgRL7qOWEOtrBqvJn5ZCgaLybRhu8ySKvCSUwWtEv1gWQ-XT28NZ6h4nDy5yEqkMw9yVcJs4U8JUCHL2cxgHxGK22FK1o3EMiZ3LvMjzWZNVlLUbJJVFO4XDNqMsumV6oLEmWNZtILyEaD6FfGw6grLJNw__&Key-Pair-Id=K24J24Z295AEI9" playsinline autoplay loop muted></video>
184
+ </div>
185
+ <div id="chat-container"></div>
186
+ <div id="input-container">
187
+ <input type="text" id="user-input" placeholder="Type your message...">
188
+ <button onclick="sendMessage()">
189
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/648a824a8ca6cf9857d1349c/aJO71FyXi40-U_AOjwPmt.png" alt="Send">
190
+ </button>
191
+ </div>
192
+
193
+ <div id="audio-recording-container">
194
+ <button id="audio-record-button">START</button>
195
+ </div>
196
+
197
+ <script>
198
+ function sendMessage() {
199
+ var userInput = document.getElementById('user-input').value;
200
+ if (userInput.trim() === "") return;
201
+
202
+ var chatContainer = document.getElementById('chat-container');
203
+
204
+ // Create user bubble
205
+ var userBubble = document.createElement('div');
206
+ userBubble.textContent = userInput;
207
+ userBubble.className = 'chat-bubble user-bubble';
208
+ chatContainer.appendChild(userBubble);
209
+
210
+ // Create bot bubble with "..." text
211
+ var botBubble = document.createElement('div');
212
+ botBubble.textContent = ". . .";
213
+ botBubble.className = 'chat-bubble bot-bubble';
214
+ chatContainer.appendChild(botBubble);
215
+
216
+ chatContainer.scrollTop = chatContainer.scrollHeight;
217
+ document.getElementById('user-input').value = '';
218
+
219
+ var xhr = new XMLHttpRequest();
220
+ xhr.open('POST', '/send_message', true);
221
+ xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
222
+ xhr.onload = function () {
223
+ if (xhr.status === 200) {
224
+ var response = JSON.parse(xhr.responseText);
225
+
226
+ // Update bot bubble with the actual response
227
+ botBubble.textContent = response.response;
228
+ chatContainer.scrollTop = chatContainer.scrollHeight;
229
+ }
230
+ };
231
+ xhr.send('user_input=' + encodeURIComponent(userInput));
232
+ }
233
+
234
+
235
+ document.getElementById('user-input').addEventListener('keydown', function(event) {
236
+ if (event.key === 'Enter') {
237
+ sendMessage();
238
+ }
239
+ });
240
+
241
+ function toggleMenu() {
242
+ var menuContent = document.getElementById('menu-content');
243
+ if (menuContent.style.display === 'block') {
244
+ menuContent.style.display = 'none';
245
+ } else {
246
+ menuContent.style.display = 'block';
247
+ }
248
+ }
249
+
250
+ function showTextChat() {
251
+ document.getElementById('chat-container').style.display = 'flex';
252
+ document.getElementById('input-container').style.display = 'flex';
253
+ document.getElementById('audio-recording-container').style.display = 'none';
254
+ document.getElementById('menu-content').style.display = 'none';
255
+ }
256
+
257
+ function showAudioChat() {
258
+ document.getElementById('chat-container').style.display = 'none';
259
+ document.getElementById('input-container').style.display = 'none';
260
+ document.getElementById('audio-recording-container').style.display = 'flex';
261
+ document.getElementById('menu-content').style.display = 'none';
262
+ }
263
+
264
+ let mediaRecorder;
265
+ let audioChunks = [];
266
+ const recordButton = document.getElementById('audio-record-button');
267
+ let isRecording = false;
268
+ recordButton.addEventListener('click', () => {
269
+ if (isRecording) {
270
+ mediaRecorder.stop();
271
+ recordButton.textContent = 'START';
272
+ recordButton.classList.remove('recording');
273
+ } else {
274
+ navigator.mediaDevices.getUserMedia({ audio: true })
275
+ .then(stream => {
276
+ mediaRecorder = new MediaRecorder(stream);
277
+ mediaRecorder.start();
278
+ mediaRecorder.addEventListener('dataavailable', event => {
279
+ audioChunks.push(event.data);
280
+ });
281
+ mediaRecorder.addEventListener('stop', () => {
282
+ const audioBlob = new Blob(audioChunks, { type: 'audio/wav' });
283
+ const formData = new FormData();
284
+ formData.append('file', audioBlob, 'audio.wav');
285
+ fetch('/upload', {
286
+ method: 'POST',
287
+ body: formData
288
+ })
289
+ .then(response => response.json())
290
+ .catch(error => {
291
+ console.error('Error:', error);
292
+ });
293
+ audioChunks = [];
294
+ });
295
+ recordButton.textContent = 'STOP';
296
+ recordButton.classList.add('recording');
297
+ });
298
+ }
299
+ isRecording = !isRecording;
300
+ });
301
+
302
+ </script>
303
+ </body>
304
+ </html>