Spaces:
Runtime error
Runtime error
Update templates/index.html
Browse files- templates/index.html +5 -13
templates/index.html
CHANGED
@@ -46,18 +46,7 @@
|
|
46 |
};
|
47 |
|
48 |
mediaRecorder.start();
|
49 |
-
|
50 |
-
// Wait for user to stop speaking (detect silence)
|
51 |
-
let silenceTimeout = setTimeout(() => {
|
52 |
-
mediaRecorder.stop();
|
53 |
-
}, 5000); // Max 5 seconds recording
|
54 |
-
|
55 |
-
navigator.mediaDevices.getUserMedia({ audio: true }).then(stream => {
|
56 |
-
stream.getTracks().forEach(track => {
|
57 |
-
track.onmute = () => clearTimeout(silenceTimeout);
|
58 |
-
track.onunmute = () => silenceTimeout = setTimeout(() => mediaRecorder.stop(), 2000);
|
59 |
-
});
|
60 |
-
});
|
61 |
});
|
62 |
}
|
63 |
|
@@ -71,7 +60,10 @@
|
|
71 |
});
|
72 |
|
73 |
const result = await response.json();
|
74 |
-
|
|
|
|
|
|
|
75 |
}
|
76 |
|
77 |
async function startInteraction() {
|
|
|
46 |
};
|
47 |
|
48 |
mediaRecorder.start();
|
49 |
+
setTimeout(() => mediaRecorder.stop(), 5000); // Record for 5 seconds
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
});
|
51 |
}
|
52 |
|
|
|
60 |
});
|
61 |
|
62 |
const result = await response.json();
|
63 |
+
if (result.error) {
|
64 |
+
return "Error: " + result.error;
|
65 |
+
}
|
66 |
+
return result.text;
|
67 |
}
|
68 |
|
69 |
async function startInteraction() {
|