Created
November 28, 2023 12:30
-
-
Save KaushikShresth07/ba9589c3585deeab4d004dd908811189 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sounddevice as sd | |
import numpy as np | |
threshold = 90 | |
Clap = False | |
def detect_clap(indata,frames,time,status): | |
global Clap | |
volume_norm = np.linalg.norm(indata) * 10 | |
if volume_norm>threshold: | |
print("Clapped!") | |
Clap = True | |
def Listen_for_claps(): | |
with sd.InputStream(callback=detect_clap): | |
return sd.sleep(1000) | |
def MainClapExe(): | |
while True: | |
Listen_for_claps() | |
if Clap==True: | |
break | |
else: | |
pass | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment