我目前正在努力使用 Python 和 Flask 实现一个简单的实时流媒体 Web 应用程序。似乎我无法将实时录制的音频从服务器麦克风输入流式传输到网页。
服务器.py
from flask import Flask, render_template, Response
import cv2
import framework
import pyaudio
import audio_processing as audioRec
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 44100
CHUNK = 1024
audio = pyaudio.PyAudio()
app = Flask(__name__)
@app.route('/')
def index():
"""Video streaming home page."""
return render_template('index.html')
# Stream routing
@app.route('/video_feed')
def video_feed():
"""Video streaming route. Put this in the src attribute of an img tag."""
return Response(generateVideo(),
mimetype='multipart/x-mixed-replace; boundary=frame')
@app.route("/audio_feed")
def audio_feed():
"""Audio streaming route. …Run Code Online (Sandbox Code Playgroud)