Skip to content

Instantly share code, notes, and snippets.

View SolomidHero's full-sized avatar
🏠
Building cool things from home

SolomidHero

🏠
Building cool things from home
  • Moscow Institute of Physics and Technologies
  • Armenia, Yerevan
View GitHub Profile
@SolomidHero
SolomidHero / diff_melspec_16khz_vs_22khz.py
Created July 6, 2023 13:55
Visualize mel difference
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
@SolomidHero
SolomidHero / main.sh
Last active December 12, 2022 14:20
Fast archiving/unarchiving
#!/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/
@SolomidHero
SolomidHero / autologs.py
Last active May 9, 2022 19:38
Logging to tensorboard
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>'
@SolomidHero
SolomidHero / start.sh
Last active September 30, 2021 12:19
Server start script (for FastSpeech2 repo, MFA, etc).
#! /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
@SolomidHero
SolomidHero / to_adain_emb.py
Last active May 18, 2021 21:53
VC speaker embeddings (by AdaIN-VC speaker encoder, by Resemblyzer)
# 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`)
@SolomidHero
SolomidHero / losses.py
Last active May 20, 2021 09:50
PatchGAN - Discriminator for frequency features
# 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)
@SolomidHero
SolomidHero / wc.sh
Created December 15, 2020 14:25
Word count (based on map/reduce) using bash
#!/bin/bash
# Word count of file using map reduce
# Args:
# - file
# - n_workers
map() {
local file=$1
local from=$2
local to=$3
@SolomidHero
SolomidHero / combinatorics.cpp
Last active September 27, 2020 14:29
Modular calculations
// 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;
@SolomidHero
SolomidHero / template.cpp
Last active November 21, 2020 16:58
Competitive Programming Template
// 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;