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
# 在末尾加上,显示当前在第几个窗口。 | |
caption always "%{= kw}%-w%{= kG}%{+b}[%n %t]%{-b}%{= kw}%+w %=%d %M %0c %{g}%H%{-}" |
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
/////////// self defined ENUM_STR, have a string val | |
#define ENUM_STR_BEGIN(type_name) \ | |
class type_name { \ | |
std::string v; \ | |
public: \ | |
static std::set<std::string>* vals() { static std::set<std::string> s; return &s; }\ | |
type_name(const std::string& a): v(a){} \ | |
std::string toString() { return v; } \ | |
bool isValid() { return vals()->find(v) != vals()->end(); } |
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
#encoding=utf-8 | |
import cProfile | |
import pstats | |
def fun(): | |
return sum([i for i in range(10000000)]) | |
if __name__ == "__main__": | |
cProfile.run('fun()', "result") |
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
from functools import lru_cache | |
@lru_cache(maxsize=2**20) | |
def LCS(a, b): | |
""" Longest common subsequence """ | |
if len(a) == 0 or len(b) == 0: | |
return 0 | |
res = max( |
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 bob.io.audio | |
import bob.kaldi # https://www.idiap.ch/software/bob/docs/bob/docs/stable/bob/doc/install.html | |
import matplotlib.pyplot as plt | |
def vad(sig, sr, vad_energy_mean_scale=0.5, vad_energy_th=9, vad_frames_context=20, vad_proportion_th=0.4): | |
""" Energy Based Voice Activate Detection algorithm. (based on kaldi) | |
Param: | |
sig: list or np.array | |
the signal, list of samples | |
sr: int |
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 librosa | |
import wave | |
from pathlib import Path | |
import numpy as np | |
import os | |
all_in_one_wav = "@all_in_one.wav" | |
all_in_one_wav_info = "@all_in_one.txt" | |
all_in_one_label = "@all_in_one_vad.txt" | |
label_file = "@label.txt" |
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 wave | |
import os | |
def is_wav(f): | |
res = True | |
try: | |
wave.open(f) | |
except wave.Error as e: | |
res = False |
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
#ifndef __PYTHON_LIKE__ | |
#define __PYTHON_LIKE__ | |
#include <stdio.h> | |
#include <string> | |
#include <fstream> | |
#include <streambuf> | |
#include <vector> | |
#include <iostream> | |
#include <stdarg.h> |
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
# coding=utf-8 | |
import os | |
from multiprocessing.dummy import Pool | |
def can_ping(ip): | |
ret = os.system('ping -n 1 -w 1 %s > nul' % ip) | |
can_ping = True if ret == 0 else False | |
return can_ping, ip |
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
from sklearn import metrics | |
from scipy.optimize import brentq | |
from scipy.interpolate import interp1d | |
def cal_eer(score_true, score_false): | |
""" 计算EER | |
Args: | |
scores_true: 正样例的分数列表 | |
scores_false: 负样例的分数列表 |
OlderNewer