repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
a3t-dev_richard | a3t-dev_richard/test/espnet2/gan_tts/melgan/test_melgan.py | # Copyright 2021 Tomoki Hayashi
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""Test code for MelGAN modules."""
import numpy as np
import pytest
import torch
from espnet2.gan_tts.hifigan.loss import DiscriminatorAdversarialLoss
from espnet2.gan_tts.hifigan.loss import FeatureMatchLoss
from espnet2.ga... | 4,711 | 29.205128 | 82 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/gan_tts/wavenet/test_wavenet.py | # Copyright 2021 Tomoki Hayashi
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""Test code for WaveNet modules."""
import pytest
import torch
from espnet2.gan_tts.wavenet import WaveNet
def make_wavenet_args(**kwargs):
defaults = dict(
in_channels=1,
out_channels=1,
kernel... | 1,768 | 25.014706 | 76 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/gan_tts/joint/test_joint_text2wav.py | # Copyright 2021 Tomoki Hayashi
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""Test VITS related modules."""
from distutils.version import LooseVersion
import pytest
import torch
from espnet2.gan_tts.joint import JointText2Wav
def make_text2mel_args(**kwargs):
defaults = dict(
text2mel... | 18,284 | 32.489011 | 88 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/gan_tts/style_melgan/test_style_melgan.py | # Copyright 2021 Tomoki Hayashi
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""Test code for StyleMelGAN modules."""
import numpy as np
import pytest
import torch
from espnet2.gan_tts.hifigan.loss import DiscriminatorAdversarialLoss
from espnet2.gan_tts.hifigan.loss import GeneratorAdversarialLoss
fr... | 4,405 | 28.77027 | 82 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/gan_tts/hifigan/test_hifigan.py | # Copyright 2021 Tomoki Hayashi
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""Test code for HiFi-GAN modules."""
import numpy as np
import pytest
import torch
from espnet2.gan_tts.hifigan import HiFiGANGenerator
from espnet2.gan_tts.hifigan import HiFiGANMultiScaleMultiPeriodDiscriminator
from espne... | 6,392 | 30.338235 | 82 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/gan_tts/vits/test_generator.py | # Copyright 2021 Tomoki Hayashi
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""Test VITS generator modules."""
from distutils.version import LooseVersion
import pytest
import torch
from espnet2.gan_tts.vits.generator import VITSGenerator
def make_generator_args(**kwargs):
defaults = dict(
... | 11,360 | 32.122449 | 80 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/gan_tts/vits/test_vits.py | # Copyright 2021 Tomoki Hayashi
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""Test VITS related modules."""
from distutils.version import LooseVersion
import pytest
import torch
from espnet2.gan_tts.vits import VITS
def make_vits_generator_args(**kwargs):
defaults = dict(
generator_ty... | 35,675 | 33.270893 | 88 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/gan_tts/parallel_wavegan/test_parallel_wavegan.py | # Copyright 2021 Tomoki Hayashi
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""Test code for ParallelWaveGAN modules."""
import numpy as np
import pytest
import torch
from espnet2.gan_tts.hifigan.loss import DiscriminatorAdversarialLoss
from espnet2.gan_tts.hifigan.loss import GeneratorAdversarialLos... | 4,596 | 28.280255 | 86 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/enh/test_espnet_model.py | from distutils.version import LooseVersion
import pytest
import torch
from espnet2.enh.decoder.conv_decoder import ConvDecoder
from espnet2.enh.decoder.stft_decoder import STFTDecoder
from espnet2.enh.encoder.conv_encoder import ConvEncoder
from espnet2.enh.encoder.stft_encoder import STFTEncoder
from espnet2.enh.esp... | 9,082 | 31.90942 | 87 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/enh/separator/test_beamformer.py | from distutils.version import LooseVersion
import pytest
import torch
from espnet2.enh.encoder.stft_encoder import STFTEncoder
from espnet2.enh.separator.neural_beamformer import NeuralBeamformer
is_torch_1_9_plus = LooseVersion(torch.__version__) >= LooseVersion("1.9.0")
random_speech = torch.tensor(
[
... | 10,001 | 33.136519 | 87 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/enh/separator/test_tcn_separator.py | import pytest
import torch
from torch import Tensor
from torch_complex import ComplexTensor
from espnet2.enh.separator.tcn_separator import TCNSeparator
@pytest.mark.parametrize("input_dim", [5])
@pytest.mark.parametrize("bottleneck_dim", [5])
@pytest.mark.parametrize("hidden_dim", [5])
@pytest.mark.parametrize("ke... | 3,690 | 25.364286 | 77 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/enh/separator/test_dprnn_separator.py | import pytest
import torch
from torch import Tensor
from torch_complex import ComplexTensor
from espnet2.enh.separator.dprnn_separator import DPRNNSeparator
@pytest.mark.parametrize("input_dim", [5])
@pytest.mark.parametrize("rnn_type", ["lstm", "gru"])
@pytest.mark.parametrize("layer", [1, 3])
@pytest.mark.paramet... | 3,670 | 25.601449 | 77 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/enh/separator/test_transformer_separator.py | import pytest
import torch
from torch import Tensor
from torch_complex import ComplexTensor
from espnet2.enh.separator.transformer_separator import TransformerSeparator
@pytest.mark.parametrize("input_dim", [5])
@pytest.mark.parametrize("num_spk", [1, 2])
@pytest.mark.parametrize("adim", [8])
@pytest.mark.parametri... | 4,851 | 29.325 | 77 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/enh/separator/test_conformer_separator.py | import pytest
import torch
from torch import Tensor
from torch_complex.tensor import ComplexTensor
from espnet2.enh.separator.conformer_separator import ConformerSeparator
@pytest.mark.parametrize("input_dim", [15])
@pytest.mark.parametrize("num_spk", [1, 2])
@pytest.mark.parametrize("adim", [8])
@pytest.mark.param... | 7,308 | 34.139423 | 77 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/enh/separator/test_rnn_separator.py | import pytest
import torch
from torch import Tensor
from torch_complex import ComplexTensor
from espnet2.enh.separator.rnn_separator import RNNSeparator
@pytest.mark.parametrize("input_dim", [5])
@pytest.mark.parametrize("rnn_type", ["blstm"])
@pytest.mark.parametrize("layer", [1, 3])
@pytest.mark.parametrize("unit... | 3,067 | 26.63964 | 77 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/enh/layers/test_complex_utils.py | from distutils.version import LooseVersion
import numpy as np
import pytest
import torch
import torch_complex.functional as FC
from torch_complex.tensor import ComplexTensor
from espnet2.enh.layers.complex_utils import einsum
from espnet2.enh.layers.complex_utils import inverse
from espnet2.enh.layers.complex_utils i... | 4,902 | 34.021429 | 88 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/enh/layers/test_enh_layers.py | from distutils.version import LooseVersion
import pytest
import torch
import torch_complex.functional as FC
from torch_complex.tensor import ComplexTensor
from espnet2.enh.layers.beamformer import get_rtf
from espnet2.enh.layers.beamformer import signal_framing
from espnet2.layers.stft import Stft
is_torch_1_1_plus ... | 5,172 | 42.108333 | 81 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/enh/encoder/test_stft_encoder.py | import pytest
import torch
from espnet2.enh.encoder.stft_encoder import STFTEncoder
@pytest.mark.parametrize("n_fft", [512])
@pytest.mark.parametrize("win_length", [512])
@pytest.mark.parametrize("hop_length", [128])
@pytest.mark.parametrize("window", ["hann"])
@pytest.mark.parametrize("center", [True])
@pytest.mark... | 1,075 | 25.9 | 62 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/enh/encoder/test_conv_encoder.py | import pytest
import torch
from espnet2.enh.encoder.conv_encoder import ConvEncoder
@pytest.mark.parametrize("channel", [64])
@pytest.mark.parametrize("kernel_size", [10, 20])
@pytest.mark.parametrize("stride", [5, 10])
def test_ConvEncoder_backward(channel, kernel_size, stride):
encoder = ConvEncoder(
c... | 545 | 25 | 60 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/enh/decoder/test_conv_decoder.py | import pytest
import torch
from espnet2.enh.decoder.conv_decoder import ConvDecoder
@pytest.mark.parametrize("channel", [64])
@pytest.mark.parametrize("kernel_size", [10, 20])
@pytest.mark.parametrize("stride", [5, 10])
def test_ConvEncoder_backward(channel, kernel_size, stride):
decoder = ConvDecoder(
c... | 608 | 25.478261 | 82 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/enh/decoder/test_stft_decoder.py | import pytest
import torch
from torch_complex import ComplexTensor
from espnet2.enh.decoder.stft_decoder import STFTDecoder
@pytest.mark.parametrize("n_fft", [512])
@pytest.mark.parametrize("win_length", [512])
@pytest.mark.parametrize("hop_length", [128])
@pytest.mark.parametrize("window", ["hann"])
@pytest.mark.p... | 2,069 | 32.387097 | 88 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/torch_utils/test_pytorch_version.py | from espnet2.torch_utils.pytorch_version import pytorch_cudnn_version
def test_pytorch_cudnn_version():
print(pytorch_cudnn_version())
| 141 | 22.666667 | 69 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/torch_utils/test_set_all_random_seed.py | from espnet2.torch_utils.set_all_random_seed import set_all_random_seed
def test_set_all_random_seed():
set_all_random_seed(0)
| 133 | 21.333333 | 71 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/torch_utils/test_add_gradient_noise.py | import torch
from espnet2.torch_utils.add_gradient_noise import add_gradient_noise
def test_add_gradient_noise():
linear = torch.nn.Linear(1, 1)
linear(torch.rand(1, 1)).sum().backward()
add_gradient_noise(linear, 100)
| 234 | 22.5 | 69 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/torch_utils/test_model_summary.py | import torch
from espnet2.torch_utils.model_summary import model_summary
class Model(torch.nn.Module):
def __init__(self):
super().__init__()
self.l1 = torch.nn.Linear(1000, 1000)
self.l2 = torch.nn.Linear(1000, 1000)
self.l3 = torch.nn.Linear(1000, 1000)
def test_model_summary(... | 357 | 21.375 | 59 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/torch_utils/test_initialize.py | import pytest
import torch
from espnet2.torch_utils.initialize import initialize
initialize_types = {}
class Model(torch.nn.Module):
def __init__(self):
super().__init__()
self.conv1 = torch.nn.Conv2d(2, 2, 3)
self.l1 = torch.nn.Linear(2, 2)
self.rnn_cell = torch.nn.LSTMCell(2, 2... | 1,083 | 20.68 | 53 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/torch_utils/test_load_pretrained_model.py | import numpy as np
import torch
from espnet2.torch_utils.load_pretrained_model import load_pretrained_model
class Model(torch.nn.Module):
def __init__(self):
super().__init__()
self.layer1 = torch.nn.Linear(1, 1)
self.layer2 = torch.nn.Linear(2, 2)
def test_load_pretrained_model_all(tmp... | 2,070 | 29.910448 | 84 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/torch_utils/test_forward_adaptor.py | import pytest
import torch
from espnet2.torch_utils.forward_adaptor import ForwardAdaptor
class Model(torch.nn.Module):
def func(self, x):
return x
def test_ForwardAdaptor():
model = Model()
x = torch.randn(2, 2)
assert (ForwardAdaptor(model, "func")(x) == x).all()
def test_ForwardAdaptor... | 424 | 18.318182 | 62 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/torch_utils/test_device_funcs.py | import dataclasses
from typing import NamedTuple
import pytest
import torch
from espnet2.torch_utils.device_funcs import force_gatherable
from espnet2.torch_utils.device_funcs import to_device
x = torch.tensor(10)
@dataclasses.dataclass(frozen=True)
class Data:
x: torch.Tensor
class Named(NamedTuple):
x:... | 1,319 | 22.571429 | 81 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/main_funcs/test_average_nbest_models.py | import pytest
import torch
from espnet2.main_funcs.average_nbest_models import average_nbest_models
from espnet2.train.reporter import Reporter
@pytest.fixture
def reporter():
_reporter = Reporter()
_reporter.set_epoch(1)
with _reporter.observe("valid") as sub:
sub.register({"acc": 0.4})
... | 1,927 | 27.352941 | 72 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/main_funcs/test_calculate_all_attentions.py | from collections import defaultdict
import numpy as np
import pytest
import torch
from espnet.nets.pytorch_backend.rnn.attentions import AttAdd
from espnet.nets.pytorch_backend.transformer.attention import MultiHeadedAttention
from espnet2.asr.decoder.rnn_decoder import RNNDecoder
from espnet2.main_funcs.calculate_al... | 2,743 | 28.505376 | 87 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/bin/test_enh_inference.py | from argparse import ArgumentParser
from pathlib import Path
import pytest
import torch
from espnet2.bin.enh_inference import get_parser
from espnet2.bin.enh_inference import main
from espnet2.bin.enh_inference import SeparateSpeech
from espnet2.tasks.enh import EnhancementTask
def test_get_parser():
assert isi... | 1,368 | 24.830189 | 88 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/hubert/test_hubert_loss.py | import pytest
import torch
from espnet2.hubert.hubert_loss import HubertPretrainLoss # noqa: H301
from espnet2.asr.encoder.hubert_encoder import (
FairseqHubertPretrainEncoder, # noqa: H301
)
@pytest.fixture
def hubert_args():
encoder = FairseqHubertPretrainEncoder(
output_size=32,
linear_u... | 1,026 | 25.333333 | 71 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/layers/test_global_mvn.py | from pathlib import Path
import numpy as np
import pytest
import torch
from espnet2.layers.global_mvn import GlobalMVN
@pytest.fixture()
def stats_file(tmp_path: Path):
"""Kaldi like style"""
p = tmp_path / "stats.npy"
count = 10
np.random.seed(0)
x = np.random.randn(count, 80)
s = x.sum(0)... | 3,459 | 27.833333 | 79 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/layers/test_stft.py | import torch
from espnet2.layers.stft import Stft
def test_repr():
print(Stft())
def test_forward():
layer = Stft(win_length=4, hop_length=2, n_fft=4)
x = torch.randn(2, 30)
y, _ = layer(x)
assert y.shape == (2, 16, 3, 2)
y, ylen = layer(x, torch.tensor([30, 15], dtype=torch.long))
asse... | 903 | 21.04878 | 66 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/layers/test_utterance_mvn.py | import pytest
import torch
from espnet2.layers.utterance_mvn import UtteranceMVN
def test_repr():
print(UtteranceMVN())
@pytest.mark.parametrize(
"norm_vars, norm_means",
[(True, True), (False, False), (True, False), (False, True)],
)
def test_forward(norm_vars, norm_means):
layer = UtteranceMVN(no... | 1,268 | 27.2 | 68 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/layers/test_sinc_filters.py | import torch
from espnet2.layers.sinc_conv import BarkScale
from espnet2.layers.sinc_conv import LogCompression
from espnet2.layers.sinc_conv import MelScale
from espnet2.layers.sinc_conv import SincConv
def test_log_compression():
activation = LogCompression()
x = torch.randn([5, 20, 1, 40], requires_grad=T... | 1,644 | 26.881356 | 76 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/layers/test_log_mel.py | import torch
from espnet2.layers.log_mel import LogMel
def test_repr():
print(LogMel())
def test_forward():
layer = LogMel(n_fft=16, n_mels=2)
x = torch.randn(2, 4, 9)
y, _ = layer(x)
assert y.shape == (2, 4, 2)
y, ylen = layer(x, torch.tensor([4, 2], dtype=torch.long))
assert (ylen == ... | 708 | 21.15625 | 65 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/layers/test_label_aggregation.py | import pytest
import torch
from espnet2.layers.label_aggregation import LabelAggregate
@pytest.mark.parametrize(
("input_label", "expected_output"),
[
(torch.ones(10, 20000, 2), torch.ones(10, 157, 2)),
(torch.zeros(10, 20000, 2), torch.zeros(10, 157, 2)),
],
)
def test_LabelAggregate(inp... | 700 | 29.478261 | 81 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/layers/test_mask_along_axis.py | import pytest
import torch
from espnet2.layers.mask_along_axis import MaskAlongAxis
@pytest.mark.parametrize("requires_grad", [False, True])
@pytest.mark.parametrize("replace_with_zero", [False, True])
@pytest.mark.parametrize("dim", ["freq", "time"])
def test_MaskAlongAxis(dim, replace_with_zero, requires_grad):
... | 1,043 | 28.828571 | 62 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/layers/test_time_warp.py | import pytest
import torch
from espnet2.layers.time_warp import TimeWarp
@pytest.mark.parametrize("x_lens", [None, torch.tensor([80, 78])])
@pytest.mark.parametrize("requires_grad", [False, True])
def test_TimeWarp(x_lens, requires_grad):
time_warp = TimeWarp(window=10)
x = torch.randn(2, 100, 80, requires_g... | 600 | 26.318182 | 66 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/train/test_distributed_utils.py | import argparse
from concurrent.futures.process import ProcessPoolExecutor
from concurrent.futures.thread import ThreadPoolExecutor
import unittest.mock
import pytest
from espnet2.tasks.abs_task import AbsTask
from espnet2.train.distributed_utils import DistributedOption
from espnet2.train.distributed_utils import fr... | 11,669 | 27.325243 | 78 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/train/test_reporter.py | import logging
from pathlib import Path
import uuid
import numpy as np
import pytest
import torch
from torch.utils.tensorboard import SummaryWriter
from espnet2.train.reporter import aggregate
from espnet2.train.reporter import Average
from espnet2.train.reporter import ReportedValue
from espnet2.train.reporter impor... | 12,189 | 25.385281 | 78 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/asr/test_ctc.py | import pytest
import torch
from espnet2.asr.ctc import CTC
@pytest.fixture
def ctc_args():
bs = 2
h = torch.randn(bs, 10, 10)
h_lens = torch.LongTensor([10, 8])
y = torch.randint(0, 4, [2, 5])
y_lens = torch.LongTensor([5, 2])
return h, h_lens, y, y_lens
@pytest.mark.parametrize("ctc_type",... | 1,135 | 28.128205 | 65 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/asr/postencoder/test_hugging_face_transformers_postencoder.py | import pytest
import torch
from espnet2.asr.postencoder.hugging_face_transformers_postencoder import (
HuggingFaceTransformersPostEncoder, # noqa: H301
)
@pytest.mark.parametrize(
"model_name_or_path",
[
"akreal/tiny-random-bert",
"akreal/tiny-random-gpt2",
"akreal/tiny-random-xl... | 1,492 | 32.177778 | 84 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/asr/specaug/test_specaug.py | import pytest
import torch
from espnet2.asr.specaug.specaug import SpecAug
@pytest.mark.parametrize("apply_time_warp", [False, True])
@pytest.mark.parametrize("apply_freq_mask", [False, True])
@pytest.mark.parametrize("apply_time_mask", [False, True])
def test_SpecAuc(apply_time_warp, apply_freq_mask, apply_time_mas... | 1,385 | 33.65 | 75 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/asr/frontend/test_s3prl.py | from distutils.version import LooseVersion
import os
import torch
is_torch_1_7_plus = LooseVersion(torch.__version__) >= LooseVersion("1.7.0")
if is_torch_1_7_plus:
from s3prl.upstream.interfaces import Featurizer
def test_frontend_output_size():
# Skip some testing cases
if not is_torch_1_7_plus:
... | 1,020 | 23.309524 | 76 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/asr/frontend/test_windowing.py | import torch
from espnet2.asr.frontend.windowing import SlidingWindow
def test_frontend_output_size():
win_length = 400
frontend = SlidingWindow(win_length=win_length, hop_length=32, fs="16k")
assert frontend.output_size() == win_length
def test_frontend_forward():
frontend = SlidingWindow(fs=160, ... | 694 | 30.590909 | 77 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/asr/frontend/test_frontend.py | import pytest
import torch
from espnet2.asr.frontend.default import DefaultFrontend
def test_frontend_repr():
frontend = DefaultFrontend(fs="16k")
print(frontend)
def test_frontend_output_size():
frontend = DefaultFrontend(fs="16k", n_mels=40)
assert frontend.output_size() == 40
def test_frontend... | 1,249 | 26.777778 | 77 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/asr/preencoder/test_sinc.py | from espnet2.asr.preencoder.sinc import LightweightSincConvs
from espnet2.asr.preencoder.sinc import SpatialDropout
import torch
def test_spatial_dropout():
dropout = SpatialDropout()
x = torch.randn([5, 20, 40], requires_grad=True)
y = dropout(x)
assert x.shape == y.shape
def test_lightweight_sinc_... | 1,041 | 31.5625 | 66 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/asr/preencoder/test_linear.py | from espnet2.asr.preencoder.linear import LinearProjection
import torch
def test_linear_projection_forward():
idim = 400
odim = 80
preencoder = LinearProjection(input_size=idim, output_size=odim)
x = torch.randn([2, 50, idim], requires_grad=True)
x_lengths = torch.LongTensor([30, 15])
y, y_len... | 468 | 30.266667 | 68 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/asr/encoder/test_rnn_encoder.py | import pytest
import torch
from espnet2.asr.encoder.rnn_encoder import RNNEncoder
@pytest.mark.parametrize("rnn_type", ["lstm", "gru"])
@pytest.mark.parametrize("bidirectional", [True, False])
@pytest.mark.parametrize("use_projection", [True, False])
@pytest.mark.parametrize("subsample", [None, (2, 2, 1, 1)])
def te... | 947 | 27.727273 | 86 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/asr/encoder/test_contextual_block_transformer_encoder.py | import pytest
import torch
from espnet2.asr.encoder.contextual_block_transformer_encoder import (
ContextualBlockTransformerEncoder, # noqa: H301
)
@pytest.mark.parametrize("input_layer", ["linear", "conv2d", "embed", None])
@pytest.mark.parametrize("positionwise_layer_type", ["conv1d", "conv1d-linear"])
def te... | 1,574 | 28.716981 | 80 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/asr/encoder/test_conformer_encoder.py | import pytest
import torch
from espnet2.asr.encoder.conformer_encoder import ConformerEncoder
@pytest.mark.parametrize(
"input_layer", ["linear", "conv2d", "conv2d2", "conv2d6", "conv2d8", "embed"]
)
@pytest.mark.parametrize("positionwise_layer_type", ["conv1d", "conv1d-linear"])
@pytest.mark.parametrize(
"r... | 2,774 | 28.83871 | 81 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/asr/encoder/test_vgg_rnn_encoder.py | import pytest
import torch
from espnet2.asr.encoder.vgg_rnn_encoder import VGGRNNEncoder
@pytest.mark.parametrize("rnn_type", ["lstm", "gru"])
@pytest.mark.parametrize("bidirectional", [True, False])
@pytest.mark.parametrize("use_projection", [True, False])
def test_Encoder_forward_backward(rnn_type, bidirectional, ... | 838 | 28.964286 | 88 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/asr/encoder/test_transformer_encoder.py | import pytest
import torch
from espnet2.asr.encoder.transformer_encoder import TransformerEncoder
@pytest.mark.parametrize("input_layer", ["linear", "conv2d", "embed", None])
@pytest.mark.parametrize("positionwise_layer_type", ["conv1d", "conv1d-linear"])
def test_Encoder_forward_backward(input_layer, positionwise_l... | 1,065 | 29.457143 | 80 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/asr/decoder/test_transformer_decoder.py | import pytest
import torch
from espnet.nets.batch_beam_search import BatchBeamSearch
from espnet.nets.batch_beam_search_online_sim import BatchBeamSearchOnlineSim
from espnet.nets.beam_search import BeamSearch
from espnet.nets.scorers.ctc import CTCPrefixScorer
from espnet2.asr.ctc import CTC
from espnet2.asr.decoder.... | 8,327 | 30.908046 | 88 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/asr/decoder/test_rnn_decoder.py | import pytest
import torch
from espnet.nets.beam_search import BeamSearch
from espnet2.asr.decoder.rnn_decoder import RNNDecoder
@pytest.mark.parametrize("context_residual", [True, False])
@pytest.mark.parametrize("rnn_type", ["lstm", "gru"])
def test_RNNDecoder_backward(context_residual, rnn_type):
decoder = RN... | 2,206 | 31.940299 | 86 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/lm/test_seq_rnn_lm.py | import pytest
import torch
from espnet.nets.batch_beam_search import BatchBeamSearch
from espnet.nets.beam_search import BeamSearch
from espnet2.lm.seq_rnn_lm import SequentialRNNLM
@pytest.mark.parametrize("rnn_type", ["LSTM", "GRU", "RNN_TANH", "RNN_RELU"])
@pytest.mark.parametrize("tie_weights", [True, False])
de... | 3,110 | 30.424242 | 77 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/lm/test_transformer_lm.py | import pytest
import torch
from espnet.nets.batch_beam_search import BatchBeamSearch
from espnet.nets.beam_search import BeamSearch
from espnet2.lm.transformer_lm import TransformerLM
@pytest.mark.parametrize("pos_enc", ["sinusoidal", None])
def test_TransformerLM_backward(pos_enc):
model = TransformerLM(10, pos... | 2,457 | 27.581395 | 65 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/iterators/test_sequence_iter_factory.py | import pytest
import torch
from espnet2.iterators.sequence_iter_factory import SequenceIterFactory
class Dataset:
def __getitem__(self, item):
return item
def collate_func(x):
return torch.tensor(x)
@pytest.mark.parametrize("collate", [None, collate_func])
def test_SequenceIterFactory_larger_than... | 2,206 | 30.528571 | 86 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/tts/test_fastspeech.py | import pytest
import torch
from espnet2.tts.fastspeech import FastSpeech
@pytest.mark.parametrize("reduction_factor", [1, 3])
@pytest.mark.parametrize(
"spk_embed_dim, spk_embed_integration_type",
[(None, "add"), (2, "add"), (2, "concat")],
)
@pytest.mark.parametrize("encoder_type", ["transformer", "conforme... | 2,871 | 28.608247 | 80 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/tts/test_tacotron2.py | import pytest
import torch
from espnet2.tts.tacotron2 import Tacotron2
@pytest.mark.parametrize("prenet_layers", [0, 1])
@pytest.mark.parametrize("postnet_layers", [0, 1])
@pytest.mark.parametrize("reduction_factor", [1, 3])
@pytest.mark.parametrize(
"spk_embed_dim, spk_embed_integration_type",
[(None, "add"... | 2,798 | 26.99 | 63 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/tts/test_fastspeech2.py | import pytest
import torch
from espnet2.tts.fastspeech2 import FastSpeech2
@pytest.mark.parametrize("reduction_factor", [1, 3])
@pytest.mark.parametrize(
"spk_embed_dim, spk_embed_integration_type",
[(None, "add"), (2, "add"), (2, "concat")],
)
@pytest.mark.parametrize("encoder_type", ["transformer", "confor... | 3,903 | 32.084746 | 86 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/tts/test_transformer.py | import pytest
import torch
from espnet2.tts.transformer import Transformer
@pytest.mark.parametrize("eprenet_conv_layers", [0, 1])
@pytest.mark.parametrize("dprenet_layers", [0, 1])
@pytest.mark.parametrize("postnet_layers", [0, 1])
@pytest.mark.parametrize("reduction_factor", [1, 3])
@pytest.mark.parametrize(
"... | 3,311 | 28.052632 | 64 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/tts/feats_extract/test_dio.py | import pytest
import torch
from espnet2.tts.feats_extract.dio import Dio
@pytest.mark.parametrize("use_continuous_f0", [False, True])
@pytest.mark.parametrize("use_log_f0", [False, True])
@pytest.mark.parametrize(
"use_token_averaged_f0, reduction_factor", [(False, 1), (True, 1), (True, 3)]
)
def test_forward(
... | 1,928 | 27.367647 | 83 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/tts/feats_extract/test_linear_spectrogram.py | import numpy as np
import torch
from espnet2.tts.feats_extract.linear_spectrogram import LinearSpectrogram
from espnet2.tts.feats_extract.log_mel_fbank import LogMelFbank
def test_forward():
layer = LinearSpectrogram(n_fft=4, hop_length=1)
x = torch.randn(2, 4, 9)
y, _ = layer(x, torch.LongTensor([4, 3])... | 1,430 | 27.058824 | 74 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/tts/feats_extract/test_log_mel_fbank.py | import numpy as np
import torch
from espnet.transform.spectrogram import logmelspectrogram
from espnet2.tts.feats_extract.log_mel_fbank import LogMelFbank
def test_forward():
layer = LogMelFbank(n_fft=4, hop_length=1, n_mels=2)
x = torch.randn(2, 4, 9)
y, _ = layer(x, torch.LongTensor([4, 3]))
assert... | 1,422 | 28.040816 | 87 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/tts/feats_extract/test_energy.py | import pytest
import torch
from espnet2.tts.feats_extract.energy import Energy
@pytest.mark.parametrize(
"use_token_averaged_energy, reduction_factor", [(False, None), (True, 1), (True, 3)]
)
def test_forward(use_token_averaged_energy, reduction_factor):
layer = Energy(
n_fft=128,
hop_length=... | 1,718 | 29.157895 | 88 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/tts/feats_extract/test_log_spectrogram.py | import numpy as np
import torch
from espnet.transform.spectrogram import spectrogram
from espnet2.tts.feats_extract.log_spectrogram import LogSpectrogram
def test_forward():
layer = LogSpectrogram(n_fft=4, hop_length=1)
x = torch.randn(2, 4, 9)
y, _ = layer(x, torch.LongTensor([4, 3]))
assert y.shape... | 1,279 | 26.234043 | 68 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/optimizers/test_sgd.py | import torch
from espnet2.optimizers.sgd import SGD
def test_SGD():
linear = torch.nn.Linear(1, 1)
opt = SGD(linear.parameters())
x = torch.randn(1, 1)
linear(x).sum().backward()
opt.step()
| 213 | 16.833333 | 38 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/schedulers/test_warmup_lr.py | import numpy as np
import torch
from espnet2.schedulers.noam_lr import NoamLR
from espnet2.schedulers.warmup_lr import WarmupLR
def test_WarumupLR():
linear = torch.nn.Linear(2, 2)
opt = torch.optim.SGD(linear.parameters(), 0.1)
sch = WarmupLR(opt)
lr = opt.param_groups[0]["lr"]
opt.step()
s... | 1,134 | 24.222222 | 77 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/schedulers/test_noam_lr.py | import torch
from espnet2.schedulers.noam_lr import NoamLR
def test_NoamLR():
linear = torch.nn.Linear(2, 2)
opt = torch.optim.SGD(linear.parameters(), 0.1)
sch = NoamLR(opt)
lr = opt.param_groups[0]["lr"]
opt.step()
sch.step()
lr2 = opt.param_groups[0]["lr"]
assert lr != lr2
| 313 | 18.625 | 51 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/utils/test_sized_dict.py | import multiprocessing
import sys
import numpy as np
import pytest
import torch.multiprocessing
from espnet2.utils.sized_dict import get_size
from espnet2.utils.sized_dict import SizedDict
def test_get_size():
d = {}
x = np.random.randn(10)
d["a"] = x
size1 = sys.getsizeof(d)
assert size1 + get_... | 1,561 | 20.39726 | 88 | py |
a3t-dev_richard | a3t-dev_richard/test/espnet2/tasks/test_abs_task.py | import configargparse
import pytest
import torch
from espnet2.tasks.abs_task import AbsTask
from espnet2.torch_utils.device_funcs import force_gatherable
from espnet2.train.abs_espnet_model import AbsESPnetModel
from espnet2.train.collate_fn import CommonCollateFn
class TestModel(AbsESPnetModel):
def __init__(se... | 3,457 | 24.614815 | 75 | py |
a3t-dev_richard | a3t-dev_richard/espnet/scheduler/pytorch.py | """PyTorch optimizer schdulers."""
from typing import List
from torch.optim import Optimizer
from espnet.scheduler.scheduler import SchedulerInterface
class PyTorchScheduler:
"""PyTorch optimizer scheduler."""
def __init__(self, schedulers: List[SchedulerInterface], optimizer: Optimizer):
"""Initi... | 801 | 29.846154 | 83 | py |
a3t-dev_richard | a3t-dev_richard/espnet/vc/pytorch_backend/vc.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2020 Nagoya University (Wen-Chin Huang)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""E2E VC training / decoding functions."""
import copy
import json
import logging
import math
import os
import time
import chainer
import kaldiio
import num... | 26,325 | 34.432032 | 88 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/st_interface.py | """ST Interface module."""
from espnet.nets.asr_interface import ASRInterface
from espnet.utils.dynamic_import import dynamic_import
class STInterface(ASRInterface):
"""ST Interface for ESPnet model implementation.
NOTE: This class is inherited from ASRInterface to enable joint translation
and recogniti... | 2,271 | 32.411765 | 87 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/transducer_decoder_interface.py | """Transducer decoder interface module."""
from dataclasses import dataclass
from typing import Any
from typing import Dict
from typing import List
from typing import Optional
from typing import Tuple
from typing import Union
import torch
@dataclass
class Hypothesis:
"""Default hypothesis definition for transdu... | 4,372 | 26.33125 | 85 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/batch_beam_search_online_sim.py | """Parallel beam search module for online simulation."""
import logging
from pathlib import Path
from typing import List
import yaml
import torch
from espnet.nets.batch_beam_search import BatchBeamSearch
from espnet.nets.beam_search import Hypothesis
from espnet.nets.e2e_asr_common import end_detect
class BatchBe... | 10,143 | 36.431734 | 87 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/e2e_asr_common.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)
"""Common functions for ASR."""
import json
import logging
import sys
import editdistance
from itertools import groupby
import numpy as np
import six
def... | 8,505 | 33.718367 | 85 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/ctc_prefix_score.py | #!/usr/bin/env python3
# Copyright 2018 Mitsubishi Electric Research Labs (Takaaki Hori)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
import torch
import numpy as np
import six
class CTCPrefixScoreTH(object):
"""Batch processing of CTCPrefixScore
which is based on Algorithm 2 in WATANABE et... | 13,951 | 37.755556 | 87 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/beam_search_transducer.py | """Search algorithms for transducer models."""
import logging
from typing import List
from typing import Union
import numpy as np
import torch
from espnet.nets.pytorch_backend.transducer.custom_decoder import CustomDecoder
from espnet.nets.pytorch_backend.transducer.joint_network import JointNetwork
from espnet.nets... | 30,026 | 33.513793 | 88 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/batch_beam_search.py | """Parallel beam search module."""
import logging
from typing import Any
from typing import Dict
from typing import List
from typing import NamedTuple
from typing import Tuple
import torch
from torch.nn.utils.rnn import pad_sequence
from espnet.nets.beam_search import BeamSearch
from espnet.nets.beam_search import H... | 13,243 | 36.948424 | 88 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/beam_search.py | """Beam search module."""
from itertools import chain
import logging
from typing import Any
from typing import Dict
from typing import List
from typing import NamedTuple
from typing import Tuple
from typing import Union
import torch
from espnet.nets.e2e_asr_common import end_detect
from espnet.nets.scorer_interface ... | 19,241 | 36.218569 | 88 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/e2e_mt_common.py | #!/usr/bin/env python3
# encoding: utf-8
# Copyright 2019 Kyoto University (Hirofumi Inaguma)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""Common functions for ST and MT."""
import nltk
import numpy as np
class ErrorCalculator(object):
"""Calculate BLEU for ST and MT models during training.
... | 2,731 | 35.426667 | 85 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/lm_interface.py | """Language model interface."""
import argparse
from espnet.nets.scorer_interface import ScorerInterface
from espnet.utils.dynamic_import import dynamic_import
from espnet.utils.fill_missing_args import fill_missing_args
class LMInterface(ScorerInterface):
"""LM Interface for ESPnet model implementation."""
... | 2,590 | 28.781609 | 82 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/scorer_interface.py | """Scorer interface module."""
from typing import Any
from typing import List
from typing import Tuple
import torch
import warnings
class ScorerInterface:
"""Scorer interface for beam search.
The scorer performs scoring of the all tokens in vocabulary.
Examples:
* Search heuristics
... | 5,938 | 30.42328 | 87 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/asr_interface.py | """ASR Interface module."""
import argparse
from espnet.bin.asr_train import get_parser
from espnet.utils.dynamic_import import dynamic_import
from espnet.utils.fill_missing_args import fill_missing_args
class ASRInterface:
"""ASR Interface for ESPnet model implementation."""
@staticmethod
def add_argum... | 5,957 | 33.439306 | 88 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/mt_interface.py | """MT Interface module."""
import argparse
from espnet.bin.asr_train import get_parser
from espnet.utils.fill_missing_args import fill_missing_args
class MTInterface:
"""MT Interface for ESPnet model implementation."""
@staticmethod
def add_arguments(parser):
"""Add arguments to parser."""
... | 3,428 | 35.094737 | 87 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/tts_interface.py | # -*- coding: utf-8 -*-
# Copyright 2018 Nagoya University (Tomoki Hayashi)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""TTS Interface realted modules."""
from espnet.asr.asr_utils import torch_load
try:
import chainer
except ImportError:
Reporter = None
else:
class Reporter(chainer.... | 2,583 | 26.784946 | 87 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/chainer_backend/e2e_asr.py | # Copyright 2017 Johns Hopkins University (Shinji Watanabe)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""RNN sequence-to-sequence speech recognition model (chainer)."""
import logging
import math
import chainer
from chainer import reporter
import numpy as np
from espnet.nets.chainer_backend.asr_in... | 7,619 | 32.568282 | 87 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/chainer_backend/e2e_asr_transformer.py | # encoding: utf-8
"""Transformer-based model for End-to-end ASR."""
from argparse import Namespace
from distutils.util import strtobool
import logging
import math
import chainer
import chainer.functions as F
from chainer import reporter
import numpy as np
import six
from espnet.nets.chainer_backend.asr_interface imp... | 23,674 | 36.51981 | 88 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/chainer_backend/rnn/training.py | # Copyright 2017 Johns Hopkins University (Shinji Watanabe)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
import collections
import logging
import math
import six
# chainer related
from chainer import cuda
from chainer import training
from chainer import Variable
from chainer.training.updaters.multipr... | 9,419 | 34.954198 | 86 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/chainer_backend/transformer/training.py | # Copyright 2017 Johns Hopkins University (Shinji Watanabe)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""Class Declaration of Transformer's Training Subprocess."""
import collections
import logging
import math
import six
from chainer import cuda
from chainer import functions as F
from chainer import ... | 11,933 | 36.17757 | 88 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/scorers/length_bonus.py | """Length bonus module."""
from typing import Any
from typing import List
from typing import Tuple
import torch
from espnet.nets.scorer_interface import BatchScorerInterface
class LengthBonus(BatchScorerInterface):
"""Length bonus in beam search."""
def __init__(self, n_vocab: int):
"""Initialize c... | 1,776 | 27.66129 | 87 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/scorers/ctc.py | """ScorerInterface implementation for CTC."""
import numpy as np
import torch
from espnet.nets.ctc_prefix_score import CTCPrefixScore
from espnet.nets.ctc_prefix_score import CTCPrefixScoreTH
from espnet.nets.scorer_interface import BatchPartialScorerInterface
class CTCPrefixScorer(BatchPartialScorerInterface):
... | 4,993 | 30.408805 | 85 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/scorers/ngram.py | """Ngram lm implement."""
from abc import ABC
import kenlm
import torch
from espnet.nets.scorer_interface import BatchScorerInterface
from espnet.nets.scorer_interface import PartialScorerInterface
class Ngrambase(ABC):
"""Ngram base implemented through ScorerInterface."""
def __init__(self, ngram_model, ... | 3,120 | 29.300971 | 82 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/pytorch_backend/e2e_asr.py | # Copyright 2017 Johns Hopkins University (Shinji Watanabe)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""RNN sequence-to-sequence speech recognition model (pytorch)."""
import argparse
from itertools import groupby
import logging
import math
import os
import chainer
from chainer import reporter
imp... | 19,568 | 35.105166 | 87 | py |
a3t-dev_richard | a3t-dev_richard/espnet/nets/pytorch_backend/e2e_tts_fastspeech.py | # Copyright 2019 Tomoki Hayashi
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""FastSpeech related modules."""
import logging
import torch
import torch.nn.functional as F
from espnet.asr.asr_utils import get_model_conf
from espnet.asr.asr_utils import torch_load
from espnet.nets.pytorch_backend.fasts... | 34,550 | 37.39 | 88 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.