Skip to content

Instantly share code, notes, and snippets.

View johnmeade's full-sized avatar

John Meade johnmeade

  • Resemble AI
View GitHub Profile
@johnmeade
johnmeade / asr.py
Last active April 18, 2021 00:15
Multi-language ASR using Huggingface transformer models.
"""
Multi-language ASR using Huggingface transformer models.
Python dependencies:
pip install transformers==4.5.0 librosa soundfile torch
"""
from typing import NamedTuple
from functools import lru_cache
@johnmeade
johnmeade / aeneas_word_force_align.py
Created April 14, 2021 19:19
Forced Alignment with Aeneas at the word-level
"""
Note: Aeneas is based on TTS and DTW, which is not ideal for word-level alignment.
However, it is easy to install and works quite well, so it is still very useful.
This gist just lazily writes files to "/tmp" for demonstration purposes.
System and Python dependencies (Ubuntu):
sudo apt-get install python-dev espeak espeak-data libespeak1 libespeak-dev ffmpeg
pip install numpy textgrid
pip install aeneas
@johnmeade
johnmeade / speech_noise.py
Last active January 3, 2023 12:55
Use VAD to separate out regions without speech content, and estimate mean power of background noise
"""
Estimate background noise power level of a speech waveform.
Requires some non-speech regions in the wave.
Requirements:
pip install numpy librosa soundfile webrtcvad
MIT License John Meade 2021
"""
@johnmeade
johnmeade / snr.py
Last active May 24, 2024 19:29
WADA SNR Estimation of Speech Signals in Python
import numpy as np
def wada_snr(wav):
# Direct blind estimation of the SNR of a speech signal.
#
# Paper on WADA SNR:
# http://www.cs.cmu.edu/~robust/Papers/KimSternIS08.pdf
#
# This function was adapted from this matlab code:
# https://labrosa.ee.columbia.edu/projects/snreval/#9
@johnmeade
johnmeade / pool_data_loader.py
Created July 13, 2019 19:50
A Python multiprocessing pool drop-in replacement for the PyTorch DataLoader class
'''
A multiprocessing Pool drop-in replacement for the pytorch
DataLoader class. Built to work around an apparent bug in
the default pytorch DataLoader, in which it hangs indefinitely.
It is possible to reach a sustained 95-100% GPU usage (as
reported by `nvidia-smi`) using this implementation.
Requirements:
pip install filelock
@johnmeade
johnmeade / dist_sampler.py
Last active July 13, 2019 20:28
Fast sampling from arbitrary probability densities in Python
'''
Tools for sampling from arbitrary probability densities.
Requirements:
pip install scipy numpy
John Meade 2019
MIT license
'''