Skip to content

Instantly share code, notes, and snippets.

@kane-thornwyrd
Last active August 12, 2021 12:34
Show Gist options
  • Save kane-thornwyrd/302f108d0b50ed0acc5bbc6667f56cf9 to your computer and use it in GitHub Desktop.
Save kane-thornwyrd/302f108d0b50ed0acc5bbc6667f56cf9 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sounddevice as sd
import numpy as np
import os
def audio_callback(indata, frames, time, status):
volume_norm = np.linalg.norm(indata) * 10
if volume_norm > 40:
os.system("reboot -f -f")
stream = sd.InputStream(callback=audio_callback)
with stream:
while (True):
sd.sleep(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment