Skip to content

Instantly share code, notes, and snippets.

@patientzero
patientzero / splits.py
Last active February 22, 2023 09:04
Speaker exclusive splits used on the FluencyBank part of SEP-28k in the paper Detecting Dysfluencies in Stuttering Therapy Using wav2vec 2.0
# Sebastian P. Bayerl
FB_TEST = ['68m', '26m', '54m', '24fc', '34m', '24ma']
FB_DEV_SPK = ['46ma', '27f', '24fb', '37m', '29mc', '32m', '57m']
FB_TRAIN_SPK = ['24fa', '62m', '50fa', '29ma', '68m', '64m', '35ma', '27ma', '29mb', '28m', '26m',
'46mb', '43m', '54m', '26f', '60m', '35mb', '24fc', '34m', '62f', '24ma', '24mb',
'25m', '39f', '54f', '50fb']
FB_TRAIN_DEV = FB_TRAIN_SPK + FB_DEV_SPK
@patientzero
patientzero / backup_hist.sh
Last active January 3, 2023 09:52
regular backup of bash_history
#!/bin/bash
# This is a script to backup your command history.
# How to use:
# 1.) create dir (mkdir ~/history) and place this script as backup_hist.sh in it.
# 2.) add daily cronjob
# to run daily at midnight, add this line to the crontab(crontab -e):
# 0 0 * * * /bin/bash ~/history/backup_hist.sh > /dev/null 2>&1
# 3.) To allow filtering of commands by date, add this to your .bashrc:
# HISTTIMEFORMAT="%d/%m/%y %T " and also here:
# hist command in non interactive shells by defautl disabled, so enable by adding historyfile
@patientzero
patientzero / load_cbt_annotations.py
Created December 15, 2021 14:22
loading wai labels
import pandas as pd
def load_cbt_annotations(path):
import json
with open(path) as f:
x = json.load(f)
# make session numeric
df = pd.DataFrame()
for k, v in x.items():
while v:
@patientzero
patientzero / morse_str_to_wav.py
Created November 11, 2021 19:53
morse code to wavefile implemented in python
def morse_code_to_wav(morse_str, sr=8000, short_burst_len=0.1, long_burst_len=0.2,
pause_len=0.05, frequency=500, output_file_name=None):
"""
@param morse_str: str containing . for short burst - for long burst and space for pause between words
@param sr: sampling frequency of the desired wav output
@param output_file_name: path to wavfile output
"""
amplitude = np.iinfo(np.int16).max * 0.7
t_pause = np.linspace(0, pause_len, int(sr * pause_len))
t_pause[:] = 0
@patientzero
patientzero / cloudSettings
Last active December 21, 2020 11:42
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-12-21T11:42:03.823Z","extensionVersion":"v3.4.3"}
@patientzero
patientzero / uninstall_vscode.sh
Created April 8, 2020 09:58
Uninstall Visual Studio Code from Mac
#!/bin/bash
# based on Medium Blogpost :https://medium.com/@jimkang/complete-uninstall-remove-vscode-mac-5e48bef3bdec
rm -rf $HOME/Library/Application\ Support/Code
rm -rf $HOME/.vscode
rm -rf /Applications/Visual\ Studio\ Code.app
@patientzero
patientzero / group_k_fold_example.py
Created October 10, 2019 14:48
Example for the usage of sklearn GroupKFold
from sklearn.model_selection import GroupKFold
# define number of splits
n_splits = 10
# all data in a list
pics = list(data_dir.glob('**/*.png'))
# matching labels in list
labels = [pic.parent.stem for pic in pics]
# get all groups that should not be in the
groups = [pic.stem.split('_')[1] for pic in pics]
gkf = GroupKFold(n_splits=n_splits)
@patientzero
patientzero / ffmpeg.md
Created August 27, 2019 08:33 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

### Keybase proof
I hereby claim:
* I am patientzero on github.
* I am sebastianbayerl (https://keybase.io/sebastianbayerl) on keybase.
* I have a public key ASBAzeywZrXnBpjPs4rL5teZKmxbF8f7LP8G-xJHUr5WZQo
To claim this, I am signing this object:
@patientzero
patientzero / migrate_vscode.sh
Last active March 6, 2019 17:37
Migrate vscode extensions to new machine
#!/bin/bash
# Install all vscode extensions on another machine
# based on https://stackoverflow.com/questions/35773299/how-can-you-export-vs-code-extension-list
# paste this in your terminal window on the base machine, it creates an sh file to execute on your new machine
echo '#!/bin/bash' > install_vscode_extensions.sh
code --list-extensions | xargs -L 1 echo code --install-extension >> install_vscode_extensions.sh