Stream audio from pyaudio with Flask to HTML5

后端 未结 4 1552
小鲜肉
小鲜肉 2021-02-01 10:51

I want to stream the audio of my microphone (that is being recorded via pyaudio) via Flask to any client that connects.

This is where the audio comes from:



        
4条回答
  •  感动是毒
    2021-02-01 11:44

    Instead of datasize = len(samples) * channels * bitsPerSample in the header function write datasize = 2000*10**6.

    def gen_audio():
    
        CHUNK = 512
        sampleRate = 44100
        bitsPerSample = 16
        channels = 2
        wav_header = genHeader(sampleRate, bitsPerSample, channels)
    
        audio = AudioRead()
        data = audio.get_audio_chunck()
        chunck = wav_header + data
        while True:
            yield (chunck)
            data = audio.get_audio_chunck()
            chunck = data
    

提交回复
热议问题