Skip to content

Instantly share code, notes, and snippets.

View voidful's full-sized avatar
🎯
Focusing

Eric Lam voidful

🎯
Focusing
View GitHub Profile
@voidful
voidful / streaming_whisper.py
Created November 29, 2024 18:23
streaming-whisper
from collections import deque
import numpy as np
import torch
from datasets import load_dataset
from transformers import WhisperProcessor, WhisperForConditionalGeneration
# Load and preprocess dataset
ds = load_dataset("librispeech_asr", "clean", split="validation")
sample = ds[0]["audio"]
sample["array"] = sample["array"][16000 * 1 : 16000 * 4] # Extract a 3-second clip
@voidful
voidful / ffmpeg-convert-mp3-to-wave
Created November 13, 2022 10:13 — forked from vunb/ffmpeg-convert-mp3-to-wave
Convert mp3 to wave format using ffmpeg
ffmpeg -i input.mp3 -acodec pcm_s16le -ac 1 -ar 16000 output.wav
# To convert all mp3 files in a directory in Linux:
for f in *.mp3; do ffmpeg -i "$f" -acodec pcm_s16le -ac 1 -ar 16000 "${f%.mp3}.wav"; done
# Or Windows:
for /r %i in (*) do ffmpeg -i %i -acodec pcm_s16le -ac 1 -ar 16000 %i.wav
@voidful
voidful / all-git-commits.py
Created July 19, 2022 08:35 — forked from alpiepho/all-git-commits.py
Simple python script to download all GitHub commits for a given repo.
#!/usr/bin/python
# python3 ./all-git-commits.py -u <user> -d <directory> -r <repo> -n <number of commits>
#
# Tool to inspect Github and pull local copies of all commits for
# for the given user.
#
# Why? Every ask yourself the question 'I know I did this before, but
# which repos commit was it in?'
# With all files local, you can use any serach-in-files app to look.
@voidful
voidful / block.sh
Last active September 14, 2021 08:20
block docker container external access - whitelist
iprange=${1}
devices=$( ip -o -4 route show to default | awk '{print $5}')
echo "whitelist:" $1
sudo iptables -D DOCKER-USER ! -s $1 -i $devices -m conntrack --ctdir ORIGINAL -j DROP
sudo iptables -I DOCKER-USER -i $devices ! -s $1 -m conntrack --ctdir ORIGINAL -j DROP
# run on reboot
echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections
echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections
sudo apt-get -y install iptables-persistent