Get an audio sample as float number from pyaudio-stream

后端 未结 1 348
萌比男神i
萌比男神i 2021-01-18 14:12

As I am currently about to build a device based on a Raspberry Pi for measuring some stuff from noise recorded with a sound card (e.g. variance), and trying to do this withi

1条回答
  •  情歌与酒
    2021-01-18 14:23

    Try use "numpy.fromstring" function to replace "struct.unpack":

    import numpy
    stream = p.open(format=FORMAT,channels=1,rate=SAMPLEFREQ,input=True,frames_per_buffer=FRAMESIZE)
    data = stream.read(NOFFRAMES*FRAMESIZE)
    decoded = numpy.fromstring(data, 'Float32');
    

    let me know if this works for you

    0 讨论(0)
提交回复
热议问题