Spaces:
Running
Running
Update index.js
Browse files
index.js
CHANGED
|
@@ -284,20 +284,20 @@ async function initMedia() {
|
|
| 284 |
recordButton.disabled = true;
|
| 285 |
|
| 286 |
try {
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
const stream = await navigator.mediaDevices.getUserMedia({
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
});
|
| 293 |
-
webcamElement.srcObject =
|
| 294 |
statusMessageElement.style.display = 'none';
|
| 295 |
webcamElement.style.display = 'block';
|
| 296 |
|
| 297 |
await loadLlm();
|
| 298 |
|
| 299 |
// Set up MediaRecorder for audio
|
| 300 |
-
mediaRecorder = new MediaRecorder(
|
| 301 |
mediaRecorder.ondataavailable = (event) => {
|
| 302 |
console.log('ondataavailable event: ', event);
|
| 303 |
audioChunks.push(event.data);
|
|
@@ -307,7 +307,7 @@ async function initMedia() {
|
|
| 307 |
console.log('Chunks: ', audioChunks);
|
| 308 |
const blob = new Blob(audioChunks, {type: 'audio/webm'});
|
| 309 |
console.log('Blob: ', blob);
|
| 310 |
-
|
| 311 |
audioUrl = window.URL.createObjectURL(blob);
|
| 312 |
console.log('url: ', audioUrl);
|
| 313 |
// HACK FOR TESTING
|
|
|
|
| 284 |
recordButton.disabled = true;
|
| 285 |
|
| 286 |
try {
|
| 287 |
+
const videoStream = await navigator.mediaDevices.getUserMedia({video: true});
|
| 288 |
+
const audioStream = await navigator.mediaDevices.getUserMedia({audio: true});
|
| 289 |
+
//const stream = await navigator.mediaDevices.getUserMedia({
|
| 290 |
+
// video: true,
|
| 291 |
+
// audio: true,
|
| 292 |
+
//});
|
| 293 |
+
webcamElement.srcObject = videoStream;
|
| 294 |
statusMessageElement.style.display = 'none';
|
| 295 |
webcamElement.style.display = 'block';
|
| 296 |
|
| 297 |
await loadLlm();
|
| 298 |
|
| 299 |
// Set up MediaRecorder for audio
|
| 300 |
+
mediaRecorder = new MediaRecorder(audioStream);
|
| 301 |
mediaRecorder.ondataavailable = (event) => {
|
| 302 |
console.log('ondataavailable event: ', event);
|
| 303 |
audioChunks.push(event.data);
|
|
|
|
| 307 |
console.log('Chunks: ', audioChunks);
|
| 308 |
const blob = new Blob(audioChunks, {type: 'audio/webm'});
|
| 309 |
console.log('Blob: ', blob);
|
| 310 |
+
if (audioUrl) window.URL.revokeObjectURL(audioUrl);
|
| 311 |
audioUrl = window.URL.createObjectURL(blob);
|
| 312 |
console.log('url: ', audioUrl);
|
| 313 |
// HACK FOR TESTING
|