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/asr_transducer/joint_network.py
"""Transducer joint network implementation.""" import torch from espnet2.asr_transducer.activation import get_activation class JointNetwork(torch.nn.Module): """Transducer joint network module. Args: output_size: Output size. encoder_size: Encoder output size. decoder_size: Decoder ...
2,097
29.405797
75
py
espnet
espnet-master/espnet2/asr_transducer/activation.py
"""Activation functions for Transducer models.""" import torch from packaging.version import parse as V def get_activation( activation_type: str, ftswish_threshold: float = -0.2, ftswish_mean_shift: float = 0.0, hardtanh_min_val: int = -1.0, hardtanh_max_val: int = 1.0, leakyrelu_neg_slope: f...
6,737
30.485981
87
py
espnet
espnet-master/espnet2/asr_transducer/utils.py
"""Utility functions for Transducer models.""" from typing import List, Tuple, Union import torch class TooShortUttError(Exception): """Raised when the utt is too short for subsampling. Args: message: Error message to display. actual_size: The size that cannot pass the subsampling. ...
5,616
26.26699
85
py
espnet
espnet-master/espnet2/asr_transducer/beam_search_transducer.py
"""Search algorithms for Transducer models.""" from dataclasses import dataclass from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np import torch from espnet2.asr_transducer.decoder.abs_decoder import AbsDecoder from espnet2.asr_transducer.joint_network import JointNetwork @dataclass clas...
22,742
31.49
88
py
espnet
espnet-master/espnet2/asr_transducer/error_calculator.py
"""Error Calculator module for Transducer.""" from typing import List, Optional, Tuple import torch from espnet2.asr_transducer.beam_search_transducer import BeamSearchTransducer from espnet2.asr_transducer.decoder.abs_decoder import AbsDecoder from espnet2.asr_transducer.joint_network import JointNetwork class Er...
6,162
30.932642
88
py
espnet
espnet-master/espnet2/asr_transducer/normalization.py
"""Normalization modules for Transducer.""" from typing import Dict, Optional, Tuple import torch def get_normalization( normalization_type: str, eps: Optional[float] = None, partial: Optional[float] = None, ) -> Tuple[torch.nn.Module, Dict]: """Get normalization module and arguments given parameter...
4,449
25.023392
87
py
espnet
espnet-master/espnet2/asr_transducer/espnet_transducer_model.py
"""ESPnet2 ASR Transducer model.""" 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.frontend.abs_frontend import AbsFrontend from espnet2.asr.sp...
21,402
32.758675
88
py
espnet
espnet-master/espnet2/asr_transducer/frontend/online_audio_processor.py
"""Online processor for Transducer models chunk-by-chunk streaming decoding.""" from typing import Dict, Tuple import torch class OnlineAudioProcessor: """OnlineProcessor module definition. Args: feature_extractor: Feature extractor module. normalization_module: Normalization module. ...
5,265
30.159763
85
py
espnet
espnet-master/espnet2/asr_transducer/encoder/building.py
"""Set of methods to build Transducer encoder architecture.""" from typing import Any, Dict, List, Optional, Union from espnet2.asr_transducer.activation import get_activation from espnet2.asr_transducer.encoder.blocks.branchformer import Branchformer from espnet2.asr_transducer.encoder.blocks.conformer import Confor...
12,952
29.767221
86
py
espnet
espnet-master/espnet2/asr_transducer/encoder/encoder.py
"""Encoder for Transducer model.""" from typing import Any, Dict, List, Tuple import torch from typeguard import check_argument_types from espnet2.asr_transducer.encoder.building import ( build_body_blocks, build_input_block, build_main_parameters, build_positional_encoding, ) from espnet2.asr_transd...
5,102
27.830508
85
py
espnet
espnet-master/espnet2/asr_transducer/encoder/modules/convolution.py
"""Convolution modules for X-former blocks.""" from typing import Dict, Optional, Tuple import torch class ConformerConvolution(torch.nn.Module): """ConformerConvolution module definition. Args: channels: The number of channels. kernel_size: Size of the convolving kernel. activation...
7,416
26.675373
85
py
espnet
espnet-master/espnet2/asr_transducer/encoder/modules/multi_blocks.py
"""MultiBlocks for encoder architecture.""" from typing import Dict, List, Optional import torch class MultiBlocks(torch.nn.Module): """MultiBlocks definition. Args: block_list: Individual blocks of the encoder architecture. output_size: Architecture output size. norm_class: Normali...
3,435
29.40708
86
py
espnet
espnet-master/espnet2/asr_transducer/encoder/modules/positional_encoding.py
"""Positional encoding modules.""" import math import torch from espnet.nets.pytorch_backend.transformer.embedding import _pre_hook class RelPositionalEncoding(torch.nn.Module): """Relative positional encoding. Args: size: Module size. max_len: Maximum input length. dropout_rate: D...
2,878
29.62766
82
py
espnet
espnet-master/espnet2/asr_transducer/encoder/modules/normalization.py
"""Normalization modules for X-former blocks.""" from typing import Dict, Optional, Tuple import torch def get_normalization( normalization_type: str, eps: Optional[float] = None, partial: Optional[float] = None, ) -> Tuple[torch.nn.Module, Dict]: """Get normalization module and arguments given para...
4,454
25.052632
87
py
espnet
espnet-master/espnet2/asr_transducer/encoder/modules/attention.py
"""Multi-Head attention layers with relative positional encoding.""" import math from typing import Optional, Tuple import torch class RelPositionMultiHeadedAttention(torch.nn.Module): """RelPositionMultiHeadedAttention definition. Args: num_heads: Number of attention heads. embed_size: Emb...
8,228
31.270588
88
py
espnet
espnet-master/espnet2/asr_transducer/encoder/blocks/branchformer.py
"""Branchformer block for Transducer encoder.""" from typing import Dict, Optional, Tuple import torch class Branchformer(torch.nn.Module): """Branchformer module definition. Reference: https://arxiv.org/pdf/2207.02971.pdf Args: block_size: Input/output size. linear_size: Linear layers...
5,017
28.00578
87
py
espnet
espnet-master/espnet2/asr_transducer/encoder/blocks/conv1d.py
"""Conv1d block for Transducer encoder.""" from typing import Optional, Tuple, Union import torch class Conv1d(torch.nn.Module): """Conv1d module definition. Args: input_size: Input dimension. output_size: Output dimension. kernel_size: Size of the convolving kernel. stride:...
6,398
28.353211
85
py
espnet
espnet-master/espnet2/asr_transducer/encoder/blocks/conformer.py
"""Conformer block for Transducer encoder.""" from typing import Dict, Optional, Tuple import torch class Conformer(torch.nn.Module): """Conformer module definition. Args: block_size: Input/output size. self_att: Self-attention module instance. feed_forward: Feed-forward module inst...
5,560
27.085859
87
py
espnet
espnet-master/espnet2/asr_transducer/encoder/blocks/conv_input.py
"""ConvInput block for Transducer encoder.""" from typing import Optional, Tuple, Union import torch from espnet2.asr_transducer.utils import get_convinput_module_parameters class ConvInput(torch.nn.Module): """ConvInput module definition. Args: input_size: Input size. conv_size: Convoluti...
3,412
30.311927
80
py
espnet
espnet-master/espnet2/asr_transducer/encoder/blocks/ebranchformer.py
"""E-Branchformer block for Transducer encoder.""" from typing import Dict, Optional, Tuple import torch class EBranchformer(torch.nn.Module): """E-Branchformer module definition. Reference: https://arxiv.org/pdf/2210.00077.pdf Args: block_size: Input/output size. linear_size: Linear l...
6,771
29.781818
87
py
espnet
espnet-master/espnet2/asr_transducer/decoder/rnn_decoder.py
"""RNN decoder definition for Transducer models.""" from typing import List, Optional, Tuple import torch from typeguard import check_argument_types from espnet2.asr_transducer.beam_search_transducer import Hypothesis from espnet2.asr_transducer.decoder.abs_decoder import AbsDecoder class RNNDecoder(AbsDecoder): ...
7,707
28.532567
87
py
espnet
espnet-master/espnet2/asr_transducer/decoder/stateless_decoder.py
"""Stateless decoder definition for Transducer models.""" from typing import Any, List, Optional, Tuple import torch from typeguard import check_argument_types from espnet2.asr_transducer.beam_search_transducer import Hypothesis from espnet2.asr_transducer.decoder.abs_decoder import AbsDecoder class StatelessDecod...
4,095
24.128834
86
py
espnet
espnet-master/espnet2/asr_transducer/decoder/abs_decoder.py
"""Abstract decoder definition for Transducer models.""" from abc import ABC, abstractmethod from typing import Any, Dict, List, Optional, Tuple, Union import torch class AbsDecoder(torch.nn.Module, ABC): """Abstract decoder module.""" @abstractmethod def forward(self, labels: torch.Tensor) -> torch.Te...
3,755
22.622642
76
py
espnet
espnet-master/espnet2/asr_transducer/decoder/mega_decoder.py
"""MEGA decoder definition for Transducer models.""" import math from typing import Dict, List, Optional, Tuple import torch from typeguard import check_argument_types from espnet2.asr_transducer.activation import get_activation from espnet2.asr_transducer.beam_search_transducer import Hypothesis from espnet2.asr_tr...
11,982
31.040107
86
py
espnet
espnet-master/espnet2/asr_transducer/decoder/rwkv_decoder.py
"""RWKV decoder definition for Transducer models.""" import math from typing import Dict, List, Optional, Tuple import torch from typeguard import check_argument_types from espnet2.asr_transducer.beam_search_transducer import Hypothesis from espnet2.asr_transducer.decoder.abs_decoder import AbsDecoder from espnet2.a...
8,252
28.370107
86
py
espnet
espnet-master/espnet2/asr_transducer/decoder/modules/mega/feed_forward.py
"""Normalized position-wise feed-forward module for MEGA block.""" import torch class NormalizedPositionwiseFeedForward(torch.nn.Module): """NormalizedPositionFeedForward module definition. Args: size: Input/Output size. hidden_size: Hidden size. normalization: Normalization module. ...
2,076
27.452055
79
py
espnet
espnet-master/espnet2/asr_transducer/decoder/modules/mega/multi_head_damped_ema.py
"""Multi-head Damped Exponential Moving Average (EMA) module for MEGA block. Based/modified from https://github.com/facebookresearch/mega/blob/main/fairseq/modules/moving_average_gated_attention.py Most variables are renamed according to https://github.com/huggingface/transformers/blob/main/src/transformers/models/me...
7,009
30.576577
140
py
espnet
espnet-master/espnet2/asr_transducer/decoder/modules/mega/positional_bias.py
"""Positional bias related modules. Based/modified from https://github.com/facebookresearch/mega/blob/main/fairseq/modules/relative_positional_bias.py """ # noqa import math from typing import Tuple import torch class RelativePositionBias(torch.nn.Module): """RelativePositionBias module definition. Args:...
5,037
26.232432
114
py
espnet
espnet-master/espnet2/asr_transducer/decoder/modules/rwkv/feed_forward.py
"""Feed-forward (channel mixing) module for RWKV block. Based/Modified from https://github.com/BlinkDL/RWKV-LM/blob/main/RWKV-v4/src/model.py Some variables are renamed according to https://github.com/huggingface/transformers/blob/main/src/transformers/models/rwkv/modeling_rwkv.py. """ # noqa from typing import Li...
3,038
30.329897
140
py
espnet
espnet-master/espnet2/asr_transducer/decoder/modules/rwkv/attention.py
"""Attention (time mixing) modules for RWKV block. Based/Modified from https://github.com/BlinkDL/RWKV-LM/blob/main/RWKV-v4/src/model.py. Some variables are renamed according to https://github.com/huggingface/transformers/blob/main/src/transformers/models/rwkv/modeling_rwkv.py. """ # noqa import math from importli...
11,396
29.886179
140
py
espnet
espnet-master/espnet2/asr_transducer/decoder/blocks/rwkv.py
"""Receptance Weighted Key Value (RWKV) block definition. Based/modified from https://github.com/BlinkDL/RWKV-LM/blob/main/RWKV-v4/src/model.py """ from typing import Dict, Optional, Tuple import torch from espnet2.asr_transducer.decoder.modules.rwkv.attention import SelfAttention from espnet2.asr_transducer.decod...
2,602
30.743902
85
py
espnet
espnet-master/espnet2/asr_transducer/decoder/blocks/mega.py
"""Moving Average Equipped Gated Attention (MEGA) block definition. Based/modified from https://github.com/facebookresearch/mega/blob/main/fairseq/modules/moving_average_gated_attention.py Most variables are renamed according to https://github.com/huggingface/transformers/blob/main/src/transformers/models/mega/modeli...
9,571
32.704225
140
py
espnet
espnet-master/espnet2/schedulers/noam_lr.py
"""Noam learning rate scheduler module.""" import warnings from typing import Union import torch from torch.optim.lr_scheduler import _LRScheduler from typeguard import check_argument_types from espnet2.schedulers.abs_scheduler import AbsBatchStepScheduler class NoamLR(_LRScheduler, AbsBatchStepScheduler): """T...
2,068
30.348485
85
py
espnet
espnet-master/espnet2/schedulers/abs_scheduler.py
from abc import ABC, abstractmethod import torch.optim.lr_scheduler as L class AbsScheduler(ABC): @abstractmethod def step(self, epoch: int = None): pass @abstractmethod def state_dict(self): pass @abstractmethod def load_state_dict(self, state): pass # If you need...
1,664
18.821429
70
py
espnet
espnet-master/espnet2/schedulers/warmup_reducelronplateau.py
"""ReduceLROnPlateau (with Warm up) learning rate scheduler module.""" from typing import Union import torch from torch import inf from typeguard import check_argument_types from espnet2.schedulers.abs_scheduler import ( AbsBatchStepScheduler, AbsValEpochStepScheduler, ) class WarmupReduceLROnPlateau(AbsBat...
6,832
32.826733
88
py
espnet
espnet-master/espnet2/schedulers/warmup_lr.py
"""Warm up learning rate scheduler module.""" from typing import Union import torch from torch.optim.lr_scheduler import _LRScheduler from typeguard import check_argument_types from espnet2.schedulers.abs_scheduler import AbsBatchStepScheduler class WarmupLR(_LRScheduler, AbsBatchStepScheduler): """The WarmupLR...
1,495
28.333333
86
py
espnet
espnet-master/espnet2/schedulers/warmup_step_lr.py
"""Step (with Warm up) learning rate scheduler module.""" from typing import Union import torch from torch.optim.lr_scheduler import _LRScheduler from typeguard import check_argument_types from espnet2.schedulers.abs_scheduler import AbsBatchStepScheduler class WarmupStepLR(_LRScheduler, AbsBatchStepScheduler): ...
2,699
31.53012
88
py
espnet
espnet-master/espnet2/utils/sized_dict.py
import collections import sys from torch import multiprocessing def get_size(obj, seen=None): """Recursively finds size of objects Taken from https://github.com/bosswissam/pysize """ size = sys.getsizeof(obj) if seen is None: seen = set() obj_id = id(obj) if obj_id in seen: ...
2,027
25.684211
86
py
espnet
espnet-master/espnet2/utils/griffin_lim.py
#!/usr/bin/env python3 """Griffin-Lim related modules.""" # Copyright 2019 Tomoki Hayashi # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) import logging from functools import partial from typing import Optional import librosa import numpy as np import torch from packaging.version import parse as V from ...
5,607
28.208333
86
py
espnet
espnet-master/espnet2/tasks/enh_tse.py
import argparse from typing import Callable, Collection, Dict, List, Optional, Tuple import numpy as np import torch from typeguard import check_argument_types, check_return_type from espnet2.enh.espnet_model_tse import ESPnetExtractionModel from espnet2.enh.extractor.abs_extractor import AbsExtractor from espnet2.en...
11,924
33.665698
86
py
espnet
espnet-master/espnet2/tasks/enh_s2t.py
import argparse import copy import logging from typing import Callable, Collection, Dict, List, Optional, Tuple import numpy as np import torch from typeguard import check_argument_types, check_return_type from espnet2.asr.ctc import CTC from espnet2.asr.espnet_model import ESPnetASRModel from espnet2.diar.espnet_mod...
19,866
34.225177
88
py
espnet
espnet-master/espnet2/tasks/slu.py
import argparse import logging from typing import Callable, Dict, Optional, Tuple import numpy as np from typeguard import check_argument_types, check_return_type from espnet2.asr.ctc import CTC from espnet2.asr.decoder.abs_decoder import AbsDecoder from espnet2.asr.decoder.mlm_decoder import MLMDecoder from espnet2....
20,979
34.260504
85
py
espnet
espnet-master/espnet2/tasks/st.py
import argparse import logging from typing import Callable, Collection, Dict, List, Optional, Tuple import numpy as np import torch from typeguard import check_argument_types, check_return_type from espnet2.asr.ctc import CTC from espnet2.asr.decoder.abs_decoder import AbsDecoder from espnet2.asr.decoder.rnn_decoder ...
20,374
34.068847
85
py
espnet
espnet-master/espnet2/tasks/hubert.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 argparse impor...
14,204
32.266979
85
py
espnet
espnet-master/espnet2/tasks/svs.py
"""Singing-voice-synthesis task.""" import argparse import logging from pathlib import Path from typing import Callable, Collection, Dict, List, Optional, Tuple, Union import numpy as np import torch import yaml from typeguard import check_argument_types, check_return_type from espnet2.gan_svs.joint import JointScor...
17,151
34.219713
87
py
espnet
espnet-master/espnet2/tasks/diar.py
import argparse from typing import Callable, Collection, Dict, List, Optional, Tuple import numpy as np import torch from typeguard import check_argument_types, check_return_type from espnet2.asr.encoder.abs_encoder import AbsEncoder from espnet2.asr.encoder.conformer_encoder import ConformerEncoder from espnet2.asr....
9,963
31.993377
87
py
espnet
espnet-master/espnet2/tasks/mt.py
import argparse import logging from typing import Callable, Collection, Dict, List, Optional, Tuple import numpy as np import torch from typeguard import check_argument_types, check_return_type from espnet2.asr.ctc import CTC from espnet2.asr.decoder.abs_decoder import AbsDecoder from espnet2.asr.decoder.rnn_decoder ...
15,892
33.85307
86
py
espnet
espnet-master/espnet2/tasks/asr_transducer.py
"""ASR Transducer Task.""" import argparse import logging import os from typing import Callable, Collection, Dict, List, Optional, Tuple import numpy as np import torch from typeguard import check_argument_types, check_return_type from espnet2.asr.frontend.abs_frontend import AbsFrontend from espnet2.asr.frontend.de...
13,389
29.501139
83
py
espnet
espnet-master/espnet2/tasks/gan_svs.py
# Copyright 2021 Tomoki Hayashi # Copyright 2022 Yifeng Yu # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """GAN-based Singing-voice-synthesis task.""" import argparse import logging from typing import Callable, Collection, Dict, List, Optional, Tuple import numpy as np import torch from typeguard impor...
15,786
32.305907
87
py
espnet
espnet-master/espnet2/tasks/asvspoof.py
import argparse import logging from typing import Callable, Collection, Dict, List, Optional, Tuple import numpy as np import torch from typeguard import check_argument_types, check_return_type from espnet2.asr.encoder.abs_encoder import AbsEncoder # TODO1 (checkpoint 2): import conformer class class from espnet2.as...
10,200
31.487261
83
py
espnet
espnet-master/espnet2/tasks/asr.py
import argparse import logging from typing import Callable, Collection, Dict, List, Optional, Tuple import numpy as np import torch from typeguard import check_argument_types, check_return_type from espnet2.asr.ctc import CTC from espnet2.asr.decoder.abs_decoder import AbsDecoder from espnet2.asr.decoder.hugging_face...
21,301
33.693811
85
py
espnet
espnet-master/espnet2/tasks/lm.py
import argparse import logging from typing import Callable, Collection, Dict, List, Optional, Tuple import numpy as np import torch from typeguard import check_argument_types, check_return_type from espnet2.lm.abs_model import AbsLM from espnet2.lm.espnet_model import ESPnetLanguageModel from espnet2.lm.seq_rnn_lm im...
6,804
31.716346
84
py
espnet
espnet-master/espnet2/tasks/uasr.py
import argparse import logging from typing import Callable, Collection, Dict, List, Optional, Tuple import numpy as np import torch from typeguard import check_argument_types, check_return_type from espnet2.asr.frontend.abs_frontend import AbsFrontend from espnet2.asr.frontend.default import DefaultFrontend from espn...
15,031
33.796296
87
py
espnet
espnet-master/espnet2/tasks/tts.py
"""Text-to-speech task.""" import argparse import logging from pathlib import Path from typing import Callable, Collection, Dict, List, Optional, Tuple, Union import numpy as np import torch import yaml from typeguard import check_argument_types, check_return_type from espnet2.gan_tts.jets import JETS from espnet2.g...
14,328
33.94878
87
py
espnet
espnet-master/espnet2/tasks/enh.py
import argparse import copy import os from typing import Callable, Collection, Dict, List, Optional, Tuple import numpy as np import torch from typeguard import check_argument_types, check_return_type from espnet2.diar.layers.abs_mask import AbsMask from espnet2.diar.layers.multi_mask import MultiMask from espnet2.di...
18,429
34.717054
88
py
espnet
espnet-master/espnet2/tasks/gan_tts.py
# Copyright 2021 Tomoki Hayashi # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """GAN-based text-to-speech task.""" import argparse import logging from typing import Callable, Collection, Dict, List, Optional, Tuple import numpy as np import torch from typeguard import check_argument_types, check_return...
13,798
31.854762
87
py
espnet
espnet-master/espnet2/tasks/abs_task.py
"""Abstract task module.""" import argparse import functools import logging import os import sys from abc import ABC, abstractmethod from dataclasses import dataclass from pathlib import Path from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import humanfriendly import numpy as np import t...
71,532
36.432234
91
py
espnet
espnet-master/espnet2/asvspoof/espnet_model.py
# Copyright 2022 Jiatong Shi (Carnegie Mellon University) # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) import logging 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 pa...
6,487
33.510638
87
py
espnet
espnet-master/espnet2/asvspoof/loss/binary_loss.py
import torch from espnet2.asvspoof.loss.abs_loss import AbsASVSpoofLoss from espnet.nets.pytorch_backend.nets_utils import to_device class ASVSpoofBinaryLoss(AbsASVSpoofLoss): """Binary loss for ASV Spoofing.""" def __init__( self, weight: float = 1.0, ): super().__init__() ...
854
27.5
77
py
espnet
espnet-master/espnet2/asvspoof/loss/abs_loss.py
from abc import ABC, abstractmethod import torch EPS = torch.finfo(torch.get_default_dtype()).eps class AbsASVSpoofLoss(torch.nn.Module, ABC): """Base class for all ASV Spoofing loss modules.""" # the name will be the key that appears in the reporter @property def name(self) -> str: return ...
646
19.870968
59
py
espnet
espnet-master/espnet2/asvspoof/loss/am_softmax_loss.py
import torch from espnet2.asvspoof.loss.abs_loss import AbsASVSpoofLoss from espnet.nets.pytorch_backend.nets_utils import to_device class ASVSpoofAMSoftmaxLoss(AbsASVSpoofLoss): """Binary loss for ASV Spoofing.""" def __init__( self, weight: float = 1.0, enc_dim: int = 128, ...
2,180
33.619048
83
py
espnet
espnet-master/espnet2/asvspoof/loss/oc_softmax_loss.py
import torch from espnet2.asvspoof.loss.abs_loss import AbsASVSpoofLoss from espnet.nets.pytorch_backend.nets_utils import to_device class ASVSpoofOCSoftmaxLoss(AbsASVSpoofLoss): """Binary loss for ASV Spoofing.""" def __init__( self, weight: float = 1.0, enc_dim: int = 128, ...
1,850
31.473684
81
py
espnet
espnet-master/espnet2/asvspoof/decoder/linear_decoder.py
from typing import Optional import torch from espnet2.asvspoof.decoder.abs_decoder import AbsDecoder class LinearDecoder(AbsDecoder): """Linear decoder for speaker diarization""" def __init__( self, encoder_output_size: int, ): super().__init__() # TODO1 (checkpoint3): i...
805
25.866667
74
py
espnet
espnet-master/espnet2/asvspoof/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
304
19.333333
43
py
espnet
espnet-master/utils/generate_wav_from_fbank.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """This code is based on https://github.com/kan-bayashi/PytorchWaveNetVocoder.""" # Copyright 2019 Nagoya University (Tomoki Hayashi) # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) import argparse import logging import os import time import h5py import num...
5,966
30.571429
87
py
espnet
espnet-master/utils/average_checkpoints.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import argparse import json import os import numpy as np def main(): if args.log is not None: with open(args.log) as f: logs = json.load(f) val_scores = [] for log in logs: if log["epoch"] > args.max_epoch: ...
4,882
34.384058
88
py
espnet
espnet-master/egs/wsj/asr1/local/filtering_samples.py
#!/usr/bin/env python3 # Copyright 2020 Shanghai Jiao Tong University (Wangyou Zhang) # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) import json import sys from functools import reduce from operator import mul from espnet.bin.asr_train import get_parser from espnet.nets.pytorch_backend.nets_utils impor...
2,983
33.298851
86
py
espnet
espnet-master/doc/conf.py
# -*- coding: utf-8 -*- # flake8: noqa # # ESPnet documentation build configuration file, created by # sphinx-quickstart on Thu Dec 7 15:46:00 2017. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerat...
6,528
28.677273
86
py
espnet
espnet-master/egs2/TEMPLATE/asr1/pyscripts/feats/feats_cluster_faiss.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # Dongji Gao (2022) # # Adapted from fairseq/examples/wav2vec/unsupervised/\ # scripts/wav2vec_cluster_faiss.py # to fit the scp data format # This source code is licensed under the MIT license in # https...
4,160
26.019481
86
py
espnet
espnet-master/egs2/TEMPLATE/asr1/pyscripts/feats/merge_clusters.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # Dongji Gao (2022) # # Adapted from fairseq/examples/wav2vec/unsupervised/\ # scripts/merge_clusters.py # to fit the scp data format # This source code is licensed under the MIT license in # https://gith...
3,325
28.433628
87
py
espnet
espnet-master/egs2/TEMPLATE/asr1/pyscripts/feats/ssl_feature_utils.py
import json import logging import os import re import sys from typing import Optional, Union import numpy as np import soundfile as sf import torch import torchaudio from espnet2.asr.frontend.s3prl import S3prlFrontend from espnet.utils.cli_readers import file_reader_helper from espnet.utils.cli_utils import is_scipy...
7,609
30.97479
84
py
espnet
espnet-master/egs2/TEMPLATE/asr1/pyscripts/feats/dump_km_label.py
# The learn_kmeans.py uses code from Fairseq: # https://github.com/pytorch/fairseq/blob/master/examples/hubert/simple_kmeans/dump_km_label.py # # 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 # C...
5,471
30.448276
99
py
espnet
espnet-master/egs2/TEMPLATE/asr1/pyscripts/feats/mean_pool_scp.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # Dongji Gao (2022) # # Adapted from fairseq/examples/wav2vec/unsupervised/\ # scripts/mean_pool.py # to fit the scp data format # This source code is licensed under the MIT license in # https://github.co...
3,406
30.841121
86
py
espnet
espnet-master/egs2/TEMPLATE/asr1/pyscripts/feats/apply_pca.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # Adapted from fairseq/examples/wav2vec/unsupervised/scripts/apply_pca.py # to fit the scp data format # This source code is licensed under the MIT license in # https://github.com/facebookresearch/fairseq import argparse import math...
2,291
28.384615
87
py
espnet
espnet-master/egs2/TEMPLATE/asr1/pyscripts/feats/feats_apply_cluster_faiss.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # Dongji Gao (2022) # # Adapted from fairseq/examples/wav2vec/unsupervised/\ # scripts/wav2vec_apply_cluster_faiss.py # to fit the scp data format # This source code is licensed under the MIT license in #...
4,575
28.522581
84
py
espnet
espnet-master/egs2/TEMPLATE/asr1/pyscripts/k2/compile_hlg.py
#!/usr/bin/env python3 # Copyright 2021 Xiaomi Corp. (authors: Fangjun Kuang) # 2022 Johns Hopkins University (author: Dongji Gao) # # This script is adapted from \ # k2-fsa/icefall/blob/master/egs/librispeech/ASR/local/compile_hlg.py # # See https://github.com/k2-fsa/icefall/blob/master/LIC...
4,986
26.860335
81
py
espnet
espnet-master/egs2/TEMPLATE/asr1/pyscripts/k2/prepare_lang.py
#!/usrilbin/env python3 # Copyright 2021 Xiaomi Corp. (authors: Fangjun Kuang) # 2022 Johns Hopkins University (author: Dongji Gao) # # This script is adapted from \ # k2-fsa/icefall/blob/master/egs/librispeech/ASR/local/prepare_lang.py # # See https://github.com/k2-fsa/icefall/blob/master/L...
14,465
28.704312
81
py
espnet
espnet-master/egs2/TEMPLATE/asr1/pyscripts/utils/evaluate_cfsd.py
#!/usr/bin/env python3 # Copyright 2020 Wen-Chin Huang and Tomoki Hayashi # Copyright 2023 Dan Lim # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Evaluate Conditional Frechet Speech Distance between generated and groundtruth audios using the s3prl pretrained models.""" import argparse import ...
9,455
32.892473
88
py
espnet
espnet-master/egs2/TEMPLATE/asr1/pyscripts/utils/evaluate_secs.py
#!/usr/bin/env python3 # Copyright 2020 Wen-Chin Huang and Tomoki Hayashi # Copyright 2023 Dan Lim # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Evaluate Speaker Embedding Cosine Similarity between generated and groundtruth audios using X-vector of the speechbrain pretrained models""" import...
7,171
31.6
88
py
espnet
espnet-master/egs2/TEMPLATE/asr1/pyscripts/utils/extract_xvectors.py
#!/usr/bin/env python3 # 2022, Hitachi LTD.; Nelson Yalta # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) import argparse import logging import os import sys from pathlib import Path import kaldiio import librosa import numpy as np import torch from tqdm.contrib import tqdm from espnet2.fileio.sound_scp...
6,207
32.923497
88
py
espnet
espnet-master/egs2/TEMPLATE/asr1/pyscripts/utils/sklearn_km.py
# The sklearn_km.py uses code from Fairseq: # https://github.com/pytorch/fairseq/blob/master/examples/hubert/simple_kmeans/learn_kmeans.py # # 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...
6,389
27.526786
98
py
espnet
espnet-master/egs2/TEMPLATE/asr1/pyscripts/utils/evaluate_whisper_inference.py
#!/usr/bin/env python3 import argparse import logging import os 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 import whisper from typeguard import check_argument_typ...
4,560
25.829412
82
py
espnet
espnet-master/egs2/TEMPLATE/asr1/pyscripts/utils/plot_sinc_filters.py
#!/usr/bin/env python3 # 2020, Technische Universität München; Nicolas Lindae, Ludwig Kürzinger # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Visualize Sinc convolution filters. Description: This program loads a pretrained Sinc convolution of an ESPnet2 ASR model and plots filters, as well a...
11,828
32.041899
88
py
espnet
espnet-master/egs2/TEMPLATE/asr1/pyscripts/utils/learn_kmeans.py
# The learn_kmeans.py uses code from Fairseq: # https://github.com/pytorch/fairseq/blob/master/examples/hubert/simple_kmeans/learn_kmeans.py # # 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 # Co...
4,472
25.945783
98
py
espnet
espnet-master/egs2/TEMPLATE/asr1/pyscripts/utils/calculate_speech_metrics.py
#!/usr/bin/env python3 import argparse import logging import sys from typing import 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.encoder.stft_encoder import STFTEncoder from espnet2.enh....
7,320
32.582569
87
py
espnet
espnet-master/egs2/TEMPLATE/asr1/steps/libs/nnet3/xconfig/convolution.py
# Copyright 2018 Johns Hopkins University (Author: Dan Povey) # 2016 Vijayaditya Peddinti # Apache 2.0. """ This module has the implementation of convolutional layers. """ from __future__ import print_function from __future__ import division import math import re import sys from libs.nnet3.xconfig.ba...
61,163
49.800664
107
py
espnet
espnet-master/egs2/lrs2/lipreading1/local/feature_extract/video_processing.py
import cvtransforms import face_alignment import numpy as np import skimage.transform import skvideo.io import torch from models import pretrained def reload_model(model, path=""): if not bool(path): return model else: model_dict = model.state_dict() pretrained_dict = torch.load(path, ...
6,492
29.483568
88
py
espnet
espnet-master/egs2/lrs2/lipreading1/local/feature_extract/models/pretrained.py
# coding: utf-8 import math import numpy as np import torch import torch.nn as nn from torch.autograd import Variable def conv3x3(in_planes, out_planes, stride=1): return nn.Conv2d( in_planes, out_planes, kernel_size=3, stride=stride, padding=1, bias=False ) class BasicBlock(nn.Module): expansi...
8,286
31.498039
88
py
espnet
espnet-master/egs2/wsj0_2mix/tse1/local/prepare_spk_embs_scp.py
from functools import partial from pathlib import Path import numpy as np import onnxruntime as ort import torch import torchaudio import torchaudio.compliance.kaldi as kaldi from tqdm.contrib.concurrent import thread_map def compute_fbank( wav_path, num_mel_bins=80, frame_length=25, frame_shift=10, dither=0.0 )...
2,982
27.961165
88
py
espnet
espnet-master/egs2/l3das22/enh1/local/metric.py
# The implementation of the metric for L3DAS22 in # Guizzo. et al. "L3DAS22 Challenge: Learning 3D Audio # Sources in a Real Office Environment" # The code is based on: # https://github.com/l3das/L3DAS22/blob/main/metrics.py import argparse import os import sys import warnings import jiwer import numpy as np import ...
4,378
31.198529
87
py
espnet
espnet-master/egs2/librispeech/ssl1/local/measure_teacher_quality.py
# The measure_teacher_quality.py uses code from Fairseq: # https://github.com/pytorch/fairseq/blob/master/examples/hubert/measure_teacher_quality.py # # 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 ...
6,713
26.292683
95
py
espnet
espnet-master/egs2/slurp_spatialized/asr1/local/multi_to_single.py
import os import sys from multiprocessing import Pool from pathlib import Path import torchaudio import tqdm multi_path = sys.argv[1] single_path = sys.argv[2] data_list = ["tr_real", "tr_synthetic", "cv", "tt", "tt_qut"] def m2s(pf): if ".wav" not in pf[2]: return mwav = os.path.join(pf[0], pf[2])...
1,386
26.74
83
py
espnet
espnet-master/egs2/chime7_task1/diar_asr1/local/pyannote_diarize.py
import argparse import glob import json import math import os.path import re from pathlib import Path import numpy as np import soundfile as sf import torch from pyannote.audio import Model, Pipeline from pyannote.audio.core.inference import Inference from pyannote.audio.pipelines import SpeakerDiarization from pyanno...
14,818
32.603175
87
py
espnet
espnet-master/egs2/chime7_task1/diar_asr1/local/pyannote_finetune.py
import argparse import os.path import shutil from pathlib import Path from types import MethodType from pyannote.audio import Inference, Model from pyannote.audio.tasks import Segmentation from pyannote.database import FileFinder, get_protocol from pytorch_lightning import Trainer from pytorch_lightning.callbacks impo...
5,429
27.429319
87
py
espnet
espnet-master/egs2/chime7_task1/asr1/local/gss_micrank.py
import argparse import os from copy import deepcopy from pathlib import Path import lhotse import soundfile as sf import torch import torchaudio import tqdm from torch.utils.data import DataLoader, Dataset class EnvelopeVariance(torch.nn.Module): """ Envelope Variance Channel Selection method with (optio...
8,190
33.707627
87
py
palbert
palbert-main/src/test.py
import argparse import logging import os import torch import transformers as t from tqdm import tqdm, trange from dataset import get_test_dataloaders, task_to_keys from modeling.palbert_fast import (AlbertPABEEForSequenceClassification, PAlbertForSequenceClassification) from trainer...
6,993
33.97
104
py
palbert
palbert-main/src/loss.py
import torch from torch.nn import functional as F class RegularizationLoss(torch.nn.Module): def __init__(self, lambda_p: float, max_steps: int = 12, prior_type="geometric"): super().__init__() p_g = torch.zeros((max_steps,)) if prior_type == "geometric": not_halted = 1.0 ...
1,922
34.611111
85
py
palbert
palbert-main/src/dataset.py
import datasets from torch.utils.data import DataLoader task_to_keys = { "cola": ("sentence", None), "mnli": ("premise", "hypothesis"), "mrpc": ("sentence1", "sentence2"), "qnli": ("question", "sentence"), "qqp": ("question1", "question2"), "rte": ("sentence1", "sentence2"), "sst2": ("sente...
5,500
34.262821
87
py
palbert
palbert-main/src/train.py
import argparse import logging import os.path from collections import defaultdict from itertools import chain import numpy as np import torch import transformers as t import wandb from datasets import load_metric from torch.optim import Adam from transformers import AutoConfig, AutoModelForSequenceClassification from...
14,261
35.757732
92
py
palbert
palbert-main/src/trainer.py
# coding=utf-8 # Copyright 2022 Tinkoff. # # 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 applicable law or agreed to ...
15,261
37.155
95
py