andrymamboro commited on
Commit
f1e0052
·
verified ·
1 Parent(s): aaa0b08

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +10 -6
templates/index.html CHANGED
@@ -1,16 +1,21 @@
1
  <!DOCTYPE html>
2
  <html lang="id">
3
  <head>
 
4
  <script src="https://cdn.jsdelivr.net/npm/livekit-client/dist/livekit-client.umd.min.js"></script>
5
  <style>
6
  body { font-family: sans-serif; display: flex; justify-content: center; padding-top: 50px; background: #f4f4f9; }
7
  .card { background: white; padding: 30px; border-radius: 20px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); width: 300px; text-align: center; }
8
- button { padding: 12px 25px; border: none; border-radius: 50px; cursor: pointer; font-weight: bold; margin-top: 15px; }
 
9
  #toggle-btn { background: #007bff; color: white; }
 
10
  </style>
11
  </head>
12
  <body>
13
  <div class="card">
 
 
14
  <h1>Voice Agent</h1>
15
  <button id="toggle-btn">Hubungkan</button>
16
  <p id="status">Status: Terputus</p>
@@ -26,6 +31,7 @@
26
  room.disconnect();
27
  room = null;
28
  btn.innerText = "Hubungkan";
 
29
  status.innerText = "Status: Terputus";
30
  } else {
31
  try {
@@ -35,18 +41,16 @@
35
 
36
  room = new LivekitClient.Room();
37
 
38
- // --- BAGIAN PENTING UNTUK AUDIO ---
39
  room.on(LivekitClient.RoomEvent.TrackSubscribed, (track) => {
40
- if (track.kind === 'audio') {
41
- track.attach(); // Memaksa audio dimainkan di speaker
42
- }
43
  });
44
- // ----------------------------------
45
 
46
  await room.connect(data.server_url, data.token);
47
  await room.localParticipant.setMicrophoneEnabled(true);
48
 
49
  btn.innerText = "Berhenti";
 
50
  status.innerText = "Status: Terhubung";
51
  } catch (e) {
52
  status.innerText = "Error: " + e.message;
 
1
  <!DOCTYPE html>
2
  <html lang="id">
3
  <head>
4
+ <meta charset="UTF-8">
5
  <script src="https://cdn.jsdelivr.net/npm/livekit-client/dist/livekit-client.umd.min.js"></script>
6
  <style>
7
  body { font-family: sans-serif; display: flex; justify-content: center; padding-top: 50px; background: #f4f4f9; }
8
  .card { background: white; padding: 30px; border-radius: 20px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); width: 300px; text-align: center; }
9
+ .mic-icon { width: 60px; height: 60px; margin-bottom: 10px; fill: #007bff; }
10
+ button { padding: 12px 25px; border: none; border-radius: 50px; cursor: pointer; font-weight: bold; transition: 0.3s; width: 100%; }
11
  #toggle-btn { background: #007bff; color: white; }
12
+ #toggle-btn.active { background: #dc3545; }
13
  </style>
14
  </head>
15
  <body>
16
  <div class="card">
17
+ <svg class="mic-icon" viewBox="0 0 24 24"><path d="M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"/><path d="M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"/></svg>
18
+
19
  <h1>Voice Agent</h1>
20
  <button id="toggle-btn">Hubungkan</button>
21
  <p id="status">Status: Terputus</p>
 
31
  room.disconnect();
32
  room = null;
33
  btn.innerText = "Hubungkan";
34
+ btn.classList.remove('active');
35
  status.innerText = "Status: Terputus";
36
  } else {
37
  try {
 
41
 
42
  room = new LivekitClient.Room();
43
 
44
+ // Pastikan audio dari agen terdengar
45
  room.on(LivekitClient.RoomEvent.TrackSubscribed, (track) => {
46
+ if (track.kind === 'audio') track.attach();
 
 
47
  });
 
48
 
49
  await room.connect(data.server_url, data.token);
50
  await room.localParticipant.setMicrophoneEnabled(true);
51
 
52
  btn.innerText = "Berhenti";
53
+ btn.classList.add('active');
54
  status.innerText = "Status: Terhubung";
55
  } catch (e) {
56
  status.innerText = "Error: " + e.message;