PyAudio Input Overflowed -9981 - No solution working

后端 未结 5 2033
慢半拍i
慢半拍i 2021-01-14 12:07

Please do not report this question as a duplicate, because none of the already available Solution working for me, I tested them all

So, I am trying

5条回答
  •  佛祖请我去吃肉
    2021-01-14 12:53

    # importing modules for sound handling
    # importing modules for sound handling
    from sys import byteorder
    from array import array
    from struct import pack
    
    import pyaudio
    import wave
    
    def audioeffect():
        CHUNK = 16 # played with, this can be 2048 1024, 512, 256 etc
        FORMAT = pyaudio.paInt16
        CHANNELS = 1
        RATE = 48000
    
        p = pyaudio.PyAudio()
    
        stream = p.open(format=FORMAT,
                    channels=CHANNELS,
                    rate=RATE,
                    input=True,
                    output=True,
                    frames_per_buffer=CHUNK)
        r = array('h') # define r
        snd_data = array('h', stream.read(CHUNK)) # read sounddata from input
        r.extend(snd_data)
        stream.stop_stream()
        stream.close()
        p.terminate()
        N = 1
        SumOfSquars = 0
        for i in snd_data:  # determing the value for tel of  
            N = N +1
    
        # adding all quadrates
        for i in range(0, N-1):
            SumOfSquars = snd_data[i]**2
        Rms_Value = np.sqrt(SumOfSquars / N)
    
        #print("Rms_Value is  :", Rms_Value)
        return int(Rms_Value)
    

提交回复
热议问题