lokesh341 commited on
Commit
69030f7
·
verified ·
1 Parent(s): b5fadc4

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +18 -33
templates/index.html CHANGED
@@ -30,37 +30,24 @@
30
  });
31
  }
32
 
33
- async function requestMicrophonePermission() {
34
- try {
35
- await navigator.mediaDevices.getUserMedia({ audio: true });
36
- console.log("Microphone access granted.");
37
- } catch (err) {
38
- alert("Microphone access denied. Please enable microphone permissions in your browser.");
39
- }
40
- }
41
-
42
  async function recordAudio() {
43
- try {
44
- const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
45
- const mediaRecorder = new MediaRecorder(stream);
46
- let audioChunks = [];
47
-
48
- return new Promise(resolve => {
49
- mediaRecorder.ondataavailable = event => {
50
- audioChunks.push(event.data);
51
- };
52
-
53
- mediaRecorder.onstop = () => {
54
- const audioBlob = new Blob(audioChunks, { type: 'audio/wav' });
55
- resolve(audioBlob);
56
- };
57
-
58
- mediaRecorder.start();
59
- setTimeout(() => mediaRecorder.stop(), 7000); // Record for 7 seconds
60
- });
61
- } catch (err) {
62
- alert("Error accessing the microphone. Please check your browser settings.");
63
- }
64
  }
65
 
66
  async function transcribeAudio(audioBlob) {
@@ -73,12 +60,10 @@
73
  });
74
 
75
  const result = await response.json();
76
- return result.text || "Error capturing speech.";
77
  }
78
 
79
  async function startInteraction() {
80
- await requestMicrophonePermission();
81
-
82
  const status = document.getElementById('status');
83
  const nameInput = document.getElementById('name');
84
  const emailInput = document.getElementById('email');
 
30
  });
31
  }
32
 
 
 
 
 
 
 
 
 
 
33
  async function recordAudio() {
34
+ const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
35
+ const mediaRecorder = new MediaRecorder(stream, { mimeType: 'audio/webm' });
36
+ let audioChunks = [];
37
+
38
+ return new Promise(resolve => {
39
+ mediaRecorder.ondataavailable = event => {
40
+ audioChunks.push(event.data);
41
+ };
42
+
43
+ mediaRecorder.onstop = () => {
44
+ const audioBlob = new Blob(audioChunks, { type: 'audio/wav' });
45
+ resolve(audioBlob);
46
+ };
47
+
48
+ mediaRecorder.start();
49
+ setTimeout(() => mediaRecorder.stop(), 5000); // ✅ Record for 5 seconds
50
+ });
 
 
 
 
51
  }
52
 
53
  async function transcribeAudio(audioBlob) {
 
60
  });
61
 
62
  const result = await response.json();
63
+ return result.text || 'Error capturing speech';
64
  }
65
 
66
  async function startInteraction() {
 
 
67
  const status = document.getElementById('status');
68
  const nameInput = document.getElementById('name');
69
  const emailInput = document.getElementById('email');