LeireTedCas commited on
Commit
9564836
1 Parent(s): fb57d7d

Update static/js/app.js

Browse files
Files changed (1) hide show
  1. static/js/app.js +14 -13
static/js/app.js CHANGED
@@ -111,9 +111,10 @@ function stopRecording() {
111
  gumStream.getAudioTracks()[0].stop();
112
 
113
  //create the wav blob and pass it on to createDownloadLink
114
- //rec.exportWAV(createDownloadLink);
115
  // Exportar los datos de audio como un Blob una vez que la grabaci n haya finalizado
116
- rec.exportWAV(function (blob) {
 
117
  // La funci n de devoluci n de llamada se llama con el Blob que contiene los datos de audio en formato WAV
118
  // Puedes utilizar este Blob como desees, por ejemplo, crear una URL para descargarlo
119
  var url = URL.createObjectURL(blob);
@@ -166,30 +167,30 @@ function stopRecording() {
166
  xhr.onreadystatechange = function () {
167
  if (xhr.readyState === 4 && xhr.status === 200) {
168
  // Manejar la respuesta del servidor
169
- console.log("Respuesta del servidor:", xhr.responseText);
170
  ////////////////////////////////////////////////////////
171
  // Muestra el resultado del reconocimiento en el cuadro de texto
172
  //document.getElementById("responseTextBox").value = xhr.responseText;
173
  // Buscar el contenido dentro de las etiquetas <p></p>
174
- //var parser = new DOMParser();
175
- //var responseHTML = parser.parseFromString(xhr.responseText, 'text/html');
176
- /*var paragraphContent = responseHTML.querySelector('p').textContent;*/
177
 
178
  // Muestra el resultado del reconocimiento en el cuadro de texto
179
  //document.getElementById("responseTextBox").value = paragraphContent;
180
  // Muestra el resultado del reconocimiento como texto plano
181
- //var textElement = document.getElementById("textElement"); // Reemplaza "textElement" con el ID adecuado
182
- //textElement.textContent = paragraphContent;
183
  //////////////////////////////////////////////////////////
184
  }
185
  };
186
- xhr.send(formData);
187
 
188
  //////////////////////////////////////////
189
 
190
 
191
  // 4. This will be called after the response is received
192
- xhr.onload = function () {
193
  if (xhr.status != 200) {
194
  // analyze HTTP status of the response
195
  alert(`Error ${xhr.status}: ${xhr.statusText}`);
@@ -198,7 +199,7 @@ function stopRecording() {
198
  $('body').html(xhr.response)
199
  }
200
  };
201
-
202
 
203
 
204
 
@@ -208,8 +209,8 @@ function stopRecording() {
208
 
209
 
210
  //});
211
- //li.appendChild(document.createTextNode(" "))//add a space in between
212
- //li.appendChild(upload)//add the upload link to li
213
 
214
  //add the li element to the ol
215
  recordingsList.appendChild(li);
 
111
  gumStream.getAudioTracks()[0].stop();
112
 
113
  //create the wav blob and pass it on to createDownloadLink
114
+ rec.exportWAV(createDownloadLink);
115
  // Exportar los datos de audio como un Blob una vez que la grabaci n haya finalizado
116
+ //rec.exportWAV(function (blob) {
117
+ function createDownloadLink (blob) {
118
  // La funci n de devoluci n de llamada se llama con el Blob que contiene los datos de audio en formato WAV
119
  // Puedes utilizar este Blob como desees, por ejemplo, crear una URL para descargarlo
120
  var url = URL.createObjectURL(blob);
 
167
  xhr.onreadystatechange = function () {
168
  if (xhr.readyState === 4 && xhr.status === 200) {
169
  // Manejar la respuesta del servidor
170
+ //console.log("Respuesta del servidor:", xhr.responseText);
171
  ////////////////////////////////////////////////////////
172
  // Muestra el resultado del reconocimiento en el cuadro de texto
173
  //document.getElementById("responseTextBox").value = xhr.responseText;
174
  // Buscar el contenido dentro de las etiquetas <p></p>
175
+ var parser = new DOMParser();
176
+ var responseHTML = parser.parseFromString(xhr.responseText, 'text/html');
177
+ var paragraphContent = responseHTML.querySelector('p').textContent;
178
 
179
  // Muestra el resultado del reconocimiento en el cuadro de texto
180
  //document.getElementById("responseTextBox").value = paragraphContent;
181
  // Muestra el resultado del reconocimiento como texto plano
182
+ var textElement = document.getElementById("textElement"); // Reemplaza "textElement" con el ID adecuado
183
+ textElement.textContent = paragraphContent;
184
  //////////////////////////////////////////////////////////
185
  }
186
  };
187
+ //xhr.send(formData);
188
 
189
  //////////////////////////////////////////
190
 
191
 
192
  // 4. This will be called after the response is received
193
+ /*xhr.onload = function () {
194
  if (xhr.status != 200) {
195
  // analyze HTTP status of the response
196
  alert(`Error ${xhr.status}: ${xhr.statusText}`);
 
199
  $('body').html(xhr.response)
200
  }
201
  };
202
+ */
203
 
204
 
205
 
 
209
 
210
 
211
  //});
212
+ li.appendChild(document.createTextNode(" "))//add a space in between
213
+ li.appendChild(upload)//add the upload link to li
214
 
215
  //add the li element to the ol
216
  recordingsList.appendChild(li);