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/enh/encoder/conv_encoder.py | import math
import torch
from espnet2.enh.encoder.abs_encoder import AbsEncoder
class ConvEncoder(AbsEncoder):
"""Convolutional encoder for speech enhancement and separation"""
def __init__(
self,
channel: int,
kernel_size: int,
stride: int,
):
super().__init__()... | 2,731 | 26.877551 | 87 | py |
espnet | espnet-master/espnet2/enh/loss/criterions/time_domain.py | import logging
import math
from abc import ABC
import ci_sdr
import fast_bss_eval
import torch
from packaging.version import parse as V
from torch_complex.tensor import ComplexTensor
from espnet2.enh.loss.criterions.abs_loss import AbsEnhLoss
from espnet2.layers.stft import Stft
is_torch_1_9_plus = V(torch.__version... | 13,715 | 28.307692 | 88 | py |
espnet | espnet-master/espnet2/enh/loss/criterions/abs_loss.py | from abc import ABC, abstractmethod
import torch
EPS = torch.finfo(torch.get_default_dtype()).eps
class AbsEnhLoss(torch.nn.Module, ABC):
"""Base class for all Enhancement loss modules."""
# the name will be the key that appears in the reporter
@property
def name(self) -> str:
return NotImp... | 705 | 22.533333 | 61 | py |
espnet | espnet-master/espnet2/enh/loss/criterions/tf_domain.py | import math
from abc import ABC, abstractmethod
from functools import reduce
import torch
import torch.nn.functional as F
from packaging.version import parse as V
from espnet2.enh.layers.complex_utils import complex_norm, is_complex, new_complex_like
from espnet2.enh.loss.criterions.abs_loss import AbsEnhLoss
is_tor... | 16,625 | 31.034682 | 94 | py |
espnet | espnet-master/espnet2/enh/loss/wrappers/mixit_solver.py | import itertools
from typing import Dict, List, Union
import torch
from torch_complex.tensor import ComplexTensor
from espnet2.enh.layers.complex_utils import einsum as complex_einsum
from espnet2.enh.layers.complex_utils import stack as complex_stack
from espnet2.enh.loss.criterions.abs_loss import AbsEnhLoss
from e... | 4,145 | 32.983607 | 88 | py |
espnet | espnet-master/espnet2/enh/loss/wrappers/abs_wrapper.py | from abc import ABC, abstractmethod
from typing import Dict, List, Tuple
import torch
class AbsLossWrapper(torch.nn.Module, ABC):
"""Base class for all Enhancement loss wrapper modules."""
# The weight for the current loss in the multi-task learning.
# The overall training target will be combined as:
... | 580 | 24.26087 | 65 | py |
espnet | espnet-master/espnet2/enh/loss/wrappers/multilayer_pit_solver.py | from espnet2.enh.loss.criterions.abs_loss import AbsEnhLoss
from espnet2.enh.loss.wrappers.abs_wrapper import AbsLossWrapper
from espnet2.enh.loss.wrappers.pit_solver import PITSolver
class MultiLayerPITSolver(AbsLossWrapper):
def __init__(
self,
criterion: AbsEnhLoss,
weight=1.0,
... | 3,042 | 42.471429 | 88 | py |
espnet | espnet-master/espnet2/enh/loss/wrappers/fixed_order.py | from collections import defaultdict
import torch
from espnet2.enh.loss.criterions.abs_loss import AbsEnhLoss
from espnet2.enh.loss.wrappers.abs_wrapper import AbsLossWrapper
class FixedOrderSolver(AbsLossWrapper):
def __init__(self, criterion: AbsEnhLoss, weight=1.0):
super().__init__()
self.cri... | 1,393 | 31.418605 | 75 | py |
espnet | espnet-master/espnet2/enh/loss/wrappers/dpcl_solver.py | from espnet2.enh.loss.criterions.abs_loss import AbsEnhLoss
from espnet2.enh.loss.wrappers.abs_wrapper import AbsLossWrapper
class DPCLSolver(AbsLossWrapper):
def __init__(self, criterion: AbsEnhLoss, weight=1.0):
super().__init__()
self.criterion = criterion
self.weight = weight
def ... | 1,083 | 31.848485 | 83 | py |
espnet | espnet-master/espnet2/enh/loss/wrappers/pit_solver.py | from collections import defaultdict
from itertools import permutations
import torch
from espnet2.enh.loss.criterions.abs_loss import AbsEnhLoss
from espnet2.enh.loss.wrappers.abs_wrapper import AbsLossWrapper
class PITSolver(AbsLossWrapper):
def __init__(
self,
criterion: AbsEnhLoss,
wei... | 4,627 | 36.322581 | 88 | py |
espnet | espnet-master/espnet2/enh/extractor/td_speakerbeam_extractor.py | from collections import OrderedDict
from typing import List, Tuple, Union
import torch
from torch_complex.tensor import ComplexTensor
from espnet2.enh.extractor.abs_extractor import AbsExtractor
from espnet2.enh.layers.complex_utils import is_complex
from espnet2.enh.layers.tcn import TemporalConvNet, TemporalConvNet... | 6,590 | 37.770588 | 100 | py |
espnet | espnet-master/espnet2/enh/extractor/abs_extractor.py | from abc import ABC, abstractmethod
from collections import OrderedDict
from typing import Tuple
import torch
class AbsExtractor(torch.nn.Module, ABC):
@abstractmethod
def forward(
self,
input: torch.Tensor,
ilens: torch.Tensor,
input_aux: torch.Tensor,
ilens_aux: torc... | 458 | 23.157895 | 63 | py |
espnet | espnet-master/espnet2/enh/decoder/conv_decoder.py | import math
import torch
from espnet2.enh.decoder.abs_decoder import AbsDecoder
class ConvDecoder(AbsDecoder):
"""Transposed Convolutional decoder for speech enhancement and separation"""
def __init__(
self,
channel: int,
kernel_size: int,
stride: int,
):
super()... | 3,014 | 29.454545 | 87 | py |
espnet | espnet-master/espnet2/enh/decoder/null_decoder.py | import torch
from espnet2.enh.decoder.abs_decoder import AbsDecoder
class NullDecoder(AbsDecoder):
"""Null decoder, return the same args."""
def __init__(self):
super().__init__()
def forward(self, input: torch.Tensor, ilens: torch.Tensor):
"""Forward. The input should be the waveform a... | 493 | 23.7 | 64 | py |
espnet | espnet-master/espnet2/enh/decoder/abs_decoder.py | from abc import ABC, abstractmethod
from typing import Tuple
import torch
class AbsDecoder(torch.nn.Module, ABC):
@abstractmethod
def forward(
self,
input: torch.Tensor,
ilens: torch.Tensor,
) -> Tuple[torch.Tensor, torch.Tensor]:
raise NotImplementedError
def forward... | 975 | 28.575758 | 80 | py |
espnet | espnet-master/espnet2/enh/decoder/stft_decoder.py | import math
import torch
import torch_complex
from packaging.version import parse as V
from torch_complex.tensor import ComplexTensor
from espnet2.enh.decoder.abs_decoder import AbsDecoder
from espnet2.enh.layers.complex_utils import is_torch_complex_tensor
from espnet2.layers.stft import Stft
is_torch_1_9_plus = V(... | 6,263 | 31.625 | 88 | py |
espnet | espnet-master/espnet2/torch_utils/forward_adaptor.py | import torch
from typeguard import check_argument_types
class ForwardAdaptor(torch.nn.Module):
"""Wrapped module to parallelize specified method
torch.nn.DataParallel parallelizes only "forward()"
and, maybe, the method having the other name can't be applied
except for wrapping the module just like t... | 1,052 | 29.970588 | 67 | py |
espnet | espnet-master/espnet2/torch_utils/initialize.py | #!/usr/bin/env python3
"""Initialize modules for espnet2 neural networks."""
import logging
import math
import torch
from typeguard import check_argument_types
def initialize(model: torch.nn.Module, init: str):
"""Initialize weights of a neural network module.
Parameters are initialized using the given me... | 4,844 | 37.452381 | 82 | py |
espnet | espnet-master/espnet2/torch_utils/model_summary.py | import humanfriendly
import numpy as np
import torch
def get_human_readable_count(number: int) -> str:
"""Return human_readable_count
Originated from:
https://github.com/PyTorchLightning/pytorch-lightning/blob/master/pytorch_lightning/core/memory.py
Abbreviates an integer number with K, M, B, T for ... | 2,498 | 34.197183 | 102 | py |
espnet | espnet-master/espnet2/torch_utils/get_layer_from_string.py | import difflib
import torch
def get_layer(l_name, library=torch.nn):
"""Return layer object handler from library e.g. from torch.nn
E.g. if l_name=="elu", returns torch.nn.ELU.
Args:
l_name (string): Case insensitive name for layer in library (e.g. .'elu').
library (module): Name of lib... | 1,411 | 31.090909 | 83 | py |
espnet | espnet-master/espnet2/torch_utils/load_pretrained_model.py | import logging
from typing import Any, Dict, Union
import torch
import torch.nn
import torch.optim
def filter_state_dict(
dst_state: Dict[str, Union[float, torch.Tensor]],
src_state: Dict[str, Union[float, torch.Tensor]],
):
"""Filter name, size mismatch instances between dicts.
Args:
dst_st... | 3,500 | 29.181034 | 83 | py |
espnet | espnet-master/espnet2/torch_utils/add_gradient_noise.py | import torch
def add_gradient_noise(
model: torch.nn.Module,
iteration: int,
duration: float = 100,
eta: float = 1.0,
scale_factor: float = 0.55,
):
"""Adds noise from a standard normal distribution to the gradients.
The standard deviation (`sigma`) is controlled
by the three hyper-pa... | 987 | 29.875 | 71 | py |
espnet | espnet-master/espnet2/torch_utils/device_funcs.py | import dataclasses
import warnings
import numpy as np
import torch
def to_device(data, device=None, dtype=None, non_blocking=False, copy=False):
"""Change the device of object recursively"""
if isinstance(data, dict):
return {
k: to_device(v, device, dtype, non_blocking, copy) for k, v in... | 2,681 | 36.25 | 88 | py |
espnet | espnet-master/espnet2/torch_utils/pytorch_version.py | import torch
def pytorch_cudnn_version() -> str:
message = (
f"pytorch.version={torch.__version__}, "
f"cuda.available={torch.cuda.is_available()}, "
)
if torch.backends.cudnn.enabled:
message += (
f"cudnn.version={torch.backends.cudnn.version()}, "
f"cudnn... | 468 | 26.588235 | 71 | py |
espnet | espnet-master/espnet2/torch_utils/recursive_op.py | """Torch utility module."""
import torch
if torch.distributed.is_available():
from torch.distributed import ReduceOp
def recursive_sum(obj, weight: torch.Tensor, distributed: bool = False):
assert weight.dim() == 1, weight.size()
if isinstance(obj, (tuple, list)):
return type(obj)(recursive_sum(v... | 1,615 | 32.666667 | 81 | py |
espnet | espnet-master/espnet2/torch_utils/set_all_random_seed.py | import random
import numpy as np
import torch
def set_all_random_seed(seed: int):
random.seed(seed)
np.random.seed(seed)
torch.random.manual_seed(seed)
| 167 | 14.272727 | 35 | py |
espnet | espnet-master/espnet2/main_funcs/collect_stats.py | import logging
from collections import defaultdict
from pathlib import Path
from typing import Dict, Iterable, List, Optional, Tuple, Union
import numpy as np
import torch
from torch.nn.parallel import data_parallel
from torch.utils.data import DataLoader
from typeguard import check_argument_types
from espnet2.fileio... | 5,164 | 40.653226 | 85 | py |
espnet | espnet-master/espnet2/main_funcs/calculate_all_attentions.py | from collections import defaultdict
from typing import Dict, List
import torch
from espnet2.gan_tts.jets.alignments import AlignmentModule
from espnet2.train.abs_espnet_model import AbsESPnetModel
from espnet.nets.pytorch_backend.rnn.attentions import (
AttAdd,
AttCov,
AttCovLoc,
AttDot,
AttForwar... | 5,510 | 31.609467 | 82 | py |
espnet | espnet-master/espnet2/main_funcs/average_nbest_models.py | import logging
import warnings
from pathlib import Path
from typing import Collection, Optional, Sequence, Union
import torch
from typeguard import check_argument_types
from espnet2.train.reporter import Reporter
@torch.no_grad()
def average_nbest_models(
output_dir: Path,
reporter: Reporter,
best_model... | 3,886 | 34.66055 | 88 | py |
espnet | espnet-master/espnet2/main_funcs/pack_funcs.py | import os
import sys
import tarfile
import zipfile
from datetime import datetime
from io import BytesIO, TextIOWrapper
from pathlib import Path
from typing import Dict, Iterable, Optional, Union
import yaml
class Archiver:
def __init__(self, file, mode="r"):
if Path(file).suffix == ".tar":
se... | 9,839 | 32.020134 | 87 | py |
espnet | espnet-master/espnet2/slu/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... | 16,575 | 37.459397 | 88 | py |
espnet | espnet-master/espnet2/slu/postencoder/conformer_postencoder.py | #!/usr/bin/env python3
# 2021, Carnegie Mellon University; Siddhant Arora
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""Conformers PostEncoder."""
import logging
from typing import Tuple
import torch
from typeguard import check_argument_types
from espnet2.asr.postencoder.abs_postencoder import Abs... | 10,132 | 39.370518 | 88 | py |
espnet | espnet-master/espnet2/slu/postencoder/transformer_postencoder.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.postencoder.abs_postencoder import AbsPostEncoder
from espnet.nets.pytorch_backend.nets_uti... | 5,830 | 36.140127 | 82 | py |
espnet | espnet-master/espnet2/slu/postdecoder/abs_postdecoder.py | from abc import ABC, abstractmethod
import torch
class AbsPostDecoder(torch.nn.Module, ABC):
@abstractmethod
def output_size(self) -> int:
raise NotImplementedError
@abstractmethod
def forward(
self,
transcript_input_ids: torch.LongTensor,
transcript_attention_mask: t... | 662 | 24.5 | 63 | py |
espnet | espnet-master/espnet2/slu/postdecoder/hugging_face_transformers_postdecoder.py | #!/usr/bin/env python3
# 2022, Carnegie Mellon University; Siddhant Arora
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""Hugging Face Transformers PostDecoder."""
from espnet2.slu.postdecoder.abs_postdecoder import AbsPostDecoder
try:
from transformers import AutoModel, AutoTokenizer
is_tr... | 3,807 | 34.588785 | 87 | py |
espnet | espnet-master/espnet2/bin/enh_inference.py | #!/usr/bin/env python3
import argparse
import logging
import sys
from itertools import chain
from pathlib import Path
from typing import Any, List, Optional, Sequence, Tuple, Union
import humanfriendly
import numpy as np
import torch
import yaml
from tqdm import trange
from typeguard import check_argument_types
from ... | 21,910 | 33.724247 | 88 | py |
espnet | espnet-master/espnet2/bin/slu_inference.py | #!/usr/bin/env python3
import argparse
import logging
import sys
from distutils.version import LooseVersion
from pathlib import Path
from typing import Any, List, Optional, Sequence, Tuple, Union
import numpy as np
import torch
import torch.quantization
from typeguard import check_argument_types, check_return_type
fr... | 23,605 | 32.578947 | 88 | py |
espnet | espnet-master/espnet2/bin/asr_inference_maskctc.py | #!/usr/bin/env python3
import argparse
import logging
import sys
from pathlib import Path
from typing import Any, List, Optional, Sequence, Tuple, Union
import numpy as np
import torch
from typeguard import check_argument_types, check_return_type
from espnet2.asr.maskctc_model import MaskCTCInference
from espnet2.fil... | 11,952 | 30.70557 | 85 | py |
espnet | espnet-master/espnet2/bin/asr_inference_k2.py | #!/usr/bin/env python3
import argparse
import datetime
import logging
import sys
from pathlib import Path
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
import k2
import numpy as np
import torch
import yaml
from typeguard import check_argument_types, check_return_type
from espnet2.fileio.datadir... | 26,605 | 34.054018 | 88 | py |
espnet | espnet-master/espnet2/bin/mt_inference.py | #!/usr/bin/env python3
import argparse
import logging
import sys
from pathlib import Path
from typing import Any, List, Optional, Sequence, Tuple, Union
import numpy as np
import torch
from typeguard import check_argument_types, check_return_type
from espnet2.fileio.datadir_writer import DatadirWriter
from espnet2.ta... | 17,802 | 31.369091 | 87 | py |
espnet | espnet-master/espnet2/bin/lm_calc_perplexity.py | #!/usr/bin/env python3
import argparse
import logging
import sys
from pathlib import Path
from typing import Optional, Sequence, Tuple, Union
import numpy as np
import torch
from torch.nn.parallel import data_parallel
from typeguard import check_argument_types
from espnet2.fileio.datadir_writer import DatadirWriter
f... | 6,595 | 31.17561 | 86 | py |
espnet | espnet-master/espnet2/bin/st_inference_streaming.py | #!/usr/bin/env python3
import argparse
import logging
import math
import sys
from pathlib import Path
from typing import List, Optional, Sequence, Tuple, Union
import numpy as np
import torch
from typeguard import check_argument_types, check_return_type
from espnet2.asr.encoder.contextual_block_conformer_encoder impo... | 20,953 | 33.238562 | 87 | py |
espnet | espnet-master/espnet2/bin/diar_inference.py | #!/usr/bin/env python3
import argparse
import logging
import sys
from itertools import permutations
from pathlib import Path
from typing import Any, List, Optional, Sequence, Tuple, Union
import numpy as np
import torch
import torch.nn.functional as F
from tqdm import trange
from typeguard import check_argument_types... | 26,815 | 35.53406 | 88 | py |
espnet | espnet-master/espnet2/bin/tts_inference.py | #!/usr/bin/env python3
"""Script to run the inference of text-to-speeech model."""
import argparse
import logging
import shutil
import sys
import time
from pathlib import Path
from typing import Any, Dict, Optional, Sequence, Tuple, Union
import numpy as np
import soundfile as sf
import torch
from packaging.version ... | 25,855 | 33.428762 | 88 | py |
espnet | espnet-master/espnet2/bin/enh_inference_streaming.py | #!/usr/bin/env python3
import argparse
import logging
import math
import sys
from itertools import chain
from pathlib import Path
from typing import Any, List, Optional, Sequence, Tuple, Union
import humanfriendly
import numpy as np
import torch
import torch_complex
import yaml
from typeguard import check_argument_typ... | 14,477 | 30.680525 | 88 | py |
espnet | espnet-master/espnet2/bin/asr_transducer_inference.py | #!/usr/bin/env python3
""" Inference class definition for Transducer models."""
from __future__ import annotations
import argparse
import logging
import sys
from pathlib import Path
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
import numpy as np
import torch
from packaging.version import par... | 23,356 | 31.804775 | 88 | py |
espnet | espnet-master/espnet2/bin/st_inference.py | #!/usr/bin/env python3
import argparse
import logging
import sys
from pathlib import Path
from typing import Any, List, Optional, Sequence, Tuple, Union
import numpy as np
import torch
from typeguard import check_argument_types, check_return_type
from espnet2.fileio.datadir_writer import DatadirWriter
from espnet2.ta... | 17,745 | 31.206897 | 87 | py |
espnet | espnet-master/espnet2/bin/lm_inference.py | #!/usr/bin/env python3
import argparse
import logging
import sys
from pathlib import Path
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
import numpy as np
import torch
import torch.quantization
from typeguard import check_argument_types, check_return_type
from espnet2.fileio.datadir_writer impo... | 17,623 | 30.640934 | 87 | py |
espnet | espnet-master/espnet2/bin/asr_inference.py | #!/usr/bin/env python3
import argparse
import logging
import sys
from distutils.version import LooseVersion
from itertools import groupby
from pathlib import Path
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
import numpy as np
import torch
import torch.quantization
from typeguard import check_a... | 34,289 | 34.386997 | 88 | py |
espnet | espnet-master/espnet2/bin/uasr_inference_k2.py | #!/usr/bin/env python3
import argparse
import datetime
import logging
import sys
from pathlib import Path
from typing import Any, List, Optional, Sequence, Tuple, Union
import numpy as np
import torch
import yaml
from typeguard import check_argument_types, check_return_type
from espnet2.fileio.datadir_writer import D... | 21,667 | 33.503185 | 88 | py |
espnet | espnet-master/espnet2/bin/launch.py | #!/usr/bin/env python3
import argparse
import logging
import os
import shlex
import shutil
import subprocess
import sys
import uuid
from pathlib import Path
from espnet2.utils.types import str2bool, str_or_none
from espnet.utils.cli_utils import get_commandline_args
def get_parser():
parser = argparse.ArgumentPa... | 13,042 | 32.877922 | 173 | py |
espnet | espnet-master/espnet2/bin/enh_scoring.py | #!/usr/bin/env python3
import argparse
import logging
import re
import sys
from pathlib import Path
from typing import Dict, List, Union
import numpy as np
import torch
from mir_eval.separation import bss_eval_sources
from pystoi import stoi
from typeguard import check_argument_types
from espnet2.enh.loss.criterions.... | 13,261 | 36.252809 | 88 | py |
espnet | espnet-master/espnet2/bin/asr_inference_streaming.py | #!/usr/bin/env python3
import argparse
import logging
import math
import sys
from pathlib import Path
from typing import List, Optional, Sequence, Tuple, Union
import numpy as np
import torch
from typeguard import check_argument_types, check_return_type
from espnet2.asr.encoder.contextual_block_conformer_encoder impo... | 21,829 | 33.432177 | 87 | py |
espnet | espnet-master/espnet2/bin/svs_inference.py | #!/usr/bin/env python3
"""Script to run the inference of singing-voice-synthesis model."""
import argparse
import logging
import shutil
import sys
import time
from pathlib import Path
from typing import Any, Dict, Optional, Sequence, Tuple, Union
import numpy as np
import soundfile as sf
import torch
from typeguard ... | 23,443 | 33.991045 | 88 | py |
espnet | espnet-master/espnet2/bin/uasr_extract_feature.py | #!/usr/bin/env python3
import argparse
import logging
import sys
from pathlib import Path
from typing import Optional, Sequence, Tuple, Union
from torch.nn.parallel import data_parallel
from typeguard import check_argument_types
from espnet2.fileio.npy_scp import NpyScpWriter
from espnet2.tasks.uasr import UASRTask
f... | 4,900 | 26.227778 | 82 | py |
espnet | espnet-master/espnet2/bin/asr_align.py | #!/usr/bin/env python3
# Copyright 2021, Ludwig Kürzinger; Kamo Naoyuki
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""Perform CTC segmentation to align utterances within audio files."""
import argparse
import logging
import sys
from pathlib import Path
from typing import List, Optional, TextIO, Union
... | 32,283 | 38.084746 | 88 | py |
espnet | espnet-master/espnet2/bin/asvspoof_inference.py | #!/usr/bin/env python3
import argparse
import logging
import sys
from distutils.version import LooseVersion
from pathlib import Path
from typing import Any, List, Optional, Sequence, Tuple, Union
import numpy as np
import torch
import torch.quantization
from typeguard import check_argument_types, check_return_type
fr... | 7,971 | 29.899225 | 86 | py |
espnet | espnet-master/espnet2/bin/uasr_inference.py | #!/usr/bin/env python3
import argparse
import logging
import sys
from distutils.version import LooseVersion
from pathlib import Path
from typing import Any, List, Optional, Sequence, Tuple, Union
import numpy as np
import torch
import torch.quantization
from typeguard import check_argument_types, check_return_type
fr... | 19,155 | 31.80137 | 87 | py |
espnet | espnet-master/espnet2/bin/enh_tse_inference.py | #!/usr/bin/env python3
import argparse
import logging
import sys
from itertools import chain
from pathlib import Path
from typing import Any, List, Optional, Sequence, Tuple, Union
import humanfriendly
import numpy as np
import torch
import yaml
from tqdm import trange
from typeguard import check_argument_types
from ... | 22,792 | 33.692542 | 88 | py |
espnet | espnet-master/espnet2/uasr/espnet_model.py | import argparse
import logging
from contextlib import contextmanager
from typing import Dict, Optional, Tuple
import editdistance
import torch
import torch.nn.functional as F
from packaging.version import parse as V
from typeguard import check_argument_types
from espnet2.asr.frontend.abs_frontend import AbsFrontend
f... | 15,490 | 34.941995 | 87 | py |
espnet | espnet-master/espnet2/uasr/discriminator/abs_discriminator.py | from abc import ABC, abstractmethod
import torch
class AbsDiscriminator(torch.nn.Module, ABC):
@abstractmethod
def forward(
self,
xs_pad: torch.Tensor,
padding_mask: torch.Tensor,
) -> torch.Tensor:
raise NotImplementedError
| 272 | 18.5 | 45 | py |
espnet | espnet-master/espnet2/uasr/discriminator/conv_discriminator.py | import argparse
from typing import Dict, Optional
import torch
from typeguard import check_argument_types
from espnet2.uasr.discriminator.abs_discriminator import AbsDiscriminator
from espnet2.utils.types import str2bool
class SamePad(torch.nn.Module):
def __init__(self, kernel_size, causal=False):
supe... | 5,634 | 31.385057 | 87 | py |
espnet | espnet-master/espnet2/uasr/loss/gradient_penalty.py | import numpy as np
import torch
from torch import autograd
from typeguard import check_argument_types
from espnet2.uasr.discriminator.abs_discriminator import AbsDiscriminator
from espnet2.uasr.loss.abs_loss import AbsUASRLoss
from espnet2.utils.types import str2bool
class UASRGradientPenalty(AbsUASRLoss):
"""gr... | 3,160 | 33.736264 | 84 | py |
espnet | espnet-master/espnet2/uasr/loss/smoothness_penalty.py | import torch
import torch.nn.functional as F
from typeguard import check_argument_types
from espnet2.uasr.loss.abs_loss import AbsUASRLoss
class UASRSmoothnessPenalty(AbsUASRLoss):
"""smoothness penalty for UASR."""
def __init__(
self,
weight: float = 1.0,
reduction: str = "none",
... | 1,308 | 26.851064 | 83 | py |
espnet | espnet-master/espnet2/uasr/loss/phoneme_diversity_loss.py | import torch
from typeguard import check_argument_types
from espnet2.uasr.loss.abs_loss import AbsUASRLoss
from espnet2.utils.types import str2bool
class UASRPhonemeDiversityLoss(AbsUASRLoss):
"""phoneme diversity loss for UASR."""
def __init__(
self,
weight: float = 1.0,
):
supe... | 1,316 | 27.630435 | 87 | py |
espnet | espnet-master/espnet2/uasr/loss/abs_loss.py | from abc import ABC, abstractmethod
import torch
EPS = torch.finfo(torch.get_default_dtype()).eps
class AbsUASRLoss(torch.nn.Module, ABC):
"""Base class for all Diarization loss modules."""
# the name will be the key that appears in the reporter
@property
def name(self) -> str:
return NotIm... | 499 | 21.727273 | 59 | py |
espnet | espnet-master/espnet2/uasr/loss/pseudo_label_loss.py | import torch
import torch.nn.functional as F
from typeguard import check_argument_types
from espnet2.uasr.loss.abs_loss import AbsUASRLoss
from espnet2.utils.types import str2bool
class UASRPseudoLabelLoss(AbsUASRLoss):
"""auxiliary pseudo label loss for UASR."""
def __init__(
self,
weight: ... | 1,847 | 29.295082 | 88 | py |
espnet | espnet-master/espnet2/uasr/loss/discriminator_loss.py | import torch
import torch.nn.functional as F
from typeguard import check_argument_types
from espnet2.uasr.loss.abs_loss import AbsUASRLoss
from espnet2.utils.types import str2bool
class UASRDiscriminatorLoss(AbsUASRLoss):
"""discriminator loss for UASR."""
def __init__(
self,
weight: float =... | 1,994 | 29.227273 | 67 | py |
espnet | espnet-master/espnet2/uasr/segmenter/abs_segmenter.py | """
Segmenter definition for UASR task
Practially, the output of the generator (in frame-level) may
predict the same phoneme for consecutive frames, which makes
it too easy for the discriminator. So, the segmenter here is
to merge frames with a similar prediction from the generator output.
"""
from abc import ABC, ab... | 736 | 22.774194 | 68 | py |
espnet | espnet-master/espnet2/uasr/segmenter/random_segmenter.py | import math
import torch
from typeguard import check_argument_types
from espnet2.uasr.segmenter.abs_segmenter import AbsSegmenter
from espnet2.utils.types import str2bool
class RandomSegmenter(AbsSegmenter):
def __init__(
self,
subsample_rate: float = 0.25,
mean_pool: str2bool = True,
... | 1,222 | 28.829268 | 74 | py |
espnet | espnet-master/espnet2/uasr/segmenter/join_segmenter.py | import argparse
from typing import Dict, Optional
import torch
from typeguard import check_argument_types
from espnet2.uasr.segmenter.abs_segmenter import AbsSegmenter
from espnet2.utils.types import str2bool
class JoinSegmenter(AbsSegmenter):
def __init__(
self,
cfg: Optional[Dict] = None,
... | 3,165 | 31.639175 | 83 | py |
espnet | espnet-master/espnet2/uasr/generator/abs_generator.py | from abc import ABC, abstractmethod
from typing import Optional, Tuple
import torch
class AbsGenerator(torch.nn.Module, ABC):
@abstractmethod
def output_size(self) -> int:
raise NotImplementedError
@abstractmethod
def forward(
self,
xs_pad: torch.Tensor,
ilens: torch.... | 430 | 21.684211 | 67 | py |
espnet | espnet-master/espnet2/uasr/generator/conv_generator.py | import argparse
import logging
from typing import Dict, Optional
import torch
from typeguard import check_argument_types
from espnet2.uasr.generator.abs_generator import AbsGenerator
from espnet2.utils.types import str2bool
class TransposeLast(torch.nn.Module):
def __init__(self, deconstruct_idx=None):
... | 5,254 | 31.84375 | 88 | py |
espnet | espnet-master/espnet2/st/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... | 16,065 | 34.781737 | 88 | py |
espnet | espnet-master/espnet2/hubert/espnet_model.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 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/master/examples/hubert
import logging
from ... | 16,726 | 33.559917 | 86 | py |
espnet | espnet-master/espnet2/hubert/hubert_loss.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# The HubertPretrainLoss Module uses code from Fairseq:
# https://github.com/pytorch/fairseq/blob/master/fairseq/criterions/hubert_criterion.py
#
# Thanks to Abdelrahman Mohamed and Wei-Ning Hsu's help in this implementation,
# Their origial Hubert work is in:
# P... | 2,827 | 36.706667 | 91 | py |
espnet | espnet-master/espnet2/diar/abs_diar.py | from abc import ABC, abstractmethod
from collections import OrderedDict
from typing import Tuple
import torch
class AbsDiarization(torch.nn.Module, ABC):
# @abstractmethod
# def output_size(self) -> int:
# raise NotImplementedError
@abstractmethod
def forward(
self,
input: to... | 643 | 23.769231 | 56 | py |
espnet | espnet-master/espnet2/diar/espnet_model.py | # Copyright 2021 Jiatong Shi
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
from contextlib import contextmanager
from itertools import permutations
from typing import Dict, Optional, Tuple
import numpy as np
import torch
import torch.nn.functional as F
from packaging.version import parse as V
from typeg... | 14,924 | 38.070681 | 88 | py |
espnet | espnet-master/espnet2/diar/label_processor.py | import torch
from espnet2.layers.label_aggregation import LabelAggregate
class LabelProcessor(torch.nn.Module):
"""Label aggregator for speaker diarization"""
def __init__(
self, win_length: int = 512, hop_length: int = 128, center: bool = True
):
super().__init__()
self.label_ag... | 749 | 24 | 79 | py |
espnet | espnet-master/espnet2/diar/separator/tcn_separator_nomask.py | from distutils.version import LooseVersion
from typing import Tuple, Union
import torch
from torch_complex.tensor import ComplexTensor
from espnet2.diar.layers.tcn_nomask import TemporalConvNet
from espnet2.enh.layers.complex_utils import is_complex
from espnet2.enh.separator.abs_separator import AbsSeparator
is_tor... | 2,737 | 28.76087 | 76 | py |
espnet | espnet-master/espnet2/diar/attractor/abs_attractor.py | from abc import ABC, abstractmethod
from typing import Tuple
import torch
class AbsAttractor(torch.nn.Module, ABC):
@abstractmethod
def forward(
self,
enc_input: torch.Tensor,
ilens: torch.Tensor,
dec_input: torch.Tensor,
) -> Tuple[torch.Tensor, torch.Tensor]:
rai... | 343 | 20.5 | 43 | py |
espnet | espnet-master/espnet2/diar/attractor/rnn_attractor.py | import torch
from espnet2.diar.attractor.abs_attractor import AbsAttractor
class RnnAttractor(AbsAttractor):
"""encoder decoder attractor for speaker diarization"""
def __init__(
self,
encoder_output_size: int,
layer: int = 1,
unit: int = 512,
dropout: float = 0.1,
... | 2,007 | 29.424242 | 83 | py |
espnet | espnet-master/espnet2/diar/layers/tcn_nomask.py | # Implementation of the TCN proposed in
# Luo. et al. "Conv-tasnet: Surpassing ideal time–frequency
# magnitude masking for speech separation."
#
# The code is based on:
# https://github.com/kaituoxu/Conv-TasNet/blob/master/src/conv_tasnet.py
#
import torch
import torch.nn as nn
EPS = torch.finfo(torch.get_default_... | 7,701 | 28.064151 | 88 | py |
espnet | espnet-master/espnet2/diar/layers/abs_mask.py | from abc import ABC, abstractmethod
from collections import OrderedDict
from typing import Tuple
import torch
class AbsMask(torch.nn.Module, ABC):
@property
@abstractmethod
def max_num_spk(self) -> int:
raise NotImplementedError
@abstractmethod
def forward(
self,
input,
... | 474 | 19.652174 | 63 | py |
espnet | espnet-master/espnet2/diar/layers/multi_mask.py | # This is an implementation of the multiple 1x1 convolution layer architecture
# in https://arxiv.org/pdf/2203.17068.pdf
from collections import OrderedDict
from typing import List, Tuple, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_complex.tensor import ComplexTensor
from esp... | 4,124 | 34.869565 | 87 | py |
espnet | espnet-master/espnet2/diar/decoder/linear_decoder.py | import torch
from espnet2.diar.decoder.abs_decoder import AbsDecoder
class LinearDecoder(AbsDecoder):
"""Linear decoder for speaker diarization"""
def __init__(
self,
encoder_output_size: int,
num_spk: int = 2,
):
super().__init__()
self._num_spk = num_spk
... | 754 | 21.878788 | 75 | py |
espnet | espnet-master/espnet2/diar/decoder/abs_decoder.py | from abc import ABC, abstractmethod
from typing import Tuple
import torch
class AbsDecoder(torch.nn.Module, ABC):
@abstractmethod
def forward(
self,
input: torch.Tensor,
ilens: torch.Tensor,
) -> Tuple[torch.Tensor, torch.Tensor]:
raise NotImplementedError
@property
... | 396 | 18.85 | 43 | py |
espnet | espnet-master/espnet2/layers/inversible_interface.py | from abc import ABC, abstractmethod
from typing import Tuple
import torch
class InversibleInterface(ABC):
@abstractmethod
def inverse(
self, input: torch.Tensor, input_lengths: torch.Tensor = None
) -> Tuple[torch.Tensor, torch.Tensor]:
# return output, output_lengths
raise NotImp... | 334 | 22.928571 | 69 | py |
espnet | espnet-master/espnet2/layers/stft.py | from typing import Optional, Tuple, Union
import librosa
import numpy as np
import torch
from packaging.version import parse as V
from torch_complex.tensor import ComplexTensor
from typeguard import check_argument_types
from espnet2.enh.layers.complex_utils import is_complex
from espnet2.layers.inversible_interface i... | 8,787 | 34.869388 | 86 | py |
espnet | espnet-master/espnet2/layers/global_mvn.py | from pathlib import Path
from typing import Tuple, Union
import numpy as np
import torch
from typeguard import check_argument_types
from espnet2.layers.abs_normalize import AbsNormalize
from espnet2.layers.inversible_interface import InversibleInterface
from espnet.nets.pytorch_backend.nets_utils import make_pad_mask... | 3,746 | 27.823077 | 71 | py |
espnet | espnet-master/espnet2/layers/utterance_mvn.py | from typing import Tuple
import torch
from typeguard import check_argument_types
from espnet2.layers.abs_normalize import AbsNormalize
from espnet.nets.pytorch_backend.nets_utils import make_pad_mask
class UtteranceMVN(AbsNormalize):
def __init__(
self,
norm_means: bool = True,
norm_vars... | 2,316 | 25.033708 | 83 | py |
espnet | espnet-master/espnet2/layers/mask_along_axis.py | import math
from typing import Sequence, Union
import torch
from typeguard import check_argument_types
def mask_along_axis(
spec: torch.Tensor,
spec_lengths: torch.Tensor,
mask_width_range: Sequence[int] = (0, 30),
dim: int = 1,
num_mask: int = 2,
replace_with_zero: bool = True,
):
"""App... | 6,242 | 29.453659 | 85 | py |
espnet | espnet-master/espnet2/layers/label_aggregation.py | from typing import Optional, Tuple
import torch
from typeguard import check_argument_types
from espnet.nets.pytorch_backend.nets_utils import make_pad_mask
class LabelAggregate(torch.nn.Module):
def __init__(
self,
win_length: int = 512,
hop_length: int = 128,
center: bool = True... | 2,519 | 29.361446 | 83 | py |
espnet | espnet-master/espnet2/layers/log_mel.py | from typing import Tuple
import librosa
import torch
from espnet.nets.pytorch_backend.nets_utils import make_pad_mask
class LogMel(torch.nn.Module):
"""Convert STFT to fbank feats
The arguments is same as librosa.filters.mel
Args:
fs: number > 0 [scalar] sampling rate of the incoming signal
... | 2,578 | 29.341176 | 74 | py |
espnet | espnet-master/espnet2/layers/abs_normalize.py | from abc import ABC, abstractmethod
from typing import Tuple
import torch
class AbsNormalize(torch.nn.Module, ABC):
@abstractmethod
def forward(
self, input: torch.Tensor, input_lengths: torch.Tensor = None
) -> Tuple[torch.Tensor, torch.Tensor]:
# return output, output_lengths
ra... | 344 | 23.642857 | 69 | py |
espnet | espnet-master/espnet2/layers/sinc_conv.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."""
import math
from typing import Union
import torch
from typeguard import check_argument_types
class LogCompression(torch.nn.Module):
"""Log Compre... | 9,028 | 31.832727 | 84 | py |
espnet | espnet-master/espnet2/layers/time_warp.py | """Time warp module."""
import torch
from espnet.nets.pytorch_backend.nets_utils import pad_list
DEFAULT_TIME_WARP_MODE = "bicubic"
def time_warp(x: torch.Tensor, window: int = 80, mode: str = DEFAULT_TIME_WARP_MODE):
"""Time warping using torch.interpolate.
Args:
x: (Batch, Time, Freq)
win... | 2,526 | 27.393258 | 85 | py |
espnet | espnet-master/espnet2/fst/lm_rescore.py | import math
from typing import List, Tuple
import torch
try:
import k2
except ImportError or ModuleNotFoundError:
k2 = None
def remove_repeated_and_leq(tokens: List[int], blank_id: int = 0):
"""Generate valid token sequence.
Result may be used as input of transformer decoder and neural language mod... | 7,517 | 33.486239 | 88 | py |
espnet | espnet-master/espnet2/train/abs_gan_espnet_model.py | # Copyright 2021 Tomoki Hayashi
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""ESPnetModel abstract class for GAN-based training."""
from abc import ABC, abstractmethod
from typing import Dict, Union
import torch
from espnet2.train.abs_espnet_model import AbsESPnetModel
class AbsGANESPnetModel(Abs... | 2,913 | 40.042254 | 87 | py |
espnet | espnet-master/espnet2/train/reporter.py | """Reporter module."""
import dataclasses
import datetime
import logging
import time
import warnings
from collections import defaultdict
from contextlib import contextmanager
from pathlib import Path
from typing import ContextManager, Dict, List, Optional, Sequence, Tuple, Union
import humanfriendly
import numpy as np... | 19,602 | 32.740103 | 88 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.