I am developing a web app with Flask and speech recognition for audio inputs, processing and displaying an output on screen. This post has helped me organize the input of audio files, here is my flask code:
list_msg = []
@app.route("/process_wav", methods=['GET', 'POST'])
def process_wav():
if request.method == 'POST':
audio_file = request.form.get("audio-recording")
dir = 'audio/'+str(audio_file)
msg = Mensaje(dir) # this is a custom class I created for storing and processing the audio
list_msg.append((dir, msg.sentence, msg.word_counter))
return render_template("process_wav.html", list_msg=list_msg)
and my HTML code:
{% block flask %}
<h1>Prototype</h1>
<section>
<form action="" method="POST" class="form-input">
<div class="form-input">
<label for="audio-recording">Audio file (.wav)</label>
<input name="audio-recording" type="file" accept="audio/*" id="audio-recording" >
<button class="form-submit" type="submit" id="entry">Submit</button>
</div>
</form>
</section>
{% for msg in list_msg %}
<section class="form-output" id="output">
<h3>{{ msg[0] }}</h3>
<p>Result: "{{ msg[1] }}"</p>
<p>Counter: {{ msg[2] }}</p>
</section>
{% endfor %}
{% endblock flask %}
but I find it necessary to input audio directly through a microphone (and to process it the same way as with the .wav audio files). So my question is: how could I input audio through a microphone to the web page, in HTML, so that I pass it to Flask and python for processing and then displaying the output?
Being new to Flask and HTML, I find it hard to look for good references, although I found out that HTML does not offer this natively. Any advice is welcome