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
espnet
espnet-master/espnet2/train/dataset.py
import collections import copy import functools import logging import numbers import re from abc import ABC, abstractmethod from typing import Any, Callable, Collection, Dict, Mapping, Tuple, Union import h5py import humanfriendly import kaldiio import numpy as np import torch from torch.utils.data.dataset import Data...
18,511
31.591549
88
py
espnet
espnet-master/espnet2/train/gan_trainer.py
# Copyright 2021 Tomoki Hayashi # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Trainer module for GAN-based training.""" import argparse import dataclasses import logging import time from contextlib import contextmanager from typing import Dict, Iterable, List, Optional, Sequence, Tuple import torch ...
15,057
40.368132
88
py
espnet
espnet-master/espnet2/train/distributed_utils.py
import dataclasses import os import socket from typing import Optional import torch import torch.distributed @dataclasses.dataclass class DistributedOption: # Enable distributed Training distributed: bool = False # torch.distributed.Backend: "nccl", "mpi", "gloo", or "tcp" dist_backend: str = "nccl" ...
13,914
36.506739
99
py
espnet
espnet-master/espnet2/train/iterable_dataset.py
"""Iterable dataset module.""" import copy from io import StringIO from pathlib import Path from typing import Callable, Collection, Dict, Iterator, Tuple, Union import kaldiio import numpy as np import soundfile import torch from torch.utils.data.dataset import IterableDataset from typeguard import check_argument_typ...
8,251
34.416309
88
py
espnet
espnet-master/espnet2/train/uasr_trainer.py
# Copyright 2022 Tomoki Hayashi # 2022 Dongji Gao # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Trainer module for GAN-based UASR training.""" import argparse import dataclasses import logging import math import time from contextlib import contextmanager from typing import Dict, Iterable, L...
16,645
38.445498
88
py
espnet
espnet-master/espnet2/train/collate_fn.py
import math from typing import Collection, Dict, List, Tuple, Union import numpy as np import torch from typeguard import check_argument_types, check_return_type from espnet.nets.pytorch_backend.nets_utils import pad_list class CommonCollateFn: """Functor class of common_collate_fn()""" def __init__( ...
7,460
33.068493
87
py
espnet
espnet-master/espnet2/train/trainer.py
"""Trainer module.""" import argparse import dataclasses import logging import time from contextlib import contextmanager from dataclasses import is_dataclass from pathlib import Path from typing import Dict, Iterable, List, Optional, Sequence, Tuple, Union import humanfriendly import numpy as np import torch import t...
35,902
39.752554
88
py
espnet
espnet-master/espnet2/train/abs_espnet_model.py
from abc import ABC, abstractmethod from typing import Dict, Tuple import torch class AbsESPnetModel(torch.nn.Module, ABC): """The common abstract class among each tasks "ESPnetModel" is referred to a class which inherits torch.nn.Module, and makes the dnn-models forward as its member field, a.k.a d...
1,366
32.341463
82
py
espnet
espnet-master/espnet2/samplers/abs_sampler.py
from abc import ABC, abstractmethod from typing import Iterator, Tuple from torch.utils.data import Sampler class AbsSampler(Sampler, ABC): @abstractmethod def __len__(self) -> int: raise NotImplementedError @abstractmethod def __iter__(self) -> Iterator[Tuple[str, ...]]: raise NotIm...
392
20.833333
52
py
espnet
espnet-master/espnet2/asr/espnet_model.py
import logging from contextlib import contextmanager from typing import Dict, List, Optional, Tuple, Union import torch from packaging.version import parse as V from typeguard import check_argument_types from espnet2.asr.ctc import CTC from espnet2.asr.decoder.abs_decoder import AbsDecoder from espnet2.asr.encoder.ab...
24,373
35.216939
88
py
espnet
espnet-master/espnet2/asr/discrete_asr_espnet_model.py
from contextlib import contextmanager from typing import Dict, List, Optional, Tuple, Union import torch from packaging.version import parse as V from typeguard import check_argument_types from espnet2.asr.ctc import CTC from espnet2.asr.decoder.abs_decoder import AbsDecoder from espnet2.asr.encoder.abs_encoder impor...
11,037
35.190164
87
py
espnet
espnet-master/espnet2/asr/pit_espnet_model.py
import itertools from collections import defaultdict from contextlib import contextmanager from typing import Callable, Dict, List, Optional, Tuple, Union import torch from packaging.version import parse as V from typeguard import check_argument_types from espnet2.asr.ctc import CTC from espnet2.asr.decoder.abs_decod...
11,924
35.136364
88
py
espnet
espnet-master/espnet2/asr/ctc.py
import torch import torch.nn.functional as F from typeguard import check_argument_types class CTC(torch.nn.Module): """CTC module. Args: odim: dimension of outputs encoder_output_size: number of encoder projection units dropout_rate: dropout rate (0.0 ~ 1.0) ctc_type: builtin ...
4,223
32
88
py
espnet
espnet-master/espnet2/asr/maskctc_model.py
import logging from contextlib import contextmanager from itertools import groupby from typing import Dict, List, Optional, Tuple, Union import numpy import torch from packaging.version import parse as V from typeguard import check_argument_types from espnet2.asr.ctc import CTC from espnet2.asr.decoder.mlm_decoder im...
12,296
34.43804
88
py
espnet
espnet-master/espnet2/asr/postencoder/abs_postencoder.py
from abc import ABC, abstractmethod from typing import Tuple import torch class AbsPostEncoder(torch.nn.Module, ABC): @abstractmethod def output_size(self) -> int: raise NotImplementedError @abstractmethod def forward( self, input: torch.Tensor, input_lengths: torch.Tensor ) -> T...
388
21.882353
62
py
espnet
espnet-master/espnet2/asr/postencoder/hugging_face_transformers_postencoder.py
#!/usr/bin/env python3 # 2021, University of Stuttgart; Pavel Denisov # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Hugging Face Transformers PostEncoder.""" import copy import logging from typing import Tuple import torch from typeguard import check_argument_types from espnet2.asr.postencoder.ab...
6,584
33.119171
87
py
espnet
espnet-master/espnet2/asr/transducer/beam_search_transducer.py
"""Search algorithms for Transducer models.""" import logging from dataclasses import dataclass from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np import torch from espnet2.asr.decoder.abs_decoder import AbsDecoder from espnet2.asr_transducer.joint_network import JointNetwork from espnet2....
31,972
32.514675
88
py
espnet
espnet-master/espnet2/asr/transducer/error_calculator.py
"""Error Calculator module for Transducer.""" from typing import List, Tuple import torch from espnet2.asr.decoder.abs_decoder import AbsDecoder from espnet2.asr.transducer.beam_search_transducer import BeamSearchTransducer class ErrorCalculatorTransducer(object): """Calculate CER and WER for transducer models...
4,907
27.701754
78
py
espnet
espnet-master/espnet2/asr/transducer/rnnt_multi_blank/rnnt_multi_blank.py
# Copyright (c) 2021, NVIDIA 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 appli...
18,251
35.142574
88
py
espnet
espnet-master/espnet2/asr/transducer/rnnt_multi_blank/rnnt.py
# Copyright (c) 2021, NVIDIA 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 appli...
13,479
32.95466
87
py
espnet
espnet-master/espnet2/asr/transducer/rnnt_multi_blank/utils/rnnt_helper.py
# Copyright (c) 2021, NVIDIA 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 appli...
3,802
24.52349
76
py
espnet
espnet-master/espnet2/asr/transducer/rnnt_multi_blank/utils/cuda_utils/reduce.py
# Copyright (c) 2021, NVIDIA 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 appli...
12,677
31.84456
87
py
espnet
espnet-master/espnet2/asr/transducer/rnnt_multi_blank/utils/cuda_utils/gpu_rnnt.py
# Copyright (c) 2021, NVIDIA 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 appli...
21,906
33.608215
88
py
espnet
espnet-master/espnet2/asr/transducer/rnnt_multi_blank/utils/cuda_utils/gpu_rnnt_kernel.py
# Copyright (c) 2021, NVIDIA 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 appli...
46,645
42.150786
88
py
espnet
espnet-master/espnet2/asr/transducer/rnnt_multi_blank/utils/cpu_utils/cpu_rnnt.py
# Copyright (c) 2021, NVIDIA 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 appli...
16,277
33.93133
87
py
espnet
espnet-master/espnet2/asr/specaug/specaug.py
"""SpecAugment module.""" from typing import Optional, Sequence, Union from espnet2.asr.specaug.abs_specaug import AbsSpecAug from espnet2.layers.mask_along_axis import MaskAlongAxis, MaskAlongAxisVariableMaxWidth from espnet2.layers.time_warp import TimeWarp class SpecAug(AbsSpecAug): """Implementation of SpecA...
3,435
34.42268
87
py
espnet
espnet-master/espnet2/asr/specaug/abs_specaug.py
from typing import Optional, Tuple import torch class AbsSpecAug(torch.nn.Module): """Abstract class for the augmentation of spectrogram The process-flow: Frontend -> SpecAug -> Normalization -> Encoder -> Decoder """ def forward( self, x: torch.Tensor, x_lengths: torch.Tensor = None ...
408
21.722222
63
py
espnet
espnet-master/espnet2/asr/frontend/s3prl.py
import copy import logging from typing import Optional, Tuple, Union import humanfriendly import torch from typeguard import check_argument_types from espnet2.asr.frontend.abs_frontend import AbsFrontend from espnet2.utils.get_default_kwargs import get_default_kwargs from espnet.nets.pytorch_backend.frontends.fronten...
4,294
35.398305
85
py
espnet
espnet-master/espnet2/asr/frontend/windowing.py
#!/usr/bin/env python3 # 2020, Technische Universität München; Ludwig Kürzinger # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Sliding Window for raw audio input data.""" from typing import Tuple import torch from typeguard import check_argument_types from espnet2.asr.frontend.abs_frontend import ...
2,814
32.511905
82
py
espnet
espnet-master/espnet2/asr/frontend/fused.py
from typing import Tuple import numpy as np import torch from typeguard import check_argument_types from espnet2.asr.frontend.abs_frontend import AbsFrontend from espnet2.asr.frontend.default import DefaultFrontend from espnet2.asr.frontend.s3prl import S3prlFrontend class FusedFrontends(AbsFrontend): def __ini...
5,752
38.40411
88
py
espnet
espnet-master/espnet2/asr/frontend/whisper.py
import contextlib from typing import Tuple import torch import torch.nn.functional as F from typeguard import check_argument_types from espnet2.asr.frontend.abs_frontend import AbsFrontend class WhisperFrontend(AbsFrontend): """Speech Representation Using Encoder Outputs from OpenAI's Whisper Model: URL: h...
3,963
28.804511
86
py
espnet
espnet-master/espnet2/asr/frontend/default.py
import copy from typing import Optional, Tuple, Union import humanfriendly import numpy as np import torch from torch_complex.tensor import ComplexTensor from typeguard import check_argument_types from espnet2.asr.frontend.abs_frontend import AbsFrontend from espnet2.layers.log_mel import LogMel from espnet2.layers.s...
4,417
32.469697
77
py
espnet
espnet-master/espnet2/asr/frontend/abs_frontend.py
from abc import ABC, abstractmethod from typing import Tuple import torch class AbsFrontend(torch.nn.Module, ABC): @abstractmethod def output_size(self) -> int: raise NotImplementedError @abstractmethod def forward( self, input: torch.Tensor, input_lengths: torch.Tensor ) -> Tupl...
385
21.705882
62
py
espnet
espnet-master/espnet2/asr/layers/fastformer.py
"""Fastformer attention definition. Reference: Wu et al., "Fastformer: Additive Attention Can Be All You Need" https://arxiv.org/abs/2108.09084 https://github.com/wuch15/Fastformer """ import numpy import torch class FastSelfAttention(torch.nn.Module): """Fast self-attention used in Fastformer.""" ...
5,282
33.305195
88
py
espnet
espnet-master/espnet2/asr/layers/cgmlp.py
"""MLP with convolutional gating (cgMLP) definition. References: https://openreview.net/forum?id=RA-zVvZLYIy https://arxiv.org/abs/2105.08050 """ import torch from espnet.nets.pytorch_backend.nets_utils import get_activation from espnet.nets.pytorch_backend.transformer.layer_norm import LayerNorm class Co...
3,518
27.152
75
py
espnet
espnet-master/espnet2/asr/preencoder/linear.py
#!/usr/bin/env python3 # 2021, Carnegie Mellon University; Xuankai Chang # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Linear Projection.""" from typing import Tuple import torch from typeguard import check_argument_types from espnet2.asr.preencoder.abs_preencoder import AbsPreEncoder class Lin...
1,095
28.621622
80
py
espnet
espnet-master/espnet2/asr/preencoder/abs_preencoder.py
from abc import ABC, abstractmethod from typing import Tuple import torch class AbsPreEncoder(torch.nn.Module, ABC): @abstractmethod def output_size(self) -> int: raise NotImplementedError @abstractmethod def forward( self, input: torch.Tensor, input_lengths: torch.Tensor ) -> Tu...
387
21.823529
62
py
espnet
espnet-master/espnet2/asr/preencoder/sinc.py
#!/usr/bin/env python3 # 2020, Technische Universität München; Ludwig Kürzinger # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Sinc convolutions for raw audio input.""" from collections import OrderedDict from typing import Optional, Tuple, Union import humanfriendly import torch from typeguard imp...
10,222
35.251773
87
py
espnet
espnet-master/espnet2/asr/encoder/hubert_encoder.py
# Copyright 2021 Tianzi Wang # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0 # Thanks to Abdelrahman Mohamed and Wei-Ning Hsu's help in this implementation, # Their origial Hubert work is in: # Paper: https://arxiv.org/pdf/2106.07447.pdf # Code in Fairseq: https://github.com/pytorch/fairseq/tree/mast...
25,130
37.842349
135
py
espnet
espnet-master/espnet2/asr/encoder/rnn_encoder.py
from typing import Optional, Sequence, Tuple import numpy as np import torch from typeguard import check_argument_types from espnet2.asr.encoder.abs_encoder import AbsEncoder from espnet.nets.pytorch_backend.nets_utils import make_pad_mask from espnet.nets.pytorch_backend.rnn.encoders import RNN, RNNP class RNNEnco...
3,587
30.752212
80
py
espnet
espnet-master/espnet2/asr/encoder/contextual_block_transformer_encoder.py
# Copyright 2020 Emiru Tsunoo # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Encoder definition.""" import math from typing import Optional, Tuple import torch from typeguard import check_argument_types from espnet2.asr.encoder.abs_encoder import AbsEncoder from espnet.nets.pytorch_backend.nets_utils...
21,748
37.022727
87
py
espnet
espnet-master/espnet2/asr/encoder/longformer_encoder.py
# Copyright 2020 Tomoki Hayashi # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Conformer encoder definition.""" from typing import List, Optional, Tuple import torch from typeguard import check_argument_types from espnet2.asr.ctc import CTC from espnet2.asr.encoder.conformer_encoder import Conformer...
15,394
39.195822
88
py
espnet
espnet-master/espnet2/asr/encoder/conformer_encoder.py
# Copyright 2020 Tomoki Hayashi # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Conformer encoder definition.""" import logging from typing import List, Optional, Tuple, Union import torch from typeguard import check_argument_types from espnet2.asr.ctc import CTC from espnet2.asr.encoder.abs_encoder ...
15,429
39.820106
88
py
espnet
espnet-master/espnet2/asr/encoder/transformer_encoder_multispkr.py
# Copyright 2019 Shigeki Karita # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Encoder definition.""" from typing import Optional, Tuple import torch from typeguard import check_argument_types from espnet2.asr.encoder.abs_encoder import AbsEncoder from espnet.nets.pytorch_backend.nets_utils import ma...
8,820
38.030973
88
py
espnet
espnet-master/espnet2/asr/encoder/transformer_encoder.py
# Copyright 2019 Shigeki Karita # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Transformer encoder definition.""" from typing import List, Optional, Tuple import torch from typeguard import check_argument_types from espnet2.asr.ctc import CTC from espnet2.asr.encoder.abs_encoder import AbsEncoder fr...
9,402
37.855372
88
py
espnet
espnet-master/espnet2/asr/encoder/vgg_rnn_encoder.py
from typing import Tuple import numpy as np import torch from typeguard import check_argument_types from espnet2.asr.encoder.abs_encoder import AbsEncoder from espnet.nets.e2e_asr_common import get_vgg2l_odim from espnet.nets.pytorch_backend.nets_utils import make_pad_mask from espnet.nets.pytorch_backend.rnn.encoder...
3,415
31.533333
80
py
espnet
espnet-master/espnet2/asr/encoder/abs_encoder.py
from abc import ABC, abstractmethod from typing import Optional, Tuple import torch class AbsEncoder(torch.nn.Module, ABC): @abstractmethod def output_size(self) -> int: raise NotImplementedError @abstractmethod def forward( self, xs_pad: torch.Tensor, ilens: torch.Te...
470
22.55
67
py
espnet
espnet-master/espnet2/asr/encoder/e_branchformer_encoder.py
# Copyright 2022 Kwangyoun Kim (ASAPP inc.) # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """E-Branchformer encoder definition. Reference: Kwangyoun Kim, Felix Wu, Yifan Peng, Jing Pan, Prashant Sridhar, Kyu J. Han, Shinji Watanabe, "E-Branchformer: Branchformer with Enhanced merging for ...
18,321
36.014141
88
py
espnet
espnet-master/espnet2/asr/encoder/wav2vec2_encoder.py
# Copyright 2021 Xuankai Chang # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Encoder definition.""" import contextlib import copy import logging import os from typing import Optional, Tuple import torch from filelock import FileLock from typeguard import check_argument_types from espnet2.asr.encoder...
5,628
32.307692
88
py
espnet
espnet-master/espnet2/asr/encoder/contextual_block_conformer_encoder.py
# -*- coding: utf-8 -*- """ Created on Sat Aug 21 17:27:16 2021. @author: Keqi Deng (UCAS) """ import math from typing import Optional, Tuple import torch from typeguard import check_argument_types from espnet2.asr.encoder.abs_encoder import AbsEncoder from espnet.nets.pytorch_backend.conformer.contextual_block_enc...
22,601
37.243655
88
py
espnet
espnet-master/espnet2/asr/encoder/branchformer_encoder.py
# Copyright 2022 Yifan Peng (Carnegie Mellon University) # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Branchformer encoder definition. Reference: Yifan Peng, Siddharth Dalmia, Ian Lane, and Shinji Watanabe, “Branchformer: Parallel MLP-Attention Architectures to Capture Local and Global C...
21,251
37.154399
88
py
espnet
espnet-master/espnet2/asr/encoder/whisper_encoder.py
import copy from typing import Optional, Tuple, Union import torch import torch.nn.functional as F from typeguard import check_argument_types from espnet2.asr.encoder.abs_encoder import AbsEncoder from espnet2.asr.specaug.specaug import SpecAug class OpenAIWhisperEncoder(AbsEncoder): """Transformer-based Speech...
5,639
29.486486
86
py
espnet
espnet-master/espnet2/asr/state_spaces/ff.py
# This code is derived from https://github.com/HazyResearch/state-spaces """Implementation of FFN block in the style of Transformers.""" from functools import partial from torch import nn from espnet2.asr.state_spaces.base import SequenceModule from espnet2.asr.state_spaces.components import DropoutNd, LinearActiva...
1,923
26.098592
75
py
espnet
espnet-master/espnet2/asr/state_spaces/base.py
# This code is derived from https://github.com/HazyResearch/state-spaces import functools from torch import nn class SequenceModule(nn.Module): """Abstract sequence model class. All models must adhere to this interface A SequenceModule is generally a model that transforms an input of shape (n_batc...
5,487
33.3
88
py
espnet
espnet-master/espnet2/asr/state_spaces/cauchy.py
# This code is derived from https://github.com/HazyResearch/state-spaces import torch from cauchy_mult import ( cauchy_mult_bwd, cauchy_mult_fwd, cauchy_mult_sym_bwd, cauchy_mult_sym_fwd, ) from einops import rearrange def cauchy_mult_torch( v: torch.Tensor, z: torch.Tensor, w: torch.Tensor, symm...
4,022
31.443548
88
py
espnet
espnet-master/espnet2/asr/state_spaces/residual.py
# This code is derived from https://github.com/HazyResearch/state-spaces """Implementations of different types of residual functions.""" import torch from torch import nn class Residual(nn.Module): """Residual connection with constant affine weights. Can simulate standard residual, no residual, and "consta...
3,422
27.764706
87
py
espnet
espnet-master/espnet2/asr/state_spaces/block.py
# This code is derived from https://github.com/HazyResearch/state-spaces """Implements a full residual block around a black box layer. Configurable options include: normalization position: prenorm or postnorm normalization type: batchnorm, layernorm etc. subsampling/pooling residual options: feedforward, residual, af...
5,330
29.289773
88
py
espnet
espnet-master/espnet2/asr/state_spaces/model.py
# This code is derived from https://github.com/HazyResearch/state-spaces from functools import partial import torch import torch.nn as nn from einops import rearrange from espnet2.asr.state_spaces.base import SequenceModule from espnet2.asr.state_spaces.block import SequenceResidualBlock from espnet2.asr.state_space...
6,438
33.61828
86
py
espnet
espnet-master/espnet2/asr/state_spaces/components.py
# This code is derived from https://github.com/HazyResearch/state-spaces import math from functools import partial import torch import torch.nn as nn import torch.nn.functional as F from einops import rearrange from opt_einsum import contract def stochastic_depth(input: torch.tensor, p: float, mode: str, training: ...
13,449
31.177033
88
py
espnet
espnet-master/espnet2/asr/state_spaces/attention.py
"""Multi-Head Attention layer definition.""" import math import numpy import torch from torch import nn from espnet2.asr.state_spaces.base import SequenceModule class MultiHeadedAttention(SequenceModule): """Multi-Head Attention layer inheriting SequenceModule. Comparing default MHA module in ESPnet, this...
4,629
36.642276
86
py
espnet
espnet-master/espnet2/asr/state_spaces/pool.py
# This code is derived from https://github.com/HazyResearch/state-spaces """Implements downsampling and upsampling on sequences.""" import torch import torch.nn.functional as F from einops import rearrange, reduce, repeat from torch import nn from espnet2.asr.state_spaces.base import SequenceModule from espnet2.asr....
11,292
28.030848
87
py
espnet
espnet-master/espnet2/asr/state_spaces/s4.py
# This code is derived from https://github.com/HazyResearch/state-spaces """Standalone version of Structured (Sequence) State Space (S4) model.""" import logging import math import os from functools import wraps # from pytorch_lightning.utilities import rank_zero_only from typing import Any, Callable, Optional impo...
61,257
32.806843
125
py
espnet
espnet-master/espnet2/asr/decoder/s4_decoder.py
"""Decoder definition.""" from typing import Any, List, Tuple import torch from typeguard import check_argument_types from espnet2.asr.decoder.abs_decoder import AbsDecoder from espnet2.asr.state_spaces.model import SequenceModel from espnet.nets.pytorch_backend.nets_utils import make_pad_mask from espnet.nets.scorer...
5,441
30.275862
86
py
espnet
espnet-master/espnet2/asr/decoder/rnn_decoder.py
import random import numpy as np import torch import torch.nn.functional as F from typeguard import check_argument_types from espnet2.asr.decoder.abs_decoder import AbsDecoder from espnet2.utils.get_default_kwargs import get_default_kwargs from espnet.nets.pytorch_backend.nets_utils import make_pad_mask, to_device fr...
12,120
35.399399
81
py
espnet
espnet-master/espnet2/asr/decoder/transformer_decoder.py
# Copyright 2019 Shigeki Karita # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Decoder definition.""" from typing import Any, List, Sequence, Tuple import torch from typeguard import check_argument_types from espnet2.asr.decoder.abs_decoder import AbsDecoder from espnet.nets.pytorch_backend.nets_util...
19,739
36.31569
88
py
espnet
espnet-master/espnet2/asr/decoder/mlm_decoder.py
# Copyright 2022 Yosuke Higuchi # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Masked LM Decoder definition.""" from typing import Tuple import torch from typeguard import check_argument_types from espnet2.asr.decoder.abs_decoder import AbsDecoder from espnet.nets.pytorch_backend.nets_utils import ma...
4,749
35.259542
85
py
espnet
espnet-master/espnet2/asr/decoder/transducer_decoder.py
"""(RNN-)Transducer decoder definition.""" from typing import Any, Dict, List, Optional, Tuple, Union import torch from typeguard import check_argument_types from espnet2.asr.decoder.abs_decoder import AbsDecoder from espnet2.asr.transducer.beam_search_transducer import ExtendedHypothesis, Hypothesis class Transdu...
9,252
29.946488
88
py
espnet
espnet-master/espnet2/asr/decoder/hugging_face_transformers_decoder.py
#!/usr/bin/env python3 # 2022, University of Stuttgart; Pavel Denisov # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Hugging Face Transformers Decoder.""" import copy import logging from typing import Tuple import torch from typeguard import check_argument_types from espnet2.asr.decoder.abs_decode...
3,571
30.610619
87
py
espnet
espnet-master/espnet2/asr/decoder/abs_decoder.py
from abc import ABC, abstractmethod from typing import Tuple import torch from espnet.nets.scorer_interface import ScorerInterface class AbsDecoder(torch.nn.Module, ScorerInterface, ABC): @abstractmethod def forward( self, hs_pad: torch.Tensor, hlens: torch.Tensor, ys_in_pad:...
447
22.578947
56
py
espnet
espnet-master/espnet2/asr/decoder/whisper_decoder.py
import copy from typing import Any, List, Tuple import torch from typeguard import check_argument_types from espnet2.asr.decoder.abs_decoder import AbsDecoder from espnet.nets.scorer_interface import BatchScorerInterface class OpenAIWhisperDecoder(AbsDecoder, BatchScorerInterface): """Transformer-based Speech-t...
6,090
32.467033
87
py
espnet
espnet-master/espnet2/lm/espnet_model.py
from typing import Dict, Optional, Tuple import torch import torch.nn.functional as F from typeguard import check_argument_types from espnet2.lm.abs_model import AbsLM from espnet2.torch_utils.device_funcs import force_gatherable from espnet2.train.abs_espnet_model import AbsESPnetModel from espnet.nets.pytorch_backe...
4,785
34.191176
88
py
espnet
espnet-master/espnet2/lm/seq_rnn_lm.py
"""Sequential implementation of Recurrent Neural Network Language Model.""" from typing import Tuple, Union import torch import torch.nn as nn from typeguard import check_argument_types from espnet2.lm.abs_model import AbsLM class SequentialRNNLM(AbsLM): """Sequential RNNLM. See also: https://githu...
5,887
32.83908
118
py
espnet
espnet-master/espnet2/lm/transformer_lm.py
from typing import Any, List, Tuple import torch import torch.nn as nn from espnet2.lm.abs_model import AbsLM from espnet.nets.pytorch_backend.transformer.embedding import PositionalEncoding from espnet.nets.pytorch_backend.transformer.encoder import Encoder from espnet.nets.pytorch_backend.transformer.mask import su...
4,239
31.615385
86
py
espnet
espnet-master/espnet2/lm/abs_model.py
from abc import ABC, abstractmethod from typing import Tuple import torch from espnet.nets.scorer_interface import BatchScorerInterface class AbsLM(torch.nn.Module, BatchScorerInterface, ABC): """The abstract LM class To share the loss calculation way among different models, We uses delegate pattern he...
747
24.793103
66
py
espnet
espnet-master/espnet2/iterators/sequence_iter_factory.py
import random from functools import partial from typing import Any, Sequence, Union import numpy as np from torch.utils.data import DataLoader from typeguard import check_argument_types from espnet2.iterators.abs_iter_factory import AbsIterFactory from espnet2.samplers.abs_sampler import AbsSampler def worker_init_...
5,509
35.490066
89
py
espnet
espnet-master/espnet2/iterators/chunk_iter_factory.py
import logging import re from collections import defaultdict from typing import Any, Dict, Iterator, List, Optional, Sequence, Tuple, Union import numpy as np import torch from typeguard import check_argument_types from espnet2.iterators.abs_iter_factory import AbsIterFactory from espnet2.iterators.sequence_iter_fact...
9,683
37.581673
87
py
espnet
espnet-master/espnet2/tts/espnet_model.py
# Copyright 2020 Nagoya University (Tomoki Hayashi) # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Text-to-speech ESPnet model.""" from contextlib import contextmanager from typing import Dict, Optional, Tuple import torch from packaging.version import parse as V from typeguard import check_argument_...
12,407
39.15534
87
py
espnet
espnet-master/espnet2/tts/abs_tts.py
# Copyright 2021 Tomoki Hayashi # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Text-to-speech abstrast class.""" from abc import ABC, abstractmethod from typing import Dict, Tuple import torch class AbsTTS(torch.nn.Module, ABC): """TTS abstract class.""" @abstractmethod def forward( ...
1,113
23.755556
68
py
espnet
espnet-master/espnet2/tts/tacotron2/tacotron2.py
# Copyright 2020 Nagoya University (Tomoki Hayashi) # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Tacotron 2 related modules for ESPnet2.""" import logging from typing import Dict, Optional, Sequence, Tuple import torch import torch.nn.functional as F from typeguard import check_argument_types from...
21,020
38.8125
88
py
espnet
espnet-master/espnet2/tts/fastspeech/fastspeech.py
# Copyright 2020 Nagoya University (Tomoki Hayashi) # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Fastspeech related modules for ESPnet2.""" import logging from typing import Dict, Optional, Sequence, Tuple import torch import torch.nn.functional as F from typeguard import check_argument_types from...
29,711
41.26458
88
py
espnet
espnet-master/espnet2/tts/prodiff/prodiff.py
# Copyright 2022 Hitachi LTD. (Nelson Yalta) # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) # Based in FastSpeech2 """ProDiff related modules for ESPnet2.""" import logging from typing import Dict, Optional, Sequence, Tuple import torch import torch.nn.functional as F from typeguard import check_argumen...
35,170
41.120958
88
py
espnet
espnet-master/espnet2/tts/prodiff/loss.py
# Copyright 2022 Hitachi LTD. (Nelson Yalta) # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """ProDiff related loss module for ESPnet2.""" from math import exp from typing import Tuple import torch from torch.nn import functional as F from typeguard import check_argument_types from espnet.nets.pytorch_...
9,540
33.197133
88
py
espnet
espnet-master/espnet2/tts/prodiff/denoiser.py
# Implemented from # (https://github.com/Rongjiehuang/ProDiff/blob/main/modules/ProDiff/model/ProDiff_teacher.py) # Copyright 2022 Hitachi LTD. (Nelson Yalta) # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) import math from typing import Optional, Union import numpy as np import torch from torch import nn ...
12,143
32.271233
94
py
espnet
espnet-master/espnet2/tts/fastspeech2/loss.py
# Copyright 2020 Nagoya University (Tomoki Hayashi) # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Fastspeech2 related loss module for ESPnet2.""" from typing import Tuple import torch from typeguard import check_argument_types from espnet.nets.pytorch_backend.fastspeech.duration_predictor import ( ...
5,331
40.984252
88
py
espnet
espnet-master/espnet2/tts/fastspeech2/variance_predictor.py
#!/usr/bin/env python3 # Copyright 2020 Tomoki Hayashi # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Variance predictor related modules.""" import torch from typeguard import check_argument_types from espnet.nets.pytorch_backend.transformer.layer_norm import LayerNorm class VariancePredictor(torc...
2,624
29.172414
86
py
espnet
espnet-master/espnet2/tts/fastspeech2/fastspeech2.py
# Copyright 2020 Nagoya University (Tomoki Hayashi) # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Fastspeech2 related modules for ESPnet2.""" import logging from typing import Dict, Optional, Sequence, Tuple import torch import torch.nn.functional as F from typeguard import check_argument_types fro...
35,997
42.059809
88
py
espnet
espnet-master/espnet2/tts/feats_extract/energy.py
# Copyright 2020 Nagoya University (Tomoki Hayashi) # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Energy extractor.""" from typing import Any, Dict, Tuple, Union import humanfriendly import torch import torch.nn.functional as F from typeguard import check_argument_types from espnet2.layers.stft imp...
4,733
32.814286
86
py
espnet
espnet-master/espnet2/tts/feats_extract/ying.py
# modified from https://github.com/dhchoi99/NANSY # We have modified the implementation of dhchoi99 to be fully differentiable. import math from typing import Any, Dict, Tuple, Union import torch from espnet2.tts.feats_extract.abs_feats_extract import AbsFeatsExtract from espnet2.tts.feats_extract.yin import * from e...
8,001
32.066116
88
py
espnet
espnet-master/espnet2/tts/feats_extract/abs_feats_extract.py
from abc import ABC, abstractmethod from typing import Any, Dict, Tuple import torch class AbsFeatsExtract(torch.nn.Module, ABC): @abstractmethod def output_size(self) -> int: raise NotImplementedError @abstractmethod def get_parameters(self) -> Dict[str, Any]: raise NotImplementedEr...
503
23
62
py
espnet
espnet-master/espnet2/tts/feats_extract/log_spectrogram.py
from typing import Any, Dict, Optional, Tuple import torch from typeguard import check_argument_types from espnet2.layers.stft import Stft from espnet2.tts.feats_extract.abs_feats_extract import AbsFeatsExtract class LogSpectrogram(AbsFeatsExtract): """Conventional frontend structure for ASR Stft -> log-am...
2,244
29.337838
82
py
espnet
espnet-master/espnet2/tts/feats_extract/linear_spectrogram.py
from typing import Any, Dict, Optional, Tuple import torch from typeguard import check_argument_types from espnet2.layers.stft import Stft from espnet2.tts.feats_extract.abs_feats_extract import AbsFeatsExtract class LinearSpectrogram(AbsFeatsExtract): """Linear amplitude spectrogram. Stft -> amplitude-spe...
2,092
28.9
71
py
espnet
espnet-master/espnet2/tts/feats_extract/log_mel_fbank.py
from typing import Any, Dict, Optional, Tuple, Union import humanfriendly import torch from typeguard import check_argument_types from espnet2.layers.log_mel import LogMel from espnet2.layers.stft import Stft from espnet2.tts.feats_extract.abs_feats_extract import AbsFeatsExtract class LogMelFbank(AbsFeatsExtract):...
3,044
28.563107
82
py
espnet
espnet-master/espnet2/tts/feats_extract/dio.py
# Copyright 2020 Nagoya University (Tomoki Hayashi) # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """F0 extractor using DIO + Stonemask algorithm.""" import logging from typing import Any, Dict, Tuple, Union import humanfriendly import numpy as np import pyworld import torch import torch.nn.functional ...
6,224
33.016393
88
py
espnet
espnet-master/espnet2/tts/feats_extract/yin.py
# remove np from https://github.com/dhchoi99/NANSY/blob/master/models/yin.py # adapted from https://github.com/patriceguyot/Yin # https://github.com/NVIDIA/mellotron/blob/master/yin.py import numpy as np import torch import torch.nn.functional as F def differenceFunction(x, N, tau_max): """ Compute differenc...
5,723
29.940541
87
py
espnet
espnet-master/espnet2/tts/utils/duration_calculator.py
# -*- coding: utf-8 -*- # Copyright 2020 Nagoya University (Tomoki Hayashi) # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Duration calculator for ESPnet2.""" from typing import Tuple import torch class DurationCalculator(torch.nn.Module): """Duration calculator module.""" @torch.no_grad(...
2,291
33.727273
87
py
espnet
espnet-master/espnet2/tts/utils/parallel_wavegan_pretrained_vocoder.py
# Copyright 2021 Tomoki Hayashi # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Wrapper class for the vocoder model trained with parallel_wavegan repo.""" import logging import os from pathlib import Path from typing import Optional, Union import torch import yaml class ParallelWaveGANPretrainedVoco...
1,921
30.508197
79
py
espnet
espnet-master/espnet2/tts/gst/style_encoder.py
# Copyright 2020 Nagoya University (Tomoki Hayashi) # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Style encoder of GST-Tacotron.""" from typing import Sequence import torch from typeguard import check_argument_types from espnet.nets.pytorch_backend.transformer.attention import ( MultiHeadedAtte...
10,101
36.003663
88
py
espnet
espnet-master/espnet2/tts/transformer/transformer.py
# Copyright 2020 Nagoya University (Tomoki Hayashi) # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Transformer-TTS related modules.""" from typing import Dict, Optional, Sequence, Tuple import torch import torch.nn.functional as F from typeguard import check_argument_types from espnet2.torch_utils.d...
34,927
40.286052
88
py
espnet
espnet-master/espnet2/optimizers/sgd.py
import torch from typeguard import check_argument_types class SGD(torch.optim.SGD): """Thin inheritance of torch.optim.SGD to bind the required arguments, 'lr' Note that the arguments of the optimizer invoked by AbsTask.main() must have default value except for 'param'. I can't understand why on...
828
24.121212
79
py
espnet
espnet-master/espnet2/optimizers/optim_groups.py
# noqa: E501 This code is modified from: https://github.com/HazyResearch/state-spaces/blob/main/src/utils/optim_groups.py import torch.nn as nn def add_optimizer_hooks( model, bias_weight_decay=False, normalization_weight_decay=False, ): """Set zero weight decay for some params Set weight_decay=...
2,534
34.208333
121
py