我正在开发一个带有Flask和speech recognition的web应用程序,用于音频输入、处理和在屏幕上显示输出This post帮助我组织音频文件的输入,以下是我的代码:
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)
和我的HTML代码:
{% 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 %}
但我发现有必要通过麦克风直接输入音频(并以与.wav音频文件相同的方式处理)。所以我的问题是:如何通过麦克风将音频以HTML格式输入到网页,然后将其传递给Flask和python进行处理,然后显示输出
由于对Flask和HTML不熟悉,我发现很难找到好的参考资料,尽管我发现HTML本身并没有提供这一功能。欢迎任何意见
函数使用flask实时传输音频。事实上我没有得到你真正想要做的。但通过这种方式,您可以在flask中传输音频
我希望这会有帮助github_link
相关问题 更多 >
编程相关推荐