Skip to content Skip to sidebar Skip to footer

Record Voice With Recorder.js And Upload It To Python-flask Server, But Wav File Is Broken

I would like to realize this. A user speaks to a web browser. A web browser (Google Chrome) record user's voice as WAV file(Recorder.js) and send it to a python-flask server. I r

Solution 1:

I have this problem and it takes me 2 days for finding the solution :)) . In flask server you can use request.files['audio_data'] to get wav audio file. You can pass and use it as an audio variable too. Hope this can help you

Solution 2:

For those who are still unable to figure it out after this. Just change the

main.py

#!/usr/bin/env python# -*- coding: utf-8 -*-from flask import Flask
from flask import request
from flask import render_template
import os

app = Flask(__name__)


@app.route("/", methods=['POST', 'GET'])defindex():
    if request.method == "POST":
        f = request.files['audio_data']
        withopen('audio.wav', 'wb') as audio:
            f.save(audio)
        print('file uploaded successfully')

        return render_template('index.html', request="POST")
    else:
        return render_template("index.html")


if __name__ == "__main__":
    app.run(debug=True)

Note:

Using ":" in the filename confuses ffmpeg/ffprobe (and it does not matter whether you use "" or ' to surround the file name, and backslash escaping does not work for ":"). The only possible solution is to [temporarily] remove ":" from the filename.

Post a Comment for "Record Voice With Recorder.js And Upload It To Python-flask Server, But Wav File Is Broken"