Skip to content

Instantly share code, notes, and snippets.

View revsic's full-sized avatar

YoungJoong Kim revsic

View GitHub Profile
@revsic
revsic / fuzz.sh
Last active May 4, 2024 07:33
Fuzzing101 Ex06 Tutorial
export BUILD_PATH=./build-asan
rm $BUILD_PATH/lib/gimp/2.0/plug-ins/*
afl-fuzz \
-i sample \
-o results \
-D \
-s 123 \
-t 100 \
-- $BUILD_PATH/bin/gimp-console-2.8 --verbose -d -f @@
import json
import os
import re
import subprocess
from tqdm import tqdm
_binary = "./build/bin/tiffinfo"
# _base = "./results/default/crashes"
# _dump = "./dump/default"
"""
Copyright (C) https://github.com/praat/praat
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@revsic
revsic / pyin.py
Last active February 13, 2023 14:08
from typing import Optional, Tuple
import numpy as np
import torch
from yin import YIN, localmin, parabolic_interp
def viterbi(log_prob: torch.Tensor, log_trans: torch.Tensor, log_init: torch.Tensor) -> torch.Tensor:
"""Viterbi algorithm.
@revsic
revsic / mas.py
Created September 8, 2021 15:58
monotonic alignment search
def search(log_prob: torch.Tensor, mask: torch.Tensor) -> torch.Tensor:
"""Monotonic alignment search from Glow-TTS.
Args:
log_prob: [B, S, T], log-probability.
mask: [B, S, T], attention mask.
Returns:
[B, S, T], alignment.
"""
bsize, seqlen, timestep = log_prob.shape
# [B, S, T]
@revsic
revsic / normalizer.py
Created August 24, 2021 04:38
Text normalizer for LJSpeech
from typing import List
class TextNormalizer:
"""Normalize text in to fixed graphme set.
WARNING: It does not accept digits, please use normalized text in LJ Speech.
"""
GRAPHEMES = 'abcdefghijklmnopqrstuvwxyz !?,.'
REPLACER = {
'"\'()-:;[]’“”': '', # punct
@revsic
revsic / py-cppheadermerger.py
Created August 9, 2019 10:36
Python implementation of C++ headeronly lib generator
import os
import re
import sys
class Format(object):
hpp = '''\
#ifndef {0}
#define {0}
{1}
#include <type_traits>
#define REQUIRE(method, ...) \
template <typename Cont, typename = void> \
struct require_##method : std::false_type {}; \
template <typename Cont> \
struct require_##method< \
Cont, \
std::void_t<decltype(std::declval<Cont>().method(__VA_ARGS__))>> \
: std::true_type {}; \
@revsic
revsic / Box.cpp
Created November 14, 2018 09:59
Box = unique_ptr + buffer size
#include <iostream>
template <typename T>
class Box {
public:
Box(size_t size) : ptr(new T[size]), size(size) {
// Do Nothing
}
Box(T* ptr, size_t size) : ptr(ptr), size(size) {
@revsic
revsic / match.cpp
Last active November 3, 2018 16:58
cpp implementation of functional style match syntax
#include <iostream>
#include <tuple>
#include <type_traits>
template <typename T, typename U>
using comparison_t = decltype(std::declval<T>() == std::declval<U>());
template <typename T, typename U, typename = std::void_t<>>
struct is_comparable : std::false_type {};