Skip to content

Instantly share code, notes, and snippets.

@mizoru
mizoru / zone_ids_removal.sh
Last active September 6, 2023 14:51
Remove the WSL Zone.Identifier files
cd ~ && find . -name "*:Zone.Identifier" -type f -delete && cd - > /dev/null
@mizoru
mizoru / GD_on_input_MNIST.py
Created July 26, 2023 04:50
Gradient descent on the input to a model trained to recognize MNIST digits
x = torch.ones(bs, 784) * 0.5 + 0.02 * torch.randn(bs, 784)
x.requires_grad_(True).retain_grad()
for i in range(0, n//bs):
preds = model(x)
loss = loss_func(preds, y)
loss.backward()
with torch.no_grad():
x -= x.grad * lr
if x.grad.grad_fn is not None:
x.grad.detach_()
@mizoru
mizoru / get_data_to_buffer_energies
Created November 26, 2022 18:46
get_data_to_buffer with energies
def get_data_to_buffer(train_config):
buffer = list()
text = process_text(train_config.data_path)
audio_files = sorted(Path(train_config.audio_path).iterdir())
spec = Spectrogram(512)
start = time.perf_counter()
for i, file in tqdm(zip(range(len(text)), audio_files)):
mel_gt_name = os.path.join(
@mizoru
mizoru / get_data_to_buffer
Created November 26, 2022 17:09
get_data_to_buffer with f0 processing
def get_data_to_buffer(train_config):
buffer = list()
text = process_text(train_config.data_path)
audio_files = sorted(Path(train_config.audio_path).iterdir())
hop_length = 256
frame_period = hop_length / 22_050 * 1000
start = time.perf_counter()
for i, file in tqdm(zip(range(len(text)), audio_files)):
@mizoru
mizoru / IPA-correspondences.py
Last active May 5, 2022 12:51
IPA correspondences to the TIMIT sequences
CORR = {'h#': "",
'sh': "ʃ",
'iy': "i",
'hv': "ɦ",
'ae': "æ",
'dcl': "d̚",
'd': "d",
'y': "j",
'er': "ɝ",
'aa': "ɑ",
def replace_slashes(s:str):
return s.replace('\\', '/')
df.path = df.path.map(replace_slashes)