repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/tts_utils/plot.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import matplotlib.pyplot as plt
import numpy as np
def spec_numpy_to_figure(spec):
fig = plt.figure(figsize=(8, 4))
plt.imshow(spec.T, aspect='auto', origin='lower')
return fig
def numpy_to_figure(numpy_data):
fig = plt.figure(... | 1,349 | 24.471698 | 65 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/tts_utils/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import glob
import logging
import re
import time
from collections import defaultdict
import os
import sys
import shutil
import types
import numpy as np
import torch
import torch.nn.functional as F
import torch.distributed as dist
def reduce_ten... | 17,042 | 29.931034 | 114 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/tts_utils/text_encoder.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import re
import six
from six.moves import range # pylint: disable=redefined-builtin
PAD = "<pad>"
EOS = "<EOS>"
UNK = "<UNK>"
SEG = "|"
RESERVED_TOKENS = [PAD, EOS, UNK]
NUM_RESERVED_TOKENS = len(RESERVED_TOKENS)
PAD_ID = RESERVED_TOKENS.index... | 10,163 | 32.434211 | 95 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/tts_utils/text_norm.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# coding=utf-8
# Authors:
# 2019.5 Zhiyang Zhou (https://github.com/Joee1995/chn_text_norm.git)
# 2019.9 Jiayu DU
#
# requirements:
# - python 3.X
# notes: python 2.X WILL fail or produce misleading results
import sys, os, argparse, codecs... | 27,011 | 33.063052 | 125 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/tts_utils/parse_textgrid.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import re
import argparse
import json
from collections import OrderedDict
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--input", help="input path of textgrid")
parser.add_argument("--output", help="outpu... | 3,935 | 32.641026 | 111 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/tts_utils/world_utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
##########
# world
##########
import numpy as np
import pysptk
import copy
import torch
gamma = 0
mcepInput = 3 # 0 for dB, 3 for magnitude
alpha = 0.45
en_floor = 10 ** (-80 / 20)
FFT_SIZE = 2048
def code_harmonic(sp, order):
# get mcep... | 2,926 | 26.87619 | 106 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/tts_utils/preprocessor.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import json
import warnings
import torch
from skimage.transform import resize
from tts_utils.world_utils import f0_to_coarse
warnings.filterwarnings("ignore")
import struct
import webrtcvad
from scipy.ndimage.morphology import binary_dilation... | 10,373 | 35.657244 | 115 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/tts_utils/tts_utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch
import torch.nn.functional as F
import numpy as np
from tts_utils.stft import STFT
def make_pad_mask(lengths, xs=None, length_dim=-1):
"""Make mask tensor containing indices of padded part.
Args:
lengths (LongTensor... | 8,414 | 37.424658 | 82 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/datasets/__init__.py | 0 | 0 | 0 | py | |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/datasets/tts/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import json
import os
from tts_utils.text_encoder import TokenTextEncoder
def build_phone_encoder(data_dir):
phone_list_file = os.path.join(data_dir, 'phone_set.json')
phone_list = json.load(open(phone_list_file))
return TokenTextE... | 356 | 24.5 | 62 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/datasets/tts/__init__.py | 0 | 0 | 0 | py | |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/datasets/tts/lj/prepare.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import os
os.environ["OMP_NUM_THREADS"] = "1"
import json
import os
import re
import subprocess
from multiprocessing.pool import Pool
import pandas as pd
from g2p_en import G2p
from tqdm import tqdm
basedir = 'data/raw/LJSpeech-1.1'
g2p = G2p... | 2,717 | 32.975 | 114 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/datasets/tts/lj/gen_fs2_p.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import os
os.environ["OMP_NUM_THREADS"] = "1"
from datasets.tts.utils import build_phone_encoder
from tts_utils.indexed_datasets import IndexedDatasetBuilder
import glob
import json
import logging
import sys
import traceback
from multiprocessin... | 7,361 | 36.948454 | 111 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/datasets/tts/lj/__init__.py | 0 | 0 | 0 | py | |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/monotonic_align/setup.py | from distutils.core import setup
from Cython.Build import cythonize
import numpy
setup(
name = 'monotonic_align',
ext_modules = cythonize("core.pyx"),
include_dirs=[numpy.get_include()]
)
| 195 | 18.6 | 38 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/monotonic_align/__init__.py | import numpy as np
import torch
from .monotonic_align.core import maximum_path_c
def maximum_path(value, mask):
""" Cython optimised version.
value: [b, t_x, t_y]
mask: [b, t_x, t_y]
"""
value = value * mask
device = value.device
dtype = value.dtype
value = value.data.cpu().numpy().astype(np.float32... | 608 | 26.681818 | 62 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/tasks/base_task.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import matplotlib
matplotlib.use('Agg')
from tts_utils.hparams import hparams, set_hparams
import random
import sys
import numpy as np
import torch.distributed as dist
from pytorch_lightning.loggers import TensorBoardLogger
from tts_utils.pl_uti... | 11,402 | 31.303116 | 98 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/tasks/priorgrad_inference.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import os, glob, re
from tts_utils.hparams import hparams, set_hparams
from tasks.priorgrad import PriorGradDataset
from tasks.priorgrad import PriorGradTask
import torch
import numpy as np
from tqdm import tqdm
set_hparams()
def get_latest_ckp... | 3,439 | 41.469136 | 142 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/tasks/priorgrad.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import matplotlib
# matplotlib.use('Agg')
from matplotlib import pyplot as plt
from tts_utils.pl_utils import data_loader
import os, sys
import json
from multiprocessing.pool import Pool
from tqdm import tqdm
from modules.tts_modules import Du... | 44,586 | 48.762277 | 165 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect/eval_aishell.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import sys
import torch
import argparse
import re
#from fastcorrect_model import FastCorrectModel
import os
import os.path
import time
import json
import numpy as np
from fairseq import utils
utils.import_user_module(argparse.Namespace(user_dir=... | 4,731 | 41.630631 | 223 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect/FC_utils/language_pair_dataset.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import numpy as np
import torch
from fairseq.data im... | 24,146 | 38.455882 | 90 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect/FC_utils/hub_utils_fc.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#!/usr/bin/env python3 -u
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import copy
import logging... | 11,181 | 35.423453 | 95 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect/FC_utils/binarizer_fc.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import os
from collections import Counter
import torch
from fairseq... | 4,394 | 33.606299 | 103 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect/FC_utils/options_fc.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import argparse
from typing import Callable, List, Optional
import ... | 19,822 | 43.346756 | 120 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect/FC_utils/preprocess_fc.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Data pre-processing: build vocabularies and binarize training dat... | 14,507 | 35.089552 | 124 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect/FC_utils/fastcorrect_generator.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from collections import namedtuple
import numpy as np
import torch
... | 13,998 | 36.530831 | 163 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect/scripts/align_cal_werdur_v2.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#Usage python align_cal_werdur_v2.py <input-tokened-hypo-text-file> <input-tokened-ref-text-file>
#Note:
# The script will align <input-tokened-hypo-text-file> (text with errors) with <input-tokened-ref-text-file> (ground-truth text) and obtain ... | 38,563 | 40.781148 | 212 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect/scripts/add_noise.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Usage python add_noise.py <input-raw-text-file> <output-noised-text-file> <random-seed>
import os
import sys
import random
import numpy as np
sim_dict = {}
vocab_1char = []
vocab_2char = []
with open('./scripts/sim_prun_char.txt', 'r', encod... | 5,452 | 34.180645 | 151 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect/FastCorrect/fastcorrect_task.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import os
import itertools
import logging
logger = logging.getLogge... | 13,281 | 34.513369 | 113 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect/FastCorrect/fc_loss.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import math
import torch
import torch.nn.functional as F
from fairs... | 7,118 | 35.137056 | 119 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect/FastCorrect/__init__.py | from . import fastcorrect_model
from . import fastcorrect_task
from . import fc_loss
| 85 | 20.5 | 31 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect/FastCorrect/fastcorrect_model.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn.functional as F
from fairseq import uti... | 29,151 | 36.470437 | 215 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect/espnet_wer_calculation/concatjson.py | #!/usr/bin/env python3
# encoding: utf-8
# Copyright 2017 Johns Hopkins University (Shinji Watanabe)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
import argparse
import codecs
import json
import logging
import sys
from cli_utils import get_commandline_args
is_python2 = sys.version_info[0] == 2
def... | 1,546 | 25.672414 | 77 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect/espnet_wer_calculation/eval_perm_free_error.py | #!/usr/bin/env python3
# encoding: utf-8
# Copyright 2019 Johns Hopkins University (Xuankai Chang)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
import argparse
import codecs
import json
import logging
import re
import six
import sys
import numpy as np
def permutationDFS(source, start, res):
# get... | 6,548 | 26.75 | 83 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect/espnet_wer_calculation/json2trn.py | #!/usr/bin/env python3
# encoding: utf-8
# Copyright 2017 Johns Hopkins University (Shinji Watanabe)
# 2018 Xuankai Chang (Shanghai Jiao Tong University)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
import argparse
import codecs
import json
import logging
import sys
from cli_utils import get... | 3,758 | 34.130841 | 88 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect/espnet_wer_calculation/filt.py | #!/usr/bin/env python3
# Apache 2.0
import argparse
import codecs
import sys
is_python2 = sys.version_info[0] == 2
def get_parser():
parser = argparse.ArgumentParser(
description="filter words in a text file",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument... | 1,745 | 25.059701 | 76 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect/espnet_wer_calculation/cli_utils.py | from collections.abc import Sequence
from distutils.util import strtobool as dist_strtobool
import sys
import numpy
def strtobool(x):
# distutils.util.strtobool returns integer, but it's confusing,
return bool(dist_strtobool(x))
def get_commandline_args():
extra_chars = [
" ",
";",
... | 1,380 | 19.924242 | 81 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/modules/stft_loss.py | # -*- coding: utf-8 -*-
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Copyright 2019 Tomoki Hayashi
# MIT License (https://opensource.org/licenses/MIT)
"""STFT-based Loss modules."""
import librosa
import torch
from parallel_wavegan.losses import LogSTFTMagnitudeLoss, SpectralConvergen... | 3,470 | 32.375 | 105 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/modules/tts_modules.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import math
import logging
import torch
import torch.nn as nn
from torch.nn import functional as F
from modules.operations import SinusoidalPositionalEmbedding, OPERATIONS_ENCODER, ConvSeparable
from utils.world_utils import build_activation
fr... | 17,051 | 37.579186 | 116 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/modules/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License. | 72 | 35.5 | 38 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/modules/lightspeech.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from modules.operations import *
from modules.tts_modules import TransformerEncoder, LightSpeechDecoder, DurationPredictor, LengthRegulator, PitchPredictor, EnergyPredictor
import utils
from utils.world_utils import f0_to_coarse_torch, restore_pi... | 8,395 | 47.531792 | 139 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/modules/operations.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import math
import torch
from torch import nn
from torch.nn import Parameter
import torch.onnx.operators
import torch.nn.functional as F
import utils
from utils.hparams import hparams
from utils.world_utils import build_activation
def LayerNorm... | 24,598 | 41.930192 | 159 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/datasets/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License. | 72 | 35.5 | 38 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/datasets/tts/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import json
import os
from utils.text_encoder import TokenTextEncoder
def build_phone_encoder(data_dir):
phone_list_file = os.path.join(data_dir, 'phone_set.json')
phone_list = json.load(open(phone_list_file))
return TokenTextEncod... | 352 | 24.214286 | 62 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/datasets/tts/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License. | 72 | 35.5 | 38 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/datasets/tts/lj/gen.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import os
os.environ["OMP_NUM_THREADS"] = "1"
from datasets.tts.utils import build_phone_encoder
from utils.indexed_datasets import IndexedDatasetBuilder
import glob
import json
import logging
import sys
import traceback
from multiprocessing.po... | 4,476 | 35.696721 | 111 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/datasets/tts/lj/prepare.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import os
os.environ["OMP_NUM_THREADS"] = "1"
import json
import os
import re
import subprocess
from multiprocessing.pool import Pool
import pandas as pd
from g2p_en import G2p
from tqdm import tqdm
basedir = 'data/raw/LJSpeech-1.1'
g2p = G2p... | 2,717 | 32.975 | 114 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/datasets/tts/lj/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License. | 72 | 35.5 | 38 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/utils/stft.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch
import numpy as np
import torch.nn.functional as F
from torch.autograd import Variable
from scipy.signal import get_window
from librosa.util import pad_center, tiny
import librosa.util as librosa_util
def window_sumsquare(window, n... | 6,019 | 35.26506 | 97 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/utils/indexed_datasets.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import pickle
import numpy as np
class IndexedDataset:
def __init__(self, path):
super().__init__()
self.path = path
self.data_file = None
self.data_offsets = np.load(f"{path}.idx", allow_pickle=True).item()[... | 1,951 | 28.575758 | 87 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/utils/pl_utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import os
import re
import sys
import copy
import glob
import tqdm
import logging
import itertools
import subprocess
import threading
import traceback
from functools import wraps
import numpy as np
import torch
from torch.cuda._utils import _get... | 59,913 | 35.201813 | 122 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/utils/audio.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import librosa
import librosa.filters
import numpy as np
from scipy import signal
from scipy.io import wavfile
def save_wav(wav, path, sr, norm=False):
if norm:
... | 4,968 | 25.715054 | 116 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/utils/hparams.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import os
import argparse
import yaml
hparams = {}
class Args:
def __init__(self, **kwargs):
for k, v in kwargs.items():
self.__setattr__(k, v)
def set_hparams(use_cmd=True, config='', exp_name='', hparams_str=''):
... | 3,191 | 36.116279 | 99 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/utils/pwg_decode_from_mel.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import logging
import yaml
import numpy as np
from sklearn.preprocessing import StandardScaler
import torch
from torch import nn
import utils
from parallel_wavegan.models import ParallelWaveGANGenerator
from parallel_wavegan.utils import read_h... | 2,401 | 33.811594 | 110 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/utils/plot.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import matplotlib.pyplot as plt
import numpy as np
def spec_numpy_to_figure(spec):
fig = plt.figure(figsize=(8, 4))
plt.imshow(spec.T, aspect='auto', origin='lower')
return fig
def numpy_to_figure(numpy_data):
fig = plt.figure(... | 1,349 | 24.471698 | 65 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/utils/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import os
import sys
import glob
import logging
import re
import time
from collections import defaultdict
import shutil
import types
import numpy as np
import torch
import torch.nn.functional as F
import torch.distributed as dist
def reduce_te... | 16,922 | 29.994505 | 114 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/utils/text_encoder.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import re
import six
from six.moves import range # pylint: disable=redefined-builtin
PAD = "<pad>"
EOS = "<EOS>"
UNK = "<UNK>"
SEG = "|"
RESERVED_TOKENS = [PAD, EOS, UNK]
NUM_RESERVED_TOKENS = len(RESERVED_TOKENS)
PAD_ID = RESERVED_TOKENS.index... | 10,163 | 32.434211 | 95 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/utils/text_norm.py | # coding=utf-8
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Authors:
# 2019.5 Zhiyang Zhou (https://github.com/Joee1995/chn_text_norm.git)
# 2019.9 Jiayu DU
#
# requirements:
# - python 3.X
# notes: python 2.X WILL fail or produce misleading results
import sys, os, argparse, codec... | 27,012 | 33.021411 | 125 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/utils/parse_textgrid.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import re
import argparse
import json
from collections import OrderedDict
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--input", help="input path of textgrid")
parser.add_argument("--output", help="output... | 3,934 | 32.922414 | 111 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/utils/world_utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
##########
# world
##########
import numpy as np
import pysptk
import copy
import math
import torch
import torch.nn as nn
gamma = 0
mcepInput = 3 # 0 for dB, 3 for magnitude
alpha = 0.45
en_floor = 10 ** (-80 / 20)
FFT_SIZE = 2048
def code_h... | 6,554 | 27.25431 | 106 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/utils/preprocessor.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import json
import warnings
import struct
import webrtcvad
from skimage.transform import resize
from scipy.ndimage.morphology import binary_dilation
import pyworld as pw
import numpy as np
import torch
import librosa
import pyloudnorm as pyln
f... | 8,211 | 35.990991 | 107 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/utils/tts_utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch
from utils.stft import STFT
def make_pad_mask(lengths, xs=None, length_dim=-1):
"""Make mask tensor containing indices of padded part.
Args:
lengths (LongTensor or List): Batch of lengths (B,).
xs (Tensor, o... | 8,863 | 38.048458 | 84 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/tasks/base_task.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import os
import sys
import random
import logging
import matplotlib
matplotlib.use('Agg')
import numpy as np
import torch.distributed as dist
from pytorch_lightning.logging import TensorBoardLogger
from torch import nn
import torch.utils.data
i... | 11,465 | 31.207865 | 98 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/tasks/lightspeech_inference.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import os, glob, re
from tqdm import tqdm
import numpy as np
import torch
import utils
from utils.hparams import hparams, set_hparams
from tasks.lightspeech import LightSpeechDataset, LightSpeechTask
set_hparams()
def get_latest_ckpt(dir):
... | 2,707 | 37.685714 | 123 | py |
NeuralSpeech | NeuralSpeech-master/LightSpeech/tasks/lightspeech.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import os
import sys
import re
import glob
import logging
import json
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from multiprocessing.pool import Pool
from tqdm import tqdm
import numpy as np
import torch
import torc... | 37,184 | 44.681818 | 131 | py |
spiral | spiral-master/setup.py | #!/usr/bin/env python3
# =============================================================================
# @file setup.py
# @brief Spiral setup file
# @author Michael Hucka <mhucka@caltech.edu>
# @license Please see the file named LICENSE in the project directory
# @website https://github.com/casics/spiral
# ======... | 2,201 | 39.777778 | 146 | py |
spiral | spiral-master/tests/test_ronin.py | #!/usr/bin/env python3
import os
import pytest
import sys
from time import time
thisdir = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(thisdir, '..'))
from spiral import *
class TestClass:
def test_known_successes(self, capsys):
assert ronin.split('ABCFooBar') =... | 6,622 | 63.931373 | 91 | py |
spiral | spiral-master/tests/test_simple_splitters.py | #!/usr/bin/env python3
import os
import pytest
import sys
from time import time
try:
thisdir = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(thisdir, '..'))
except:
sys.path.append('..')
from spiral import *
inputs = [
'alllower',
'ALLUPPER',
'a_delimiter',
'a... | 4,789 | 16.545788 | 76 | py |
spiral | spiral-master/tests/test_samurai.py | #!/usr/bin/env python3 -O
import os
import pytest
import sys
from time import time
thisdir = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(thisdir, '..'))
from spiral import *
class TestClass:
def test_samurai(self, capsys):
assert samurai.split('somevar') ... | 3,498 | 62.618182 | 113 | py |
spiral | spiral-master/spiral/frequencies.py | '''
frequencies: code to handle word frequencies
'''
# Main code.
# .............................................................................
def frequencies_from_csv_file(filename, threshold=None, filter_words=None):
'''Read a table of frequencies (as a Python dictionary) from a CSV file.
Parameter 'th... | 3,283 | 39.04878 | 87 | py |
spiral | spiral-master/spiral/__main__.py | '''__main__: main entry point for command-line interface
This module implements a command-line interface to Spiral. It allows users
to invoke Spiral splitters from terminal shell command lines, to explore the
splitters or use them as part of toolchains.
Authors
-------
Michael Hucka <mhucka@caltech.edu>
Copyright
... | 5,316 | 38.095588 | 82 | py |
spiral | spiral-master/spiral/constants.py | '''
constants: constants used in Spiral splitters.
'''
common_suffix_numbers = {'16', '32', '64', '128', '256', '512', '1024'}
'''
List of numbers that are commonly put after some other strings, to form
symbols such as "int32", "float64", etc.
'''
# General principles for the following:
# 1. Only put in terms that at... | 12,408 | 20.885362 | 78 | py |
spiral | spiral-master/spiral/simple_splitters.py | '''simple_splitters: simple identifier splitters
This exports a number of simple splitter functions whose behaviors are
sightly different depending on what assumptions are made about identifier
patterns. All are simple in the sense that they do not make complicated
inferences about the string and at most (in the caus... | 12,485 | 51.462185 | 95 | py |
spiral | spiral-master/spiral/__version__.py | # =============================================================================
# @file __version__.py
# @brief CASICS Spiral version info
# @author Michael Hucka <mhucka@caltech.edu>
# @license Please see the file named LICENSE in the project directory
# @website https://github.com/casics/spiral
# ==============... | 970 | 52.944444 | 171 | py |
spiral | spiral-master/spiral/utils.py | # =============================================================================
# @file data_utils.py
# @brief CASICS Spiral internal utilities for dealing with data
# @author Michael Hucka <mhucka@caltech.edu>
# @license Please see the file named LICENSE in the project directory
# @website https://github.com/cas... | 1,213 | 40.862069 | 85 | py |
spiral | spiral-master/spiral/__init__.py | '''Spiral: SPlitters for IdentifieRs: A Library
Natural language processing (NLP) methods are increasingly being applied to
source code analysis for various purposes. The methods rely on terms
(identifiers and other textual strings) extracted from program source code
and comments. The methods often work better if, i... | 2,132 | 40.823529 | 80 | py |
spiral | spiral-master/spiral/samurai.py | '''
samurai: implementation of the Samurai algorithm for identifier splitting
Introduction
------------
Natural language processing (NLP) methods are increasingly being applied to
source code analysis for various purposes. The methods rely on terms
(identifiers and other textual strings) extracted from program sourc... | 13,606 | 40.358663 | 87 | py |
spiral | spiral-master/spiral/ronin.py | '''Ronin: an identifier splitter based on the Samurai algorithm
Introduction
------------
Spiral is a Python 3 package that implements numerous identifier splitting
algorithms. Identifier splitting is the task of breaking apart program
identifier strings such as 'getInt' or 'readUTF8stream' into component
tokens: ['... | 33,297 | 46.704871 | 90 | py |
lm-scorer | lm-scorer-master/lm_scorer/__init__.py | 0 | 0 | 0 | py | |
lm-scorer | lm-scorer-master/lm_scorer/models/auto.py | from typing import * # pylint: disable=wildcard-import,unused-wildcard-import
import itertools
from .abc.base import LMScorer
from .gpt2 import GPT2LMScorer
class AutoLMScorer:
MODEL_CLASSES = [GPT2LMScorer]
def __init__(self):
raise EnvironmentError(
"AutoLMscorer is designed to be in... | 1,093 | 30.257143 | 78 | py |
lm-scorer | lm-scorer-master/lm_scorer/models/gpt2.py | from typing import * # pylint: disable=wildcard-import,unused-wildcard-import
import torch
from transformers import AutoTokenizer, GPT2LMHeadModel
from transformers import GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP
from transformers.tokenization_utils import BatchEncoding
from .abc.transformers import TransformersLMScorer
... | 3,499 | 39.697674 | 85 | py |
lm-scorer | lm-scorer-master/lm_scorer/models/__init__.py | 0 | 0 | 0 | py | |
lm-scorer | lm-scorer-master/lm_scorer/models/abc/base.py | from typing import * # pylint: disable=wildcard-import,unused-wildcard-import
from abc import ABC, abstractmethod
import math
import torch
class LMScorer(ABC):
def __init__(self, model_name: str, **kwargs: Any) -> None:
self._build(model_name, kwargs)
@overload
def sentence_score(
self... | 3,273 | 30.480769 | 83 | py |
lm-scorer | lm-scorer-master/lm_scorer/models/abc/transformers.py | # pylint: disable=abstract-method
from typing import * # pylint: disable=wildcard-import,unused-wildcard-import
import os
from .batch import BatchedLMScorer
class TransformersLMScorer(BatchedLMScorer):
# @overrides
def _build(self, model_name: str, options: Dict[str, Any]) -> None:
super()._build(m... | 546 | 31.176471 | 83 | py |
lm-scorer | lm-scorer-master/lm_scorer/models/abc/batch.py | # pylint: disable=abstract-method
from typing import * # pylint: disable=wildcard-import,unused-wildcard-import
from abc import abstractmethod
import torch
from .base import LMScorer
class BatchedLMScorer(LMScorer):
# @overrides
def _build(self, model_name: str, options: Dict[str, Any]) -> None:
su... | 1,148 | 30.916667 | 78 | py |
lm-scorer | lm-scorer-master/lm_scorer/models/abc/__init__.py | 0 | 0 | 0 | py | |
lm-scorer | lm-scorer-master/lm_scorer/bin/cli.py | #!/usr/bin/env python3
from typing import * # pylint: disable=wildcard-import,unused-wildcard-import
import argparse
import itertools
import os
import sys
import torch
from ..models.auto import AutoLMScorer as LMScorer
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
descript... | 5,142 | 28.728324 | 88 | py |
lm-scorer | lm-scorer-master/lm_scorer/bin/__init__.py | 0 | 0 | 0 | py | |
lm-scorer | lm-scorer-master/tests/__init__.py | 0 | 0 | 0 | py | |
lm-scorer | lm-scorer-master/tests/unit/__init__.py | 0 | 0 | 0 | py | |
lm-scorer | lm-scorer-master/tests/unit/models/test_gpt2.py | # pylint: disable=missing-module-docstring,missing-function-docstring,unused-variable,too-many-locals,too-many-statements
import math
import pytest # pylint: disable=unused-import
from lm_scorer.models.gpt2 import GPT2LMScorer
def describe_init():
def should_throw_an_exception_for_an_unsupported_model_name():
... | 4,693 | 34.560606 | 121 | py |
lm-scorer | lm-scorer-master/tests/unit/models/__init__.py | 0 | 0 | 0 | py | |
lm-scorer | lm-scorer-master/tests/unit/models/test_auto.py | # pylint: disable=missing-module-docstring,missing-function-docstring,unused-variable,too-many-locals,too-many-statements
import pytest # pylint: disable=unused-import
from lm_scorer.models.auto import AutoLMScorer
from lm_scorer.models.gpt2 import GPT2LMScorer
def describe_init():
def should_throw_an_exception... | 1,037 | 34.793103 | 121 | py |
lm-scorer | lm-scorer-master/tests/unit/models/abc/test_batch.py | # pylint: disable=missing-module-docstring,missing-function-docstring,unused-variable,too-many-locals,too-many-statements
import pytest # pylint: disable=unused-import
from lm_scorer.models.abc.batch import BatchedLMScorer
class FixtureLMScorer(BatchedLMScorer):
def _tokens_log_prob_for_batch(self, text):
... | 772 | 29.92 | 121 | py |
lm-scorer | lm-scorer-master/tests/unit/models/abc/__init__.py | 0 | 0 | 0 | py | |
lm-scorer | lm-scorer-master/tests/unit/models/abc/test_base.py | # pylint: disable=missing-module-docstring,missing-function-docstring,unused-variable,too-many-locals,too-many-statements
import math
import pytest # pylint: disable=unused-import
import scipy
import torch
from lm_scorer.models.abc.base import LMScorer
def model(text):
tokens = ["START"] + text.split(" ")
s... | 4,467 | 35.325203 | 121 | py |
lm-scorer | lm-scorer-master/tests/integration/test_gpt2.py | # pylint: disable=missing-module-docstring,missing-function-docstring,unused-variable,too-many-locals,too-many-statements
import pytest # pylint: disable=unused-import
from lm_scorer.models.gpt2 import GPT2LMScorer
def assert_score_of_sentence_pairs(scorer, sentence_pairs):
errors = []
for i, (correct_sente... | 8,289 | 38.855769 | 121 | py |
lm-scorer | lm-scorer-master/tests/integration/__init__.py | 0 | 0 | 0 | py | |
espressopp | espressopp-master/testsuite/langevin_thermostat_on_radius/test_langevin_thermostat_on_radius.py | #!/usr/bin/env python2
#
# Copyright (C) 2013-2017(H)
# Max Planck Institute for Polymer Research
#
# This file is part of ESPResSo++.
#
# ESPResSo++ 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,... | 3,564 | 36.526316 | 162 | py |
espressopp | espressopp-master/testsuite/ewald/ewald_eppDeserno_comparison.py | #!/usr/bin/env python2
#
# Copyright (C) 2013-2017(H)
# Max Planck Institute for Polymer Research
#
# This file is part of ESPResSo++.
#
# ESPResSo++ 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,... | 7,543 | 37.294416 | 138 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.