Robot Hearing
Sound provides critical information that vision misses: a cry for help around a corner, the subtle grinding of a failing motor, or a voice command. Microphone Arrays use differences in sound arrival time to pinpoint where a sound is coming from.
🎤
Microphone Arrays
Multiple microphones arranged in a pattern to detect sound direction (Beamforming) and reduce noise.
channels:4-8 mics
pattern:Circular/Linear
processing:DSP required
🎤
Ultrasonic Microphones
Microphones sensitive to frequencies above human hearing (>20kHz).
frequency:20kHz - 100kHz+
sensitivity:High
🎤
Piezo Vibration Sensors
Detects solid-borne sound (vibration) on surfaces.
sensitivity:V/g
range:1Hz - 10kHz
Python - Sound Level Detection (PyAudio)
import pyaudio
import numpy as np
CHUNK = 1024
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 44100
p = pyaudio.PyAudio()
stream = p.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, frames_per_buffer=CHUNK)
print("Listening for loud sounds...")
try:
while True:
data = np.frombuffer(stream.read(CHUNK), dtype=np.int16)
peak = np.average(np.abs(data))
# Simple VU Meter visualization
bars = "#" * int(50 * peak / 10000)
print(f"Level: {int(peak)} | {bars}")
if peak > 5000:
print(">> LOUD NOISE DETECTED! <<")
except KeyboardInterrupt:
print("Stopping...")
stream.stop_stream()
stream.close()
p.terminate()