Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

546
Views
Guardar audio desde el navegador al backend (Django)

Revisé muchas respuestas que ya se han dado pero que no entendí.

Tarea: debo obtener el audio del usuario, que debe durar menos de un minuto, y luego guardarlo en el backend y enviarlo a la API de reconocimiento de voz de Google para obtener el texto.

Intenté grabar en el navegador usando la API de MediaRecorder usando esta demostración aquí https://mido22.github.io/MediaRecorder-sample/ .

Quiero que el audio grabado se guarde en mi backend de Django para que podamos realizar un procesamiento posterior en él.

EDIT1: código de Github para la API de la grabadora de medios

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

POST el Blob resultante en la función makeLink al servidor como propiedad de un objeto FormData

 function makeLink() { let blob = new Blob(chunks, {type: media.type }); let fd = new FormData; fd.append("audioRecording", blob); let request = new XMLHttpRequest(); request.open("POST", "/path/to/server", true); request.onload = function() { // do stuff } request.onerror = function() { // handle error } request.send(fd); }

 function makeLink() { let blob = new Blob(chunks, {type: media.type }); let fd = new FormData; fd.append("audioRecording", blob); fetch("/path/to/server", {method:"POST", body:fd}) .then(response => response.ok) .then(res => console.log(res)) .catch(err => console.error(err)); }
about 4 years ago · Santiago Trujillo Report

0

He creado un proyecto simple aquí: https://github.com/Keramatfar/django_sound_file

Para el backend, uso la siguiente función:

 def main(request): if request.method == "POST": audio_data = request.FILES.get('data') path = default_storage.save('file' + '.wav', ContentFile(audio_data.read())) return render(request, 'web-recorder.html') else: return render(request, 'web-recorder.html')
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!