brestok commited on
Commit
a6bf3a7
·
verified ·
1 Parent(s): a86f902

Update static/js/ws.js

Browse files
Files changed (1) hide show
  1. static/js/ws.js +2 -2
static/js/ws.js CHANGED
@@ -61,6 +61,8 @@ startRecordingButton.addEventListener('click', async () => {
61
  if (mediaRecorder && mediaRecorder.state !== 'inactive') {
62
  mediaRecorder.stop();
63
  }
 
 
64
  ws = new WebSocket(`ws://localhost:8000/ws/${uuid}`);
65
  ws.onclose = (event) => {
66
  if (mediaRecorder && mediaRecorder.state !== 'inactive') {
@@ -79,7 +81,6 @@ startRecordingButton.addEventListener('click', async () => {
79
 
80
  startRecordingButton.innerHTML = 'Stop call';
81
  try {
82
- stream = await navigator.mediaDevices.getUserMedia({audio: true, video: false});
83
  audioContext = new AudioContext();
84
  await audioContext.audioWorklet.addModule('../../../static/js/audio-processor.js');
85
  silenceDetectorNode = new AudioWorkletNode(audioContext, 'silence-detector-processor');
@@ -96,7 +97,6 @@ startRecordingButton.addEventListener('click', async () => {
96
  }
97
  };
98
  source = audioContext.createMediaStreamSource(stream);
99
- mediaRecorder = new MediaRecorder(stream);
100
  mediaRecorder.start(1000);
101
  mediaRecorder.ondataavailable = event => {
102
  currentAudioChunks.push(event.data);
 
61
  if (mediaRecorder && mediaRecorder.state !== 'inactive') {
62
  mediaRecorder.stop();
63
  }
64
+ stream = await navigator.mediaDevices.getUserMedia({audio: true, video: false});
65
+ mediaRecorder = new MediaRecorder(stream);
66
  ws = new WebSocket(`ws://localhost:8000/ws/${uuid}`);
67
  ws.onclose = (event) => {
68
  if (mediaRecorder && mediaRecorder.state !== 'inactive') {
 
81
 
82
  startRecordingButton.innerHTML = 'Stop call';
83
  try {
 
84
  audioContext = new AudioContext();
85
  await audioContext.audioWorklet.addModule('../../../static/js/audio-processor.js');
86
  silenceDetectorNode = new AudioWorkletNode(audioContext, 'silence-detector-processor');
 
97
  }
98
  };
99
  source = audioContext.createMediaStreamSource(stream);
 
100
  mediaRecorder.start(1000);
101
  mediaRecorder.ondataavailable = event => {
102
  currentAudioChunks.push(event.data);