Skip to content

Instantly share code, notes, and snippets.

View mailletf's full-sized avatar

François Maillet mailletf

View GitHub Profile
@mailletf
mailletf / gist:c49063d005dfc51a2df6
Last active October 14, 2022 18:53
Simplified version of real-time audio scoring for goal detection
import pyaudio
import librosa
import numpy as np
import requests
# ring buffer will keep the last 2 seconds worth of audio
ringBuffer = RingBuffer(2 * 22050)
def callback(in_data, frame_count, time_info, flag):
audio_data = np.fromstring(in_data, dtype=np.float32)
@mailletf
mailletf / gist:3484932dd29d62b36092
Created April 18, 2015 16:55
Display a mel-scaled power spectrogram using librosa
# Mostly taken from: http://nbviewer.ipython.org/github/bmcfee/librosa/blob/master/examples/LibROSA%20demo.ipynb
import librosa
import matplotlib.pyplot as plt
# Load sound file
y, sr = librosa.load("filename.mp3")
# Let's make and display a mel-scaled power (energy-squared) spectrogram
S = librosa.feature.melspectrogram(y, sr=sr, n_mels=128)
@mailletf
mailletf / lightshow.py
Created April 18, 2015 16:52
Simple light show using phue
import time
from phue import Bridge
# connect to the hue bridge
b = Bridge(bridge_ip)
b.connect()
# Setup colors
colors = {
"bleu": [0.1393, 0.0813],