Skip to content

Instantly share code, notes, and snippets.

@twobob
twobob / 5mb.py
Created October 28, 2024 19:47
aim to hit a size without going over for mp4 files
import argparse
import subprocess
import os
from pathlib import Path
def compress_video(input_file, output_file, target_size_mb=5, initial_bitrate=500,
initial_scale=640, min_bitrate=50, min_scale=100, audio_bitrate=96,
max_attempts=5):
"""
Compress a video file to a target size while adjusting bitrate and scale.
@twobob
twobob / TsneWavs.py
Last active October 13, 2024 10:36
wav classifier (sort by reduced features revision)
import os
import argparse
import librosa
import numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler
from sklearn.decomposition import PCA
from sklearn.manifold import TSNE
from sklearn.cluster import KMeans
@twobob
twobob / DisableWavPreview.reg
Created October 7, 2024 17:41
enable WAV file preview in the Windows 11 sidebar by associating WAV files with a specific shell extension handler and defining the preview handler in the Windows registry
Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\.wav\shellex\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\PreviewHandlers]
"{031EE060-67BC-460d-8847-E4A7C5E45A27}"=-
@twobob
twobob / levicon.py
Created September 23, 2024 01:32
creating meaningful categories based on classifications parsed from a song name
from collections import Counter
# Provided text
import os
import glob
# Define the directory path
dir_path = r"E:\Dubstep_diffusion\tracks"
# List all .wav and .mp3 files using glob with wildcard matching
import os
import re
import matplotlib.pyplot as plt
from tqdm import tqdm
import pretty_midi
from basic_pitch.inference import predict_and_save, predict
from basic_pitch import ICASSP_2022_MODEL_PATH
from mido import MidiFile, MetaMessage, bpm2tempo
import subprocess
import librosa
@twobob
twobob / midi_signaller.py
Created September 21, 2024 09:01
spilts audio into stems - extracts the midi from the stems , saves them, merges them into one midi per song and saves that as well
import os
import re
import matplotlib.pyplot as plt
from tqdm import tqdm
import pretty_midi
from basic_pitch.inference import predict_and_save, predict
from basic_pitch import ICASSP_2022_MODEL_PATH
from mido import MidiFile, MetaMessage, bpm2tempo
import demucs.separate
import shlex
@twobob
twobob / midoed.py
Created September 20, 2024 19:48
basic_pitch mido and pretty midi attempt to figure out multiple layered midi
import os
import re
import matplotlib.pyplot as plt
from tqdm import tqdm
import pretty_midi
from basic_pitch.inference import predict_and_save
from basic_pitch import ICASSP_2022_MODEL_PATH
from mido import MidiFile, MetaMessage, bpm2tempo
# Set this flag to True if you want to reprocess all files, even if MIDI files already exist
@twobob
twobob / pitchIt.py
Last active September 20, 2024 15:16
vauge midi like preprocessing
import librosa
import numpy as np
from mido import Message, MidiFile, MidiTrack, MetaMessage, bpm2tempo
import pretty_midi
import matplotlib.pyplot as plt
import os
import re
# Set this flag to True if you want to reprocess all files, even if MIDI files already exist
REPROCESS_ALL = False
@twobob
twobob / fluxy.py
Last active August 8, 2024 04:47
nod to Vvan gemert
# First, in your terminal.
#
# $ python3 -m virtualenv env
# $ source env/bin/activate
# $ pip install torch torchvision transformers sentencepiece protobuf accelerate
# $ pip install git+https://github.com/huggingface/diffusers.git
# $ pip install [email protected]
# $ pip install gradio
@twobob
twobob / pinball.zig
Created July 12, 2024 13:56
pinball.zig a not at all tested wasmmodule
const std = @import("std");
const physics = @import("physics");
const Ball = physics.Ball;
const Surface = physics.Surface;
const Allocator = std.mem.Allocator;
const Pos2 = physics.Pos2;
const Vec2 = physics.Vec2;
const num_flippers = 2;
const num_bumpers = 3;