Python Forum
PyAudio Buffer Data Calculation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PyAudio Buffer Data Calculation
#1
Hi,

I have a question (Sorry I'm not very professional in python).
I'm using PyAudio to capture microphone sound with python (for its Peak Value).
The code is something like this:

p=pyaudio.PyAudio()
stream=p.open(format=pyaudio.paInt16,
              channels=1,rate=RATE,
              input=True,
              frames_per_buffer=CHUNK)
while True:
    data = np.fromstring(stream.read(1024),dtype=np.int16)
    dataMic = data...
    ...
    print("peak values")
When I run the app, it starts to print peak values line by line very fast (values change when microphone get sound)
Now my question is:
How can I calculate the average of for example every 10 peak values (in order) and print the average line by line instead of printing peak values for every frame!?
I know that I should save every 10 peak value result in an (maybe) array and then do the calculation but I don't know how to do it in python :-/ !
Please help me...
Thank you so much for your attention Shy .
Kind Regards.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pyaudio seems to randomly halt input. elpidiovaldez5 2 382 Jan-22-2024, 09:07 AM
Last Post: elpidiovaldez5
  Read buffer from bluetooth frohr 2 2,150 Jun-01-2022, 01:31 PM
Last Post: frohr
  Not getting response from pyaudio OceansBlue 1 2,658 Jul-03-2021, 06:22 AM
Last Post: OceansBlue
  JS Buffer.from VS struct.pack DreamingInsanity 3 2,468 Apr-05-2021, 06:27 PM
Last Post: DreamingInsanity
  Seperate output buffer matt_the_hall 2 2,364 Mar-15-2021, 08:44 PM
Last Post: matt_the_hall
  help with PyAudio Leo12143 1 1,958 Jan-18-2021, 09:56 AM
Last Post: DT2000
  pyAudio playing variable Talking2442 3 3,041 Dec-01-2020, 06:20 PM
Last Post: Talking2442
  Pyaudio Souls99 7 3,576 Oct-05-2020, 04:06 PM
Last Post: Larz60+
  PyAudio [Errorno -9999] Unanticipated Host Error iMuny 5 5,693 Sep-21-2020, 06:58 PM
Last Post: jefsummers
  PyAudio throwing Input overflowed anthares 3 4,795 Jun-14-2020, 03:37 PM
Last Post: anthares

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020