CiscoTheProot/rpi/micTest.py

12 lines
342 B
Python
Raw Normal View History

# Print out realtime audio volume as ascii bars
import sounddevice as sd
import numpy as np
def callback(indata: np.ndarray, outdata: np.ndarray, frames: int, time, status) -> None:
print(indata.shape)
volume_norm = np.linalg.norm(indata)*10
print ("|" * int(volume_norm))
with sd.Stream(callback=callback):
sd.sleep(10000)