diff --git a/python/clap.py b/python/clap.py index 19096cf..dd8b43f 100755 --- a/python/clap.py +++ b/python/clap.py @@ -1,28 +1,28 @@ #!/usr/bin/env nix-script #!>python -#! python | pyaudio +#! python3 | pyaudio ## Listen to claps from the microphone. -import pyaudio, audioop +import pyaudio +import audioop settings = { - "format": pyaudio.paInt16, - "channels": 2, - "rate": 44100, - "input": True, - "frames_per_buffer": 1024 + "format": pyaudio.paInt16, + "channels": 2, + "rate": 44100, + "input": True, + "frames_per_buffer": 1024 } audio = pyaudio.PyAudio() -stream = audio.open(**impostazioni) -chunk = int(impostazioni["rate"] * 0.025) +stream = audio.open(**settings) +chunk = int(settings["rate"] * 0.025) while True: - noisy = 0 - for i in range(10): - block = stream.read(chunk) - if audioop.rms(block, 2) > 100: - noisy += 1 - if 3 <= noisy < 8: - print("clap") - + noisy = 0 + for i in range(5): + block = stream.read(chunk, exception_on_overflow=False) + if audioop.rms(block, 2) > 100: + noisy += 1 + if 3 <= noisy < 8: + print("clap") diff --git a/scripts/make-raspi-img b/scripts/make-raspi-img deleted file mode 100755 index 991c88a..0000000 --- a/scripts/make-raspi-img +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh - -# Packages required -# dosfstools parted -# Can be run on any Linux system -# loop.max_part=15 must be in kernel cmdline (cmdline.txt for rpi) -# then reboot - -echo "creating image to fit on 2Gb card" -dd if=/dev/zero of=arch-rpi.img bs=1M count=1850 - -echo "Partitioning" -fdisk arch-rpi.img <