Skip to content

Instantly share code, notes, and snippets.

Avatar
🤨

endolith

🤨
View GitHub Profile
@endolith
endolith / frequency_estimator.py
Last active March 29, 2023 20:43
Frequency estimation methods in Python
View frequency_estimator.py
from __future__ import division
from numpy.fft import rfft
from numpy import argmax, mean, diff, log, nonzero
from scipy.signal import blackmanharris, correlate
from time import time
import sys
try:
import soundfile as sf
except ImportError:
from scikits.audiolab import flacread
@endolith
endolith / whisper_transcribe.py
Created March 27, 2023 02:33
Transcribe a long audio recording using OpenAI Whisper API
View whisper_transcribe.py
"""
Break up a long recording to fit within the Whisper API's limits, with some
overlap, so no words are missed, and then feed to OpenAI Whisper API to
transcribe it to .txt file. Written by endolith and ChatGPT-4.
"""
import openai
import math
import os
import subprocess
@endolith
endolith / DFT_ANN.py
Last active March 22, 2023 17:44
Training neural network to implement discrete Fourier transform (DFT/FFT)
View DFT_ANN.py
"""
Train a neural network to implement the discrete Fourier transform
"""
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
import numpy as np
import matplotlib.pyplot as plt
N = 32
batch = 10000
@endolith
endolith / readme.md
Last active March 21, 2023 03:58
THD+N calculator
View readme.md

Unfortunately, there are 2 versions of this. The other is here: https://github.com/endolith/waveform-analyzer I intend to either completely combine them or completely separate them, eventually.

Somewhat crude THD+N calculator in Python

Measures the total harmonic distortion plus noise (THD+N) for a given input signal, by guessing the fundamental frequency (finding the peak in the FFT), and notching it out in the frequency domain. This is a THDR

@endolith
endolith / example.png
Last active March 16, 2023 14:38
Plot poles and zeros in Z plane for a transfer function
@endolith
endolith / Has weird right-to-left characters.txt
Last active March 15, 2023 03:50
Unicode kaomoji smileys emoticons emoji
View Has weird right-to-left characters.txt
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶
@endolith
endolith / readme.md
Last active March 10, 2023 05:20
How to stream a webcam to a web browser in Ubuntu
View readme.md

Grr this took hours to figure out. I was trying to install MJPG-streamer and running VLC command lines and all this crap but nothing worked.

First install motion:

~> sudo apt-get install motion

Then create a config file:

~> mkdir ~/.motion

~> nano ~/.motion/motion.conf

@endolith
endolith / AutoCorrect.ahk
Last active March 5, 2023 23:23
AutoCorrect AutoHotkey spelling script
View AutoCorrect.ahk
; c = case sensitive
; c1 = ignore the case that was typed, always use the same case for output
; * = immediate change (no need for space, period, or enter)
; ? = triggered even when the character typed immediately before it is alphanumeric
; r = raw output
;------------------------------------------------------------------------------
; CHANGELOG:
;
; 2011-03-21 and after: See readme.md
@endolith
endolith / peakdet.m
Last active March 4, 2023 09:59
Peak detection in Python [Eli Billauer]
View peakdet.m
function [maxtab, mintab]=peakdet(v, delta, x)
%PEAKDET Detect peaks in a vector
% [MAXTAB, MINTAB] = PEAKDET(V, DELTA) finds the local
% maxima and minima ("peaks") in the vector V.
% MAXTAB and MINTAB consists of two columns. Column 1
% contains indices in V, and column 2 the found values.
%
% With [MAXTAB, MINTAB] = PEAKDET(V, DELTA, X) the indices
% in MAXTAB and MINTAB are replaced with the corresponding
% X-values.
@endolith
endolith / A_weighting.py
Last active February 26, 2023 21:18
A-weighting audio files in Python
View A_weighting.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Translated from a MATLAB script (which also includes C-weighting, octave
and one-third-octave digital filters).
Author: Christophe Couvreur, Faculte Polytechnique de Mons (Belgium)
couvreur@thor.fpms.ac.be
Last modification: Aug. 20, 1997, 10:00am.
BSD license