Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
import pyaudio
import audioop
import math
CHUNK = 1024
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 44100
RECORD_SECONDS = 1
p = pyaudio.PyAudio()
stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=CHUNK)
for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
data = stream.read(CHUNK,
exception_on_overflow=False)
rms = audioop.rms(data, 2)
decibel = 20 * math.log10(rms)
print(decibel)
stream.stop_stream()
stream.close()
p.terminate()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question