Abmacode12 commited on
Commit
b3a9553
·
verified ·
1 Parent(s): 9032a5d

tu vois sur la capture il fait noter micro implémenter et il ne fonctionne pas , je veux que tu le rend fonctionnel pour que je puisse parler merci

Browse files
Files changed (2) hide show
  1. index.html +39 -7
  2. script.js +7 -6
index.html CHANGED
@@ -219,15 +219,47 @@
219
  chatInput.addEventListener('keydown', (e) => {
220
  if (e.key === 'Enter') handleChatSend();
221
  });
 
 
 
 
 
 
 
 
222
 
223
- // Microphone functionality (simplified)
224
- chatMicBtn.addEventListener('click', () => {
225
- chatStatus.textContent = 'Micro: non implémenté';
226
- setTimeout(() => {
227
- chatStatus.textContent = 'Prêt';
228
- }, 2000);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  });
230
- </script>
231
  <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
232
  </body>
233
  </html>
 
219
  chatInput.addEventListener('keydown', (e) => {
220
  if (e.key === 'Enter') handleChatSend();
221
  });
222
+ // Microphone functionality using Web Speech API
223
+ chatMicBtn.addEventListener('click', async () => {
224
+ try {
225
+ const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
226
+ if (!SpeechRecognition) {
227
+ chatStatus.textContent = 'Micro: non supporté';
228
+ return;
229
+ }
230
 
231
+ const recognition = new SpeechRecognition();
232
+ recognition.lang = 'fr-FR';
233
+ recognition.interimResults = false;
234
+
235
+ recognition.onresult = (event) => {
236
+ const transcript = event.results[0][0].transcript;
237
+ chatInput.value = transcript;
238
+ handleChatSend();
239
+ };
240
+
241
+ recognition.onerror = (event) => {
242
+ console.error('Erreur de reconnaissance vocale:', event.error);
243
+ chatStatus.textContent = 'Micro: erreur';
244
+ };
245
+
246
+ chatStatus.textContent = 'Micro: écoute...';
247
+ await navigator.mediaDevices.getUserMedia({ audio: true });
248
+ recognition.start();
249
+ chatMicBtn.innerHTML = '<i data-feather="mic-off" class="w-5 h-5"></i>';
250
+ feather.replace();
251
+
252
+ recognition.onend = () => {
253
+ chatMicBtn.innerHTML = '<i data-feather="mic" class="w-5 h-5"></i>';
254
+ feather.replace();
255
+ chatStatus.textContent = 'Prêt';
256
+ };
257
+ } catch (err) {
258
+ console.error('Erreur microphone:', err);
259
+ chatStatus.textContent = 'Micro: permission refusée';
260
+ }
261
  });
262
+ </script>
263
  <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
264
  </body>
265
  </html>
script.js CHANGED
@@ -86,7 +86,7 @@ document.addEventListener('DOMContentLoaded', () => {
86
  try {
87
  const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
88
  if (!SpeechRecognition) {
89
- alert("La reconnaissance vocale n'est pas supportée sur votre navigateur");
90
  return;
91
  }
92
 
@@ -96,15 +96,16 @@ document.addEventListener('DOMContentLoaded', () => {
96
 
97
  recognition.onresult = (event) => {
98
  const transcript = event.results[0][0].transcript;
99
- input.value = transcript;
100
  handleSend();
101
  };
102
 
103
  recognition.onerror = (event) => {
104
  console.error('Erreur de reconnaissance vocale:', event.error);
105
- alert(`Erreur de reconnaissance: ${event.error}`);
106
  };
107
 
 
108
  await navigator.mediaDevices.getUserMedia({ audio: true });
109
  recognition.start();
110
  micBtn.innerHTML = '<i data-feather="mic-off" class="w-5 h-5"></i>';
@@ -113,15 +114,15 @@ document.addEventListener('DOMContentLoaded', () => {
113
  recognition.onend = () => {
114
  micBtn.innerHTML = '<i data-feather="mic" class="w-5 h-5"></i>';
115
  feather.replace();
 
116
  };
117
  } catch (err) {
118
  console.error('Erreur microphone:', err);
119
- alert('Permission microphone refusée');
120
  }
121
  });
122
  }
123
-
124
- // File attachment functionality
125
  if (paperclipBtn) {
126
  // Create hidden file input
127
  const fileInput = document.createElement('input');
 
86
  try {
87
  const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
88
  if (!SpeechRecognition) {
89
+ statusEl.textContent = "Micro: non supporté";
90
  return;
91
  }
92
 
 
96
 
97
  recognition.onresult = (event) => {
98
  const transcript = event.results[0][0].transcript;
99
+ inp.value = transcript;
100
  handleSend();
101
  };
102
 
103
  recognition.onerror = (event) => {
104
  console.error('Erreur de reconnaissance vocale:', event.error);
105
+ statusEl.textContent = "Micro: erreur - " + event.error;
106
  };
107
 
108
+ statusEl.textContent = "Micro: écoute...";
109
  await navigator.mediaDevices.getUserMedia({ audio: true });
110
  recognition.start();
111
  micBtn.innerHTML = '<i data-feather="mic-off" class="w-5 h-5"></i>';
 
114
  recognition.onend = () => {
115
  micBtn.innerHTML = '<i data-feather="mic" class="w-5 h-5"></i>';
116
  feather.replace();
117
+ statusEl.textContent = "Micro: prêt";
118
  };
119
  } catch (err) {
120
  console.error('Erreur microphone:', err);
121
+ statusEl.textContent = "Micro: permission refusée";
122
  }
123
  });
124
  }
125
+ // File attachment functionality
 
126
  if (paperclipBtn) {
127
  // Create hidden file input
128
  const fileInput = document.createElement('input');