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 |
|---|---|---|---|---|---|---|
deep-image-retrieval | deep-image-retrieval-master/dirtorch/utils/evaluation.py | '''Evaluation metrics
'''
import pdb
import numpy as np
import torch
def accuracy_topk(output, target, topk=(1,)):
"""Computes the precision@k for the specified values of k
output: torch.FloatTensoror np.array(float)
shape = B * L [* H * W]
L: number of possible labels
target: to... | 3,382 | 31.219048 | 124 | py |
deep-image-retrieval | deep-image-retrieval-master/dirtorch/utils/transforms.py | import pdb
import numpy as np
from PIL import Image, ImageOps
import torchvision.transforms as tvf
import random
from math import ceil
from . import transforms_tools as F
def create(cmd_line, to_tensor=False, **vars):
''' Create a sequence of transformations.
cmd_line: (str)
Comma-separated list of ... | 25,933 | 32.945026 | 133 | py |
luiaard | luiaard-master/prism/run.py | from multiprocessing import Pool
import subprocess
import shlex
import os
import argparse
def f(seed):
cmd = f"bin/prism {seed}"
p = subprocess.run(cmd, shell=True, env=dict(os.environ, PRISM_MAINCLASS="prism.LearnVerify"))
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_arg... | 528 | 25.45 | 98 | py |
luiaard | luiaard-master/prism/ext/lp_solve_5.5_java/demo/demo.py | # ###########################################################################
#
# Demo program that shows how to call lp_solve methods from a Python program
# via the Java wrapper. See README.html on how to run this programm with Jython.
#
# ###########################################################################
... | 4,652 | 26.052326 | 105 | py |
luiaard | luiaard-master/prism/etc/scripts/prism-pareto.py | #! /usr/bin/env python
# coding=utf-8
# run without arguments for usage info
import re
import sys
import os
from optparse import OptionParser
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.axes import Axes
import matplotlib.pyplot as plt
from matplotlib.collections import PolyCollect... | 1,748 | 21.714286 | 103 | py |
luiaard | luiaard-master/prism/etc/scripts/prism-filler.py | #! /usr/bin/env python
# coding=utf-8
# run without arguments for usage info
import re
import sys
import os
from optparse import OptionParser
list_of_files = []
directories = []
def treat_file_names(file) :
global list_of_files
#first get the actual string if a number or None is provided
if file is None :
fi... | 7,313 | 37.494737 | 239 | py |
luiaard | luiaard-master/prism/notebooks/plot_strength.py | import os
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from pandas.api.types import CategoricalDtype
from util import collect_csv_files
from util import get_plotting_arguments_parser
from util import get_related_configuration
from util import make_dprint
PRIOR_STRENGTH = "Prior Strength ... | 4,471 | 34.492063 | 130 | py |
luiaard | luiaard-master/prism/notebooks/plot_basic.py | import os
from math import log10
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from pandas.api.types import CategoricalDtype
from util import collect_csv_files
from util import export_legend
from util import get_plotting_arguments_parser
from util import get_related_conf... | 6,811 | 37.055866 | 113 | py |
luiaard | luiaard-master/prism/notebooks/util.py | import argparse
import datetime
import glob
import os
import yaml
from matplotlib import pyplot as plt
def collect_csv_files(includes, excludes, prefix, verbose):
exclude_files = []
for s in excludes:
exclude_pattern = os.path.join(prefix, s)
files = glob.glob(exclude_pattern)
if not ... | 3,620 | 32.220183 | 119 | py |
luiaard | luiaard-master/prism/notebooks/plot_switching.py | import os
from math import log10
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from pandas.api.types import CategoricalDtype
from util import collect_csv_files
from util import export_legend
from util import get_plotting_arguments_parser
from util import get_related_conf... | 5,923 | 35.795031 | 125 | py |
complex_RNN | complex_RNN-master/memory_problem.py | import cPickle
import gzip
import theano
import pdb
from fftconv import cufft, cuifft
import numpy as np
import theano.tensor as T
from theano.ifelse import ifelse
from models import *
from optimizations import *
import argparse, timeit
def generate_data(time_steps, n_data, n_sequence):
seq = np.random.randin... | 6,579 | 35.759777 | 120 | py |
complex_RNN | complex_RNN-master/adding_problem.py | import cPickle
import gzip
import theano
from fftconv import cufft, cuifft
import numpy as np
import theano.tensor as T
from theano.ifelse import ifelse
from models import *
from optimizations import *
import argparse
def generate_data(time_steps, n_data):
x = np.asarray(np.zeros((time_steps, int(n_data), 2))... | 6,693 | 34.417989 | 120 | py |
complex_RNN | complex_RNN-master/optimizations.py | import theano
import theano.tensor as T
import numpy as np
def clipped_gradients(gradients, gradient_clipping):
clipped_grads = [T.clip(g, -gradient_clipping, gradient_clipping)
for g in gradients]
return clipped_grads
def gradient_descent(learning_rate, parameters, gradients):
... | 1,369 | 37.055556 | 95 | py |
complex_RNN | complex_RNN-master/fftconv.py | import string
import numpy as np
import theano
import theano.tensor as T
from theano.sandbox.cuda import cuda_available, GpuOp
from theano.ifelse import ifelse
if cuda_available:
from theano.sandbox.cuda import (basic_ops, CudaNdarrayType,
CudaNdarray)
from theano.misc.pycuda... | 23,216 | 32.992679 | 130 | py |
complex_RNN | complex_RNN-master/models.py | import theano, cPickle
import theano.tensor as T
import numpy as np
from fftconv import cufft, cuifft
def initialize_matrix(n_in, n_out, name, rng):
bin = np.sqrt(6. / (n_in + n_out))
values = np.asarray(rng.uniform(low=-bin,
high=bin,
siz... | 16,904 | 40.231707 | 115 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-vocoder/inference.py | # Copyright 2022 (c) Microsoft Corporation. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | 9,379 | 44.533981 | 137 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-vocoder/__main__.py | # Copyright 2022 (c) Microsoft Corporation. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | 3,151 | 41.026667 | 107 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-vocoder/learner.py | # Copyright 2022 (c) Microsoft Corporation. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | 16,812 | 43.478836 | 146 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-vocoder/model.py | # Copyright 2022 (c) Microsoft Corporation. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | 7,288 | 38.4 | 116 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-vocoder/dataset.py | # Copyright 2022 (c) Microsoft Corporation. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | 8,838 | 42.328431 | 122 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-vocoder/__init__.py | 0 | 0 | 0 | py | |
NeuralSpeech | NeuralSpeech-master/PriorGrad-vocoder/params.py | # Copyright 2022 (c) Microsoft Corporation. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | 3,532 | 39.147727 | 117 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-vocoder/preprocess.py | # Copyright 2022 (c) Microsoft Corporation. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | 6,176 | 41.6 | 138 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect2/eval_aishell_nbest.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import json
import sys
import torch
import argparse
import re
#from fairseq.models.transformer import TransformerModel
import os
import os.path
import time
import json
import numpy as np
#os.environ["CUDA_VISIBLE_DEVICES"] = '1'
from fairseq impo... | 4,507 | 39.981818 | 248 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect2/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... | 50,130 | 42.974561 | 211 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect2/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,447 | 35.810289 | 146 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect2/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... | 5,757 | 37.386667 | 178 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect2/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 ... | 20,160 | 43.802222 | 120 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect2/FC_utils/preprocess_fc.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#!/usr/bin/env python3
# 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 an... | 14,629 | 35.393035 | 174 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect2/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
... | 14,093 | 36.684492 | 198 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect2/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 ... | 48,855 | 40.900515 | 212 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect2/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_2char = []
with open('sim_prun_char.txt', 'r', encoding='utf-8') as infile:
... | 15,963 | 46.93994 | 162 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect2/scripts/align_cal_werdur_fast.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#Usage python align_cal_werdur_fast.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 obtai... | 9,597 | 34.947566 | 204 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect2/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... | 14,497 | 35.427136 | 148 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect2/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,908 | 37.207729 | 134 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect2/FastCorrect/__init__.py | from . import fastcorrect_model
from . import fastcorrect_task
from . import fc_loss
| 85 | 20.5 | 31 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect2/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... | 47,075 | 40.957219 | 265 | py |
NeuralSpeech | NeuralSpeech-master/FastCorrect2/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/FastCorrect2/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/FastCorrect2/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/FastCorrect2/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/FastCorrect2/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/FastCorrect2/eval_data/align_test_offline.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import sys
import numpy as np
import copy
import random
import signal
import time
import os
def set_timeout(num, callback):
def wrap(func):
def handle(signum, frame):
raise RuntimeError
def to_do(*args, **kwar... | 47,764 | 40.105852 | 212 | py |
NeuralSpeech | NeuralSpeech-master/CMatchASR/distances.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch
def CORAL(source, target):
DEVICE = source.device
d = source.size(1)
ns, nt = source.size(0), target.size(0)
# source covariance
tmp_s = torch.ones((1, ns)).to(DEVICE) @ source
cs = (source.t() @ source - (t... | 2,742 | 38.185714 | 113 | py |
NeuralSpeech | NeuralSpeech-master/CMatchASR/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch
import logging
from espnet.asr.asr_utils import add_results_to_json
import argparse
import numpy as np
import collections
import json
def str2bool(str):
return True if str.lower() == 'true' else False
def setup_logging(verbose... | 10,200 | 36.503676 | 159 | py |
NeuralSpeech | NeuralSpeech-master/CMatchASR/ctc_aligner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Copyright 2019 Kyoto University (Hirofumi Inaguma)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
# https://github.com/hirofumi0810/neural_sp
import torch
import numpy as np
LOG_0 = -1e10
LOG_1 = 0
def np2tensor(array, device=Non... | 11,085 | 39.312727 | 113 | py |
NeuralSpeech | NeuralSpeech-master/CMatchASR/e2e_asr_udatransformer.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import collections
from espnet.nets.pytorch_backend.e2e_asr_transformer import *
from espnet.nets.pytorch_backend.e2e_asr_transformer import E2E as SpeechTransformer
from espnet.nets.pytorch_backend.transformer.encoder import *
from espnet.nets.p... | 31,542 | 43.741844 | 154 | py |
NeuralSpeech | NeuralSpeech-master/CMatchASR/data_load.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from espnet.utils.training.batchfy import make_batchset
from torch.utils.data import DataLoader
from torch.nn.utils.rnn import pad_sequence
import torch
import os
import json
import kaldiio
import random
import logging
import sentencepiece as spm... | 12,738 | 41.042904 | 134 | py |
NeuralSpeech | NeuralSpeech-master/CMatchASR/train.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import logging
import os
import collections
from espnet.bin.asr_train import get_parser
from espnet.utils.dynamic_import import dynamic_import
from espnet.utils.deterministic_utils import set_deterministic_pytorch
from espnet.asr.pytorch_backend.... | 19,142 | 45.919118 | 320 | py |
NeuralSpeech | NeuralSpeech-master/SoftCorrect/detect_error_token.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import sys
import numpy as np
import copy
import random
import signal
import time
import os
def set_timeout(num, callback):
def wrap(func):
def handle(signum, frame):
raise RuntimeError
def to_do(*args, **kwargs... | 49,510 | 41.244881 | 325 | py |
NeuralSpeech | NeuralSpeech-master/SoftCorrect/eval_detector.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import sys
import torch
import argparse
import re
from fairseq.models.transformer import TransformerModel
import os
import os.path
import time
import json
import numpy as np
from fairseq import utils
utils.import_user_module(argparse.Namespace(... | 4,812 | 36.897638 | 177 | py |
NeuralSpeech | NeuralSpeech-master/SoftCorrect/eval_corrector.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import sys
import argparse
import torch
import re
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='./softcorrect'))
from softcorrect.softcorrect_... | 6,563 | 37.840237 | 194 | py |
NeuralSpeech | NeuralSpeech-master/SoftCorrect/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/SoftCorrect/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/SoftCorrect/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/SoftCorrect/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/SoftCorrect/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/SoftCorrect/sc_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,655 | 36.844156 | 201 | py |
NeuralSpeech | NeuralSpeech-master/SoftCorrect/sc_utils/train_sc.py | #!/usr/bin/env python3 -u
# 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.
"""
Train a new model on one or across mult... | 12,121 | 32.766017 | 93 | py |
NeuralSpeech | NeuralSpeech-master/SoftCorrect/sc_utils/softcorrect_corrector_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
... | 10,257 | 37.56391 | 134 | py |
NeuralSpeech | NeuralSpeech-master/SoftCorrect/sc_utils/checkpoint_utils_sc.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 collections
import logging
import os
import re
import traceba... | 21,532 | 36.125862 | 114 | py |
NeuralSpeech | NeuralSpeech-master/SoftCorrect/sc_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/SoftCorrect/sc_utils/trainer_sc.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.
"""
Train a network across multiple GPUs.
"""
import contextlib
imp... | 47,171 | 38.082022 | 178 | py |
NeuralSpeech | NeuralSpeech-master/SoftCorrect/sc_utils/data_utils_sc.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.
try:
from collections.abc import Iterable
except ImportError:
... | 20,635 | 35.140105 | 120 | py |
NeuralSpeech | NeuralSpeech-master/SoftCorrect/sc_utils/dictionary_sc.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
from multiprocessing impor... | 12,677 | 31.259542 | 87 | py |
NeuralSpeech | NeuralSpeech-master/SoftCorrect/sc_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/SoftCorrect/sc_utils/corrector_ds.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... | 48,975 | 43.082808 | 194 | py |
NeuralSpeech | NeuralSpeech-master/SoftCorrect/sc_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/SoftCorrect/softcorrect/softcorrect_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... | 21,359 | 36.408056 | 216 | py |
NeuralSpeech | NeuralSpeech-master/SoftCorrect/softcorrect/softcorrect_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... | 70,019 | 41.53949 | 289 | py |
NeuralSpeech | NeuralSpeech-master/SoftCorrect/softcorrect/softcorrect_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,985 | 37.956098 | 184 | py |
NeuralSpeech | NeuralSpeech-master/SoftCorrect/softcorrect/__init__.py | from . import softcorrect_loss
from . import softcorrect_model
from . import softcorrect_task
| 94 | 22.75 | 31 | py |
NeuralSpeech | NeuralSpeech-master/BinauralGrad/geowarp.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import sys
import librosa
import numpy as np
import scipy.linalg
from scipy.spatial.transform import Rotation as R
import torch as th
import torch.nn as nn
import torch.nn.functional as F
import soundfile
from binauralgrad.warping import Geometr... | 3,528 | 39.563218 | 121 | py |
NeuralSpeech | NeuralSpeech-master/BinauralGrad/metric.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import os
import argparse
import numpy as np
import torch as th
import torchaudio as ta
from src.binauralgrad.losses import L2Loss, AmplitudeLoss, PhaseLoss
import auraloss
import speechmetrics
import sys
result_folder = sys.argv[1]
ref_folder... | 3,130 | 35.835294 | 141 | py |
NeuralSpeech | NeuralSpeech-master/BinauralGrad/src/binauralgrad/inference.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import numpy as np
import os
import torch
import torchaudio
import math
from argparse import ArgumentParser
from binauralgrad.params import AttrDict
import binauralgrad.params as base_params
from binauralgrad.model import BinauralGrad
models = ... | 6,559 | 41.875817 | 198 | py |
NeuralSpeech | NeuralSpeech-master/BinauralGrad/src/binauralgrad/losses.py | """
Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
# reference: https://github.com/facebookresearch/BinauralSpeechSynthesis/blob/main/src/losses.py
import numpy as np
import t... | 9,657 | 39.751055 | 176 | py |
NeuralSpeech | NeuralSpeech-master/BinauralGrad/src/binauralgrad/warping.py | """
Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
# reference: https://github.com/facebookresearch/BinauralSpeechSynthesis/blob/main/src/warping.py
import torch as th
import... | 4,372 | 37.699115 | 101 | py |
NeuralSpeech | NeuralSpeech-master/BinauralGrad/src/binauralgrad/learner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import numpy as np
import os
import torch
import torch.nn as nn
from torch.nn.parallel import DistributedDataParallel
#from torch.utils.tensorboard import SummaryWriter
from tqdm import tqdm
from binauralgrad.losses import PhaseLoss
from binaura... | 8,812 | 40.375587 | 192 | py |
NeuralSpeech | NeuralSpeech-master/BinauralGrad/src/binauralgrad/model.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import scipy
from scipy.spatial.transform import Rotation as R
from math import sqrt
Linear = nn.Linear
ConvTranspose2d = nn.ConvTranspose2d
def Conv1d(*arg... | 7,085 | 35.715026 | 131 | py |
NeuralSpeech | NeuralSpeech-master/BinauralGrad/src/binauralgrad/dataset.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import numpy as np
import os
import random
import torch
import torchaudio
from glob import glob
from torch.utils.data.distributed import DistributedSampler
import torch.nn.functional as F
class BinauralConditionalDataset(torch.utils.data.Datase... | 4,826 | 39.90678 | 117 | py |
NeuralSpeech | NeuralSpeech-master/BinauralGrad/src/binauralgrad/mstft_loss.py | #Reference: https://github.com/csteinmetz1/auraloss
import torch
import numpy as np
import librosa.filters
import scipy.signal
class SumAndDifference(torch.nn.Module):
"""Sum and difference signal extraction module."""
def __init__(self):
"""Initialize sum and difference extraction module."""
... | 24,435 | 35.690691 | 133 | py |
NeuralSpeech | NeuralSpeech-master/BinauralGrad/src/binauralgrad/__init__.py | 0 | 0 | 0 | py | |
NeuralSpeech | NeuralSpeech-master/BinauralGrad/src/binauralgrad/params.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import numpy as np
class AttrDict(dict):
def __init__(self, *args, **kwargs):
super(AttrDict, self).__init__(*args, **kwargs)
self.__dict__ = self
def override(self, attrs):
if isinstance(attrs, dict):
self.__dict__.u... | 2,696 | 22.051282 | 67 | py |
NeuralSpeech | NeuralSpeech-master/BinauralGrad/src/binauralgrad/train.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from argparse import ArgumentParser
from torch.cuda import device_count
from torch.multiprocessing import spawn
from binauralgrad.learner import train, train_distributed
import binauralgrad.params as params_all
def _get_free_port():
import s... | 1,779 | 37.695652 | 107 | py |
NeuralSpeech | NeuralSpeech-master/AdapterASR/e2e_asr_adaptertransformer.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Copyright 2019 Shigeki Karita
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""Transformer speech recognition model (pytorch)."""
from argparse import Namespace
from distutils.util import strtobool
import logging
import math
im... | 42,330 | 40.058196 | 177 | py |
NeuralSpeech | NeuralSpeech-master/AdapterASR/balanced_sampler.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Reference: https://github.com/khornlund/pytorch-balanced-sampler
import torch
import torch.utils.data
import random
import collections
import logging
import numpy as np
from torch.utils.data.sampler import BatchSampler, WeightedRandomSampler
... | 2,341 | 38.033333 | 108 | py |
NeuralSpeech | NeuralSpeech-master/AdapterASR/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch
import logging
from espnet.asr.asr_utils import add_results_to_json
import argparse
import numpy as np
import collections
import json
def load_head_from_pretrained_model(model, model_path):
model_dict = torch.load(model_path, m... | 11,240 | 36.47 | 159 | py |
NeuralSpeech | NeuralSpeech-master/AdapterASR/data_load.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from espnet.utils.training.batchfy import make_batchset
from torch.utils.data import DataLoader
from torch.nn.utils.rnn import pad_sequence
import torch
import os
import json
import kaldiio
import random
import logging
import sentencepiece as spm... | 13,293 | 35.223433 | 113 | py |
NeuralSpeech | NeuralSpeech-master/AdapterASR/train.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import logging
import os
import collections
from espnet.bin.asr_train import get_parser
from espnet.utils.dynamic_import import dynamic_import
from espnet.utils.deterministic_utils import set_deterministic_pytorch
from espnet.asr.pytorch_backend.... | 25,635 | 46.650558 | 144 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/modules/diffusion.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# The diffusion acoustic decoder module is based on the DiffWave architecture: https://github.com/lmnt-com/diffwave
# Copyright 2020 LMNT, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not... | 8,890 | 39.04955 | 185 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/modules/base.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import numpy as np
import torch
class BaseModule(torch.nn.Module):
def __init__(self):
super(BaseModule, self).__init__()
@property
def nparams(self):
"""
Returns number of trainable parameters of the module... | 893 | 26.090909 | 73 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/modules/tts_modules.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import logging
import torch
import torch.nn as nn
from torch.nn import functional as F
from modules.operations import SinusoidalPositionalEmbedding, OPERATIONS_ENCODER, OPERATIONS_DECODER
from tts_utils.hparams import hparams
DEFAULT_MAX_SOURC... | 14,686 | 37.447644 | 116 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/modules/__init__.py | 0 | 0 | 0 | py | |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/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 tts_utils
from tts_utils.hparams import hparams
class SelfAttention(nn.Module):
def __init__(sel... | 53,222 | 40.64554 | 120 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/modules/priorgrad.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from modules.operations import *
from modules.tts_modules import DurationPredictor, LengthRegulator, PitchPredictor, EnergyPredictor,\
TransformerEncoderLayer, DEFAULT_MAX_SOURCE_POSITIONS
from modules.diffusion import DiffDecoder
from tts_ut... | 17,248 | 46.913889 | 171 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/tts_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
from torchaudio.transforms impo... | 6,068 | 35.341317 | 97 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/tts_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,950 | 29.015385 | 87 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/tts_utils/pl_utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import matplotlib
from torch.nn import DataParallel
from torch.nn.parallel import DistributedDataParallel
matplotlib.use('Agg')
import glob
import itertools
import subprocess
import threading
import traceback
from pytorch_lightning.callbacks im... | 58,649 | 34.959534 | 122 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/tts_utils/audio.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import traceback
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import librosa
import librosa.filters
import numpy as np
import torch
from scipy import signal
from scipy.io import wavfile
def save_wav(wav, path, sr, n... | 4,999 | 25.455026 | 116 | py |
NeuralSpeech | NeuralSpeech-master/PriorGrad-acoustic/tts_utils/hparams.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import argparse
import os
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,491 | 36.956522 | 101 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.