Hi guys,
After being able to put the mic to work, I wanted to start developing the actual function i want it to have: trigger something if determined volume is reached…to do so, I’ve been trying to use SoundAnalyse with this sample code
import numpy
import pyaudio
import analyse
# Initialize PyAudio
pyaud = pyaudio.PyAudio()
# Open input stream, 16-bit mono at 44100 Hz
# On my system, device 1 is a USB microphone, your number may differ.
stream = pyaud.open(
format = pyaudio.paInt16,
channels = 1,
rate = 44100,
input_device_index = 1,
input = True)
while True:
# Read raw microphone data
rawsamps = stream.read(1024)
# Convert raw data to NumPy array
samps = numpy.fromstring(rawsamps, dtype=numpy.int16)
# Show the volume and pitch
print analyse.loudness(samps), analyse.musical_detect_pitch(samps)
However, I always get the same error regarding the import of analyseffi…any solution to this / is this the right method to detect sound volume?
Thanks!