This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Author: Dmitry Sadykov | |
// For simplicity, next one-liner is useful to copy paste into several files: | |
// $ curl https://gist.githubusercontent.com/SolomidHero/dc1bb22679e5e0310399b443738ecfb8/raw/b16d6a2987efa77c6320679da3fb0f65cbefd594/template.cpp | pbcopy; for i in {a..f}; do pbpaste > $i.cpp; done | |
#include <iostream> | |
using namespace std; | |
using ll = int64_t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// modular constant | |
const int m = 1e10 + 7; | |
// array: x <-> inverse to x | |
int invs[maxN]; | |
// number of combinations C_n^k | |
// uses `invs` array as memory | |
int c_n_k(const int n, const int k) { | |
if (k > n) return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Word count of file using map reduce | |
# Args: | |
# - file | |
# - n_workers | |
map() { | |
local file=$1 | |
local from=$2 | |
local to=$3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Least Squares GAN loss | |
def adversarial_loss(scores, as_real=True): | |
if as_real: | |
return torch.mean((1 - scores) ** 2) | |
return torch.mean(scores ** 2) | |
def discriminator_loss(fake_scores, real_scores): | |
loss = adversarial_loss(fake_scores, as_real=False) + adversarial_loss(real_scores, as_real=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# speaker embeddings by AdaIN-VC speaker encoder | |
# ref: https://github.com/cyhuang-tw/AdaIN-VC | |
# | |
# 1. clone repo above | |
# $ git clone https://github.com/cyhuang-tw/AdaIN-VC | |
# $ cd AdaIN-VC | |
# 2. download pretrained checkpoint (by repo authors) and unzip it | |
# $ gdown --id 1d_llv1qaCpPjioReh4AT8K_-qqG2zoIx | |
# $ unzip -qo /content/vctk_model.zip | |
# 3. change pathes in this script and run it (with `python3 to_adain_emb.py`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# common utils | |
apt update && apt-get install -y sudo git vim wget unzip rubberband-cli sox | |
sudo apt-get install -y libsndfile1-dev libopenblas-base | |
pip install gdown librosa | |
# conda environment for Montreal-Forced-Aligner | |
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh | |
bash ~/miniconda.sh -b -p ~/miniconda |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import logging | |
import datetime | |
from pathlib import PosixPath | |
import time | |
from torch.utils.tensorboard import SummaryWriter | |
check_frequency = datetime.timedelta(minutes=5) | |
aws_url = 's3://<bucket>/<path>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# archive: tar + pigz | |
tar -cf split.tar.gz -I pigz dir/ | |
# unarchive: tar + pigz | |
tar -xf split.tar.gz -I pigz -C ./ | |
# archive: zip | |
zip -rq -0 split2.zip split/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wav_path = str(REPO_PATH / "tests/accent_test_sample/split/accent17/accent17_a17_14s.wav") | |
wav_16, sr16 = librosa.load(wav_path, sr=16000) | |
wav_22, sr22 = librosa.load(wav_path, sr=22000) | |
print(wav_22.shape, wav_16.shape) | |
# test1: sr=16khz, win=640, hop=160 | |
from new_data.preprocessing.batch_processors.spectrogram_creator import ( | |
SpectrogramCreator | |
) | |
from new_data.train_data_containers import Batch |