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
speechbrain
speechbrain-main/speechbrain/dataio/sampler.py
"""PyTorch compatible samplers. These determine the order of iteration through a dataset. Authors: * Aku Rouhe 2020 * Samuele Cornell 2020 * Ralf Leibold 2020 * Artem Ploujnikov 2021 * Andreas Nautsch 2021 """ import torch import logging from operator import itemgetter from torch.utils.data import ( Ran...
32,036
38.212974
132
py
speechbrain
speechbrain-main/speechbrain/dataio/batch.py
"""Batch collation Authors * Aku Rouhe 2020 """ import collections import torch from speechbrain.utils.data_utils import mod_default_collate from speechbrain.utils.data_utils import recursive_to from speechbrain.utils.data_utils import batch_pad_right from torch.utils.data._utils.collate import default_convert from ...
9,022
32.172794
91
py
speechbrain
speechbrain-main/speechbrain/dataio/dataloader.py
"""PyTorch compatible DataLoaders Essentially we extend PyTorch DataLoader by adding the ability to save the data loading state, so that a checkpoint may be saved in the middle of an epoch. Example ------- >>> import torch >>> from speechbrain.utils.checkpoints import Checkpointer >>> # An example "dataset" and its l...
13,097
36.637931
86
py
speechbrain
speechbrain-main/speechbrain/dataio/encoder.py
"""Encoding categorical data as integers Authors * Samuele Cornell 2020 * Aku Rouhe 2020 """ import ast import torch import collections import itertools import logging import speechbrain as sb from speechbrain.utils.checkpoints import ( mark_as_saver, mark_as_loader, register_checkpoint_hooks, ) logge...
39,147
34.718978
93
py
speechbrain
speechbrain-main/speechbrain/dataio/dataset.py
"""Dataset examples for loading individual data points Authors * Aku Rouhe 2020 * Samuele Cornell 2020 """ import copy import contextlib from types import MethodType from torch.utils.data import Dataset from speechbrain.utils.data_pipeline import DataPipeline from speechbrain.dataio.dataio import load_data_json, ...
15,593
36.30622
87
py
speechbrain
speechbrain-main/speechbrain/dataio/preprocess.py
"""Preprocessors for audio""" import torch import functools from speechbrain.processing.speech_augmentation import Resample class AudioNormalizer: """Normalizes audio into a standard format Arguments --------- sample_rate : int The sampling rate to which the incoming signals should be convert...
2,293
32.735294
87
py
speechbrain
speechbrain-main/speechbrain/alignment/ctc_segmentation.py
#!/usr/bin/env python3 # 2021, Technische Universität München, Ludwig Kürzinger """Perform CTC segmentation to align utterances within audio files. This uses the ctc-segmentation Python package. Install it with pip or see the installing instructions in https://github.com/lumaku/ctc-segmentation """ import logging fro...
26,318
38.577444
84
py
speechbrain
speechbrain-main/speechbrain/alignment/aligner.py
""" Alignment code Authors * Elena Rastorgueva 2020 * Loren Lugosch 2020 """ import torch import random from speechbrain.utils.checkpoints import register_checkpoint_hooks from speechbrain.utils.checkpoints import mark_as_saver from speechbrain.utils.checkpoints import mark_as_loader from speechbrain.utils.data_util...
52,837
34.944218
96
py
speechbrain
speechbrain-main/speechbrain/utils/edit_distance.py
"""Edit distance and WER computation. Authors * Aku Rouhe 2020 * Salima Mdhaffar 2021 """ import collections EDIT_SYMBOLS = { "eq": "=", # when tokens are equal "ins": "I", "del": "D", "sub": "S", } # NOTE: There is a danger in using mutables as default arguments, as they are # only initialized ...
25,986
33.788487
80
py
speechbrain
speechbrain-main/speechbrain/utils/checkpoints.py
"""This module implements a checkpoint saver and loader. A checkpoint in an experiment usually needs to save the state of many different things: the model parameters, optimizer parameters, what epoch is this, etc. The save format for a checkpoint is a directory, where each of these separate saveable things gets its ow...
45,420
36.850833
88
py
speechbrain
speechbrain-main/speechbrain/utils/profiling.py
"""Polymorphic decorators to handle PyTorch profiling and benchmarking. Author: * Andreas Nautsch 2022 """ import numpy as np from copy import deepcopy from torch import profiler from functools import wraps from typing import Any, Callable, Iterable, Optional # from typing import List # from itertools import chai...
25,566
36.653903
120
py
speechbrain
speechbrain-main/speechbrain/utils/data_utils.py
"""This library gathers utilities for data io operation. Authors * Mirco Ravanelli 2020 * Aku Rouhe 2020 * Samuele Cornell 2020 """ import os import re import csv import shutil import urllib.request import collections.abc import torch import tqdm import pathlib import speechbrain as sb def undo_padding(batch, le...
17,403
28.90378
123
py
speechbrain
speechbrain-main/speechbrain/utils/logger.py
"""Managing the logger, utilities Author * Fang-Pen Lin 2012 https://fangpenlin.com/posts/2012/08/26/good-logging-practice-in-python/ * Peter Plantinga 2020 * Aku Rouhe 2020 """ import sys import os import yaml import tqdm import logging import logging.config import math import torch from speechbrain.utils.data_ut...
5,525
27.050761
93
py
speechbrain
speechbrain-main/speechbrain/utils/_workarounds.py
"""This module implements some workarounds for dependencies Authors * Aku Rouhe 2022 """ import torch import weakref import warnings WEAKREF_MARKER = "WEAKREF" def _cycliclrsaver(obj, path): state_dict = obj.state_dict() if state_dict.get("_scale_fn_ref") is not None: state_dict["_scale_fn_ref"] = ...
1,188
33.970588
95
py
speechbrain
speechbrain-main/speechbrain/utils/metric_stats.py
"""The ``metric_stats`` module provides an abstract class for storing statistics produced over the course of an experiment and summarizing them. Authors: * Peter Plantinga 2020 * Mirco Ravanelli 2020 * Gaelle Laperriere 2021 * Sahar Ghannay 2021 """ import torch from joblib import Parallel, delayed from speechbra...
31,718
33.069817
109
py
speechbrain
speechbrain-main/speechbrain/utils/distributed.py
"""Guard for running certain operations on main process only Authors: * Abdel Heba 2020 * Aku Rouhe 2020 """ import os import torch import logging logger = logging.getLogger(__name__) def run_on_main( func, args=None, kwargs=None, post_func=None, post_args=None, post_kwargs=None, run_p...
6,388
33.349462
80
py
speechbrain
speechbrain-main/speechbrain/utils/bleu.py
"""Library for computing the BLEU score Authors * Mirco Ravanelli 2021 """ from speechbrain.utils.metric_stats import MetricStats def merge_words(sequences): """Merge successive words into phrase, putting space between each word Arguments --------- sequences : list Each item contains a lis...
3,943
28
112
py
speechbrain
speechbrain-main/speechbrain/utils/Accuracy.py
"""Calculate accuracy. Authors * Jianyuan Zhong 2020 """ import torch from speechbrain.dataio.dataio import length_to_mask def Accuracy(log_probabilities, targets, length=None): """Calculates the accuracy for predicted log probabilities and targets in a batch. Arguments ---------- log_probabilities ...
2,584
29.05814
99
py
speechbrain
speechbrain-main/speechbrain/utils/torch_audio_backend.py
"""Library for checking the torchaudio backend. Authors * Mirco Ravanelli 2021 """ import platform import logging import torchaudio logger = logging.getLogger(__name__) def check_torchaudio_backend(): """Checks the torchaudio backend and sets it to soundfile if windows is detected. """ current_syst...
573
23.956522
112
py
speechbrain
speechbrain-main/speechbrain/utils/train_logger.py
"""Loggers for experiment monitoring. Authors * Peter Plantinga 2020 """ import logging import ruamel.yaml import torch import os logger = logging.getLogger(__name__) class TrainLogger: """Abstract class defining an interface for training loggers.""" def log_stats( self, stats_meta, ...
13,898
30.445701
168
py
speechbrain
speechbrain-main/speechbrain/processing/NMF.py
"""Non-negative matrix factorization Authors * Cem Subakan """ import torch from speechbrain.processing.features import spectral_magnitude import speechbrain.processing.features as spf def spectral_phase(stft, power=2, log=False): """Returns the phase of a complex spectrogram. Arguments --------- s...
5,770
29.373684
103
py
speechbrain
speechbrain-main/speechbrain/processing/features.py
"""Low-level feature pipeline components This library gathers functions that compute popular speech features over batches of data. All the classes are of type nn.Module. This gives the possibility to have end-to-end differentiability and to backpropagate the gradient through them. Our functions are a modified versio...
39,570
31.435246
81
py
speechbrain
speechbrain-main/speechbrain/processing/speech_augmentation.py
"""Classes for mutating speech data for data augmentation. This module provides classes that produce realistic distortions of speech data for the purpose of training speech processing models. The list of distortions includes adding noise, adding reverberation, changing speed, and more. All the classes are of type `tor...
44,293
34.982128
81
py
speechbrain
speechbrain-main/speechbrain/processing/signal_processing.py
""" Low level signal processing utilities Authors * Peter Plantinga 2020 * Francois Grondin 2020 * William Aris 2020 * Samuele Cornell 2020 * Sarthak Yadav 2022 """ import torch import math from packaging import version def compute_amplitude(waveforms, lengths=None, amp_type="avg", scale="linear"): """Compu...
20,913
32.677939
123
py
speechbrain
speechbrain-main/speechbrain/processing/multi_mic.py
"""Multi-microphone components. This library contains functions for multi-microphone signal processing. Example ------- >>> import torch >>> >>> from speechbrain.dataio.dataio import read_audio >>> from speechbrain.processing.features import STFT, ISTFT >>> from speechbrain.processing.multi_mic import Covariance >>> ...
53,438
33.836375
120
py
speechbrain
speechbrain-main/speechbrain/processing/decomposition.py
""" Generalized Eigenvalue Decomposition. This library contains different methods to adjust the format of complex Hermitian matrices and find their eigenvectors and eigenvalues. Authors * William Aris 2020 * Francois Grondin 2020 """ import torch def gevd(a, b=None): """This method computes the eigenvectors ...
11,655
26.818616
92
py
speechbrain
speechbrain-main/speechbrain/lobes/features.py
"""Basic feature pipelines. Authors * Mirco Ravanelli 2020 * Peter Plantinga 2020 * Sarthak Yadav 2020 """ import torch from speechbrain.processing.features import ( STFT, spectral_magnitude, Filterbank, DCT, Deltas, ContextWindow, ) from speechbrain.nnet.CNN import GaborConv1d from speechbr...
14,790
32.615909
114
py
speechbrain
speechbrain-main/speechbrain/lobes/augment.py
""" Combinations of processing algorithms to implement common augmentations. Examples: * SpecAugment * Environmental corruption (noise, reverberation) Authors * Peter Plantinga 2020 * Jianyuan Zhong 2020 """ import os import torch import torchaudio import speechbrain as sb from speechbrain.utils.data_utils import...
18,577
32.473874
102
py
speechbrain
speechbrain-main/speechbrain/lobes/downsampling.py
""" Combinations of processing algorithms to implement downsampling methods. Authors * Salah Zaiem """ import torch import torchaudio.transforms as T from speechbrain.nnet.CNN import Conv1d from speechbrain.nnet.pooling import Pooling1d class Downsampler(torch.nn.Module): """ Wrapper for downsampling techniques...
3,444
26.782258
80
py
speechbrain
speechbrain-main/speechbrain/lobes/beamform_multimic.py
"""Beamformer for multi-mic processing. Authors * Nauman Dawalatabad """ import torch from speechbrain.processing.features import ( STFT, ISTFT, ) from speechbrain.processing.multi_mic import ( Covariance, GccPhat, DelaySum, ) class DelaySum_Beamformer(torch.nn.Module): """Generate beamform...
1,264
22.425926
81
py
speechbrain
speechbrain-main/speechbrain/lobes/models/wav2vec.py
"""Components necessary to build a wav2vec 2.0 architecture following the original paper: https://arxiv.org/abs/2006.11477. Authors * Rudolf A Braun 2022 * Guillermo Cambara 2022 * Titouan Parcollet 2022 """ import logging import torch import torch.nn.functional as F import torch.nn as nn import random import numpy a...
12,989
32.916449
98
py
speechbrain
speechbrain-main/speechbrain/lobes/models/conv_tasnet.py
""" Implementation of a popular speech separation model. """ import torch import torch.nn as nn import speechbrain as sb import torch.nn.functional as F from speechbrain.processing.signal_processing import overlap_and_add EPS = 1e-8 class Encoder(nn.Module): """This class learns the adaptive frontend for the Co...
16,379
25.721044
88
py
speechbrain
speechbrain-main/speechbrain/lobes/models/MetricGAN.py
"""Generator and discriminator used in MetricGAN Authors: * Szu-Wei Fu 2020 """ import torch import speechbrain as sb from torch import nn from torch.nn.utils import spectral_norm def xavier_init_layer( in_size, out_size=None, spec_norm=True, layer_type=nn.Linear, **kwargs ): "Create a layer with spectral no...
5,148
26.832432
81
py
speechbrain
speechbrain-main/speechbrain/lobes/models/MetricGAN_U.py
"""Generator and discriminator used in MetricGAN-U Authors: * Szu-Wei Fu 2020 """ import torch import speechbrain as sb from torch import nn from torch.nn.utils import spectral_norm def xavier_init_layer( in_size, out_size=None, spec_norm=True, layer_type=nn.Linear, **kwargs ): "Create a layer with spectral ...
5,154
25.989529
81
py
speechbrain
speechbrain-main/speechbrain/lobes/models/Tacotron2.py
""" Neural network modules for the Tacotron2 end-to-end neural Text-to-Speech (TTS) model Authors * Georges Abous-Rjeili 2021 * Artem Ploujnikov 2021 """ # This code uses a significant portion of the NVidia implementation, even though it # has been modified and enhanced # https://github.com/NVIDIA/DeepLearningExampl...
59,832
30.441408
138
py
speechbrain
speechbrain-main/speechbrain/lobes/models/segan_model.py
""" This file contains two PyTorch modules which together consist of the SEGAN model architecture (based on the paper: Pascual et al. https://arxiv.org/pdf/1703.09452.pdf). Modification of the initialization parameters allows the change of the model described in the class project, such as turning the generator to a VAE...
8,123
31.496
108
py
speechbrain
speechbrain-main/speechbrain/lobes/models/L2I.py
"""This file implements the necessary classes and functions to implement Listen-to-Interpret (L2I) interpretation method from https://arxiv.org/abs/2202.11479v2 Authors * Cem Subakan 2022 * Francesco Paissan 2022 """ import torch.nn as nn import torch.nn.functional as F import torch from speechbrain.lobes.models.P...
11,147
29.376022
160
py
speechbrain
speechbrain-main/speechbrain/lobes/models/fairseq_wav2vec.py
"""This lobe enables the integration of fairseq pretrained wav2vec models. Reference: https://arxiv.org/abs/2006.11477 Reference: https://arxiv.org/abs/1904.05862 FairSeq >= 1.0.0 needs to be installed: https://fairseq.readthedocs.io/en/latest/ Authors * Titouan Parcollet 2021 * Salima Mdhaffar 2021 """ import tor...
11,652
33.785075
105
py
speechbrain
speechbrain-main/speechbrain/lobes/models/convolution.py
"""This is a module to ensemble a convolution (depthwise) encoder with or without residule connection. Authors * Jianyuan Zhong 2020 """ import torch from speechbrain.nnet.CNN import Conv2d from speechbrain.nnet.containers import Sequential from speechbrain.nnet.normalization import LayerNorm class ConvolutionFront...
5,520
30.369318
107
py
speechbrain
speechbrain-main/speechbrain/lobes/models/ESPnetVGG.py
"""This lobes replicate the encoder first introduced in ESPNET v1 source: https://github.com/espnet/espnet/blob/master/espnet/nets/pytorch_backend/rnn/encoders.py Authors * Titouan Parcollet 2020 """ import torch import speechbrain as sb class ESPnetVGG(sb.nnet.containers.Sequential): """This model is a combin...
3,675
29.131148
96
py
speechbrain
speechbrain-main/speechbrain/lobes/models/EnhanceResnet.py
"""Wide ResNet for Speech Enhancement. Author * Peter Plantinga 2022 """ import torch import speechbrain as sb from speechbrain.processing.features import STFT, ISTFT, spectral_magnitude class EnhanceResnet(torch.nn.Module): """Model for enhancement based on Wide ResNet. Full model description at: https://...
7,571
30.160494
95
py
speechbrain
speechbrain-main/speechbrain/lobes/models/ContextNet.py
"""The SpeechBrain implementation of ContextNet by https://arxiv.org/pdf/2005.03191.pdf Authors * Jianyuan Zhong 2020 """ import torch from torch.nn import Dropout from speechbrain.nnet.CNN import DepthwiseSeparableConv1d, Conv1d from speechbrain.nnet.linear import Linear from speechbrain.nnet.pooling import Adaptive...
9,388
30.612795
201
py
speechbrain
speechbrain-main/speechbrain/lobes/models/Xvector.py
"""A popular speaker recognition and diarization model. Authors * Nauman Dawalatabad 2020 * Mirco Ravanelli 2020 """ # import os import torch # noqa: F401 import torch.nn as nn import speechbrain as sb from speechbrain.nnet.pooling import StatisticsPooling from speechbrain.nnet.CNN import Conv1d from speechbrain.n...
6,854
28.170213
77
py
speechbrain
speechbrain-main/speechbrain/lobes/models/resepformer.py
"""Library for the Reseource-Efficient Sepformer. Authors * Cem Subakan 2022 """ import torch import torch.nn as nn from speechbrain.lobes.models.dual_path import select_norm from speechbrain.lobes.models.transformer.Transformer import ( TransformerEncoder, PositionalEncoding, get_lookahead_mask, ) impor...
21,609
29.013889
119
py
speechbrain
speechbrain-main/speechbrain/lobes/models/huggingface_wav2vec.py
"""This lobe enables the integration of huggingface pretrained wav2vec2/hubert/wavlm models. Reference: https://arxiv.org/abs/2006.11477 Reference: https://arxiv.org/abs/1904.05862 Reference: https://arxiv.org/abs/2110.13900 Transformer from HuggingFace needs to be installed: https://huggingface.co/transformers/instal...
18,749
36.055336
123
py
speechbrain
speechbrain-main/speechbrain/lobes/models/Cnn14.py
""" This file implements the CNN14 model from https://arxiv.org/abs/1912.10211 Authors * Cem Subakan 2022 * Francesco Paissan 2022 """ import torch.nn as nn import torch.nn.functional as F import torch def init_layer(layer): """Initialize a Linear or Convolutional layer.""" nn.init.xavier_uniform_(layer....
7,429
30.483051
89
py
speechbrain
speechbrain-main/speechbrain/lobes/models/ECAPA_TDNN.py
"""A popular speaker recognition and diarization model. Authors * Hwidong Na 2020 """ # import os import torch # noqa: F401 import torch.nn as nn import torch.nn.functional as F from speechbrain.dataio.dataio import length_to_mask from speechbrain.nnet.CNN import Conv1d as _Conv1d from speechbrain.nnet.normalizatio...
16,703
28.050435
83
py
speechbrain
speechbrain-main/speechbrain/lobes/models/VanillaNN.py
"""Vanilla Neural Network for simple tests. Authors * Elena Rastorgueva 2020 """ import torch import speechbrain as sb class VanillaNN(sb.nnet.containers.Sequential): """A simple vanilla Deep Neural Network. Arguments --------- activation : torch class A class used for constructing the activ...
1,178
23.5625
60
py
speechbrain
speechbrain-main/speechbrain/lobes/models/CRDNN.py
"""A combination of Convolutional, Recurrent, and Fully-connected networks. Authors * Mirco Ravanelli 2020 * Peter Plantinga 2020 * Ju-Chieh Chou 2020 * Titouan Parcollet 2020 * Abdel 2020 """ import torch import speechbrain as sb class CRDNN(sb.nnet.containers.Sequential): """This model is a combination of...
10,521
32.724359
79
py
speechbrain
speechbrain-main/speechbrain/lobes/models/HifiGAN.py
""" Neural network modules for the HiFi-GAN: Generative Adversarial Networks for Efficient and High Fidelity Speech Synthesis For more details: https://arxiv.org/pdf/2010.05646.pdf Authors * Duret Jarod 2021 * Yingzhi WANG 2022 """ # Adapted from https://github.com/jik876/hifi-gan/ and https://github.com/coqui-ai/...
37,244
28.748403
99
py
speechbrain
speechbrain-main/speechbrain/lobes/models/RNNLM.py
"""Implementation of a Recurrent Language Model. Authors * Mirco Ravanelli 2020 * Peter Plantinga 2020 * Ju-Chieh Chou 2020 * Titouan Parcollet 2020 * Abdel 2020 """ import torch from torch import nn import speechbrain as sb class RNNLM(nn.Module): """This model is a combination of embedding layer, RNN, DNN...
3,628
28.504065
79
py
speechbrain
speechbrain-main/speechbrain/lobes/models/PIQ.py
"""This file implements the necessary classes and functions to implement Posthoc Interpretations via Quantization. Authors * Cem Subakan 2023 * Francesco Paissan 2023 """ import torch import torch.nn as nn from torch.autograd import Function def get_irrelevant_regions(labels, K, num_classes, N_shared=5, stage="TR...
19,449
30.370968
273
py
speechbrain
speechbrain-main/speechbrain/lobes/models/huggingface_whisper.py
"""This lobe enables the integration of huggingface pretrained whisper model. Transformer from HuggingFace needs to be installed: https://huggingface.co/transformers/installation.html Authors * Adel Moumen 2022 * Titouan Parcollet 2022 * Luca Della Libera 2022 """ import torch import logging from torch import nn ...
12,043
35.607903
117
py
speechbrain
speechbrain-main/speechbrain/lobes/models/dual_path.py
"""Library to support dual-path speech separation. Authors * Cem Subakan 2020 * Mirco Ravanelli 2020 * Samuele Cornell 2020 * Mirko Bronzi 2020 * Jianyuan Zhong 2020 """ import math import torch import torch.nn as nn import torch.nn.functional as F import copy from speechbrain.nnet.linear import Linear from spee...
42,269
28.313454
102
py
speechbrain
speechbrain-main/speechbrain/lobes/models/g2p/dataio.py
""" Data pipeline elements for the G2P pipeline Authors * Loren Lugosch 2020 * Mirco Ravanelli 2020 * Artem Ploujnikov 2021 (minor refactoring only) """ from functools import reduce from speechbrain.wordemb.util import expand_to_chars import speechbrain as sb import torch import re RE_MULTI_SPACE = re.compile(r"\...
16,894
25.153251
84
py
speechbrain
speechbrain-main/speechbrain/lobes/models/g2p/homograph.py
"""Tools for homograph disambiguation Authors * Artem Ploujnikov 2021 """ import torch from torch import nn class SubsequenceLoss(nn.Module): """ A loss function for a specific word in the output, used in the homograph disambiguation task The approach is as follows: 1. Arrange only the target wor...
21,897
31.978916
118
py
speechbrain
speechbrain-main/speechbrain/lobes/models/g2p/model.py
"""The Attentional RNN model for Grapheme-to-Phoneme Authors * Mirco Ravinelli 2021 * Artem Ploujnikov 2021 """ from speechbrain.lobes.models.transformer.Transformer import ( TransformerInterface, get_lookahead_mask, get_key_padding_mask, ) import torch from torch import nn from speechbrain.nnet.linear...
18,054
29.293624
119
py
speechbrain
speechbrain-main/speechbrain/lobes/models/transformer/Transformer.py
"""Transformer implementaion in the SpeechBrain style. Authors * Jianyuan Zhong 2020 * Samuele Cornell 2021 """ import math import torch import torch.nn as nn import speechbrain as sb from typing import Optional import numpy as np from .Conformer import ConformerEncoder from speechbrain.nnet.activations import Swish...
27,179
30.641444
119
py
speechbrain
speechbrain-main/speechbrain/lobes/models/transformer/TransformerSE.py
"""CNN Transformer model for SE in the SpeechBrain style. Authors * Chien-Feng Liao 2020 """ import torch # noqa E402 from torch import nn from speechbrain.nnet.linear import Linear from speechbrain.lobes.models.transformer.Transformer import ( TransformerInterface, get_lookahead_mask, ) class CNNTransforme...
3,074
29.445545
92
py
speechbrain
speechbrain-main/speechbrain/lobes/models/transformer/TransformerLM.py
"""An implementation of Transformer Language model. Authors * Jianyuan Zhong * Samuele Cornell """ import torch # noqa 42 from torch import nn from speechbrain.nnet.linear import Linear from speechbrain.nnet.normalization import LayerNorm from speechbrain.nnet.containers import ModuleList from speechbrain.lobes.mo...
5,248
29.876471
108
py
speechbrain
speechbrain-main/speechbrain/lobes/models/transformer/TransformerASR.py
"""Transformer for ASR in the SpeechBrain style. Authors * Jianyuan Zhong 2020 """ import torch # noqa 42 from torch import nn from typing import Optional from speechbrain.nnet.linear import Linear from speechbrain.nnet.containers import ModuleList from speechbrain.lobes.models.transformer.Transformer import ( T...
12,371
34.348571
119
py
speechbrain
speechbrain-main/speechbrain/lobes/models/transformer/Conformer.py
"""Conformer implementation. Authors * Jianyuan Zhong 2020 * Samuele Cornell 2021 """ import torch import torch.nn as nn from typing import Optional import speechbrain as sb import warnings from speechbrain.nnet.attention import ( RelPosMHAXL, MultiheadAttention, PositionalwiseFeedForward, ) from speech...
20,245
29.127976
146
py
speechbrain
speechbrain-main/speechbrain/lobes/models/transformer/TransformerST.py
"""Transformer for ST in the SpeechBrain sytle. Authors * YAO FEI, CHENG 2021 """ import torch # noqa 42 import logging from torch import nn from typing import Optional from speechbrain.nnet.containers import ModuleList from speechbrain.lobes.models.transformer.Transformer import ( get_lookahead_mask, get_k...
13,931
34.360406
119
py
speechbrain
speechbrain-main/templates/hyperparameter_optimization_speaker_id/train.py
#!/usr/bin/env python3 """Recipe for training a speaker-id system, with hyperparameter optimization support. For a tutorial on hyperparameter optimization, refer to this tutorial: https://colab.research.google.com/drive/1b-5EOjZC7M9RvfWZ0Pq0HMV0KmQKu730#scrollTo=lJup9mNnYw_0 The template can use used as a basic exam...
13,148
35.935393
95
py
speechbrain
speechbrain-main/templates/speech_recognition/LM/custom_model.py
""" This file contains a very simple PyTorch module to use for language modeling. To replace this model, change the `!new:` tag in the hyperparameter file to refer to a built-in SpeechBrain model or another file containing a custom PyTorch module. Instead of this simple model, we suggest using one of the following bui...
2,590
27.163043
78
py
speechbrain
speechbrain-main/templates/speech_recognition/LM/train.py
#!/usr/bin/env python3 """Recipe for training a language model with a given text corpus. > python train.py RNNLM.yaml To run this recipe, you need to first install the Huggingface dataset: > pip install datasets Authors * Ju-Chieh Chou 2020 * Jianyuan Zhong 2021 * Mirco Ravanelli 2021 """ import sys import loggi...
9,669
32.344828
80
py
speechbrain
speechbrain-main/templates/speech_recognition/ASR/train.py
#!/usr/bin/env/python3 """Recipe for training a sequence-to-sequence ASR system with mini-librispeech. The system employs an encoder, a decoder, and an attention mechanism between them. Decoding is performed with beam search coupled with a neural language model. To run this recipe, do the following: > python train.py ...
17,800
37.364224
85
py
speechbrain
speechbrain-main/templates/speaker_id/custom_model.py
""" This file contains a very simple TDNN module to use for speaker-id. To replace this model, change the `!new:` tag in the hyperparameter file to refer to a built-in SpeechBrain model or another file containing a custom PyTorch module. Authors * Nauman Dawalatabad 2020 * Mirco Ravanelli 2020 """ import torch #...
5,638
29.814208
77
py
speechbrain
speechbrain-main/templates/speaker_id/train.py
#!/usr/bin/env python3 """Recipe for training a speaker-id system. The template can use used as a basic example for any signal classification task such as language_id, emotion recognition, command classification, etc. The proposed task classifies 28 speakers using Mini Librispeech. This task is very easy. In a real sce...
12,410
35.289474
80
py
speechbrain
speechbrain-main/templates/enhancement/custom_model.py
""" This file contains a very simple PyTorch module to use for enhancement. To replace this model, change the `!new:` tag in the hyperparameter file to refer to a built-in SpeechBrain model or another file containing a custom PyTorch module. Authors * Peter Plantinga 2021 """ import torch class CustomModel(torch.n...
1,992
30.140625
79
py
speechbrain
speechbrain-main/templates/enhancement/train.py
#!/usr/bin/env/python3 """Recipe for training a speech enhancement system with spectral masking. To run this recipe, do the following: > python train.py train.yaml --data_folder /path/to/save/mini_librispeech To read the code, first scroll to the bottom to see the "main" code. This gives a high-level overview of what...
11,127
34.552716
80
py
speechbrain
speechbrain-main/recipes/BinauralWSJ0Mix/separation/dynamic_mixing.py
import speechbrain as sb import numpy as np import torch import torchaudio import glob import os import random from speechbrain.processing.signal_processing import rescale from speechbrain.dataio.batch import PaddedBatch from scipy.signal import fftconvolve """ The functions to implement Dynamic Mixing For SpeechSepar...
7,597
33.694064
85
py
speechbrain
speechbrain-main/recipes/BinauralWSJ0Mix/separation/train.py
#!/usr/bin/env/python3 """Recipe for training a neural speech separation system on binaural wsjmix the dataset. The system employs an encoder, a decoder, and a masking network. To run this recipe, do the following: > python train.py hparams/convtasnet-parallel.yaml --data_folder yourpath/binaural-wsj0m...
32,509
37.023392
113
py
speechbrain
speechbrain-main/recipes/KsponSpeech/ksponspeech_prepare.py
""" Data preparation. Download: https://aihub.or.kr/aidata/105/download Author ------ Dongwon Kim, Dongwoo Kim 2021 """ import csv import logging import os import re import torchaudio from speechbrain.dataio.dataio import load_pkl, merge_csvs, save_pkl from speechbrain.utils.data_utils import get_all_files logger ...
11,619
26.213115
80
py
speechbrain
speechbrain-main/recipes/KsponSpeech/LM/train.py
#!/usr/bin/env python3 """Recipe for training a Language Model with ksponspeech train-965.2 transcript and lm_corpus. To run this recipe, do the following: > pip install datasets > python train.py hparams/<hparam_file>.yaml \ --data_folder <local_path_to_librispeech_dataset> Authors * Jianyuan Zhong 2021 * Ju-C...
7,234
32.967136
80
py
speechbrain
speechbrain-main/recipes/KsponSpeech/ASR/transformer/train.py
#!/usr/bin/env python3 """Recipe for training a Transformer ASR system with KsponSpeech. The system employs an encoder, a decoder, and an attention mechanism between them. Decoding is performed with (CTC/Att joint) beamsearch coupled with a neural language model. To run this recipe, do the following: > python train.py...
17,980
36.696017
80
py
speechbrain
speechbrain-main/recipes/timers-and-such/LM/train.py
#!/usr/bin/env/python3 """ Recipe for Timers and Such LM training. Run using: > python train.py hparams/train.yaml Authors * Loren Lugosch 2020 """ import sys import torch import speechbrain as sb from hyperpyyaml import load_hyperpyyaml from speechbrain.utils.distributed import run_on_main # Define training proc...
8,041
32.648536
83
py
speechbrain
speechbrain-main/recipes/timers-and-such/decoupled/train.py
#!/usr/bin/env/python3 """ Recipe for "decoupled" (speech -> ASR -> text -> NLU -> semantics) SLU. The NLU part is trained on the ground truth transcripts, and at test time we use the ASR to transcribe the audio and use that transcript as the input to the NLU. Run using: > python train.py hparams/train.yaml Authors ...
13,448
32.125616
89
py
speechbrain
speechbrain-main/recipes/timers-and-such/direct/train_with_wav2vec2.py
#!/usr/bin/env/python3 """ Recipe for "direct" (speech -> semantics) SLU with wav2vec2.0_based transfer learning. We encode input waveforms into features using a wav2vec2.0 model pretrained on ASR from HuggingFace (facebook/wav2vec2-base-960h), then feed the features into a seq2seq model to map them to semantics. (Ad...
13,849
32.373494
130
py
speechbrain
speechbrain-main/recipes/timers-and-such/direct/train.py
#!/usr/bin/env/python3 """ Recipe for "direct" (speech -> semantics) SLU with ASR-based transfer learning. We encode input waveforms into features using a model trained on LibriSpeech, then feed the features into a seq2seq model to map them to semantics. (Adapted from the LibriSpeech seq2seq ASR recipe written by Ju-...
13,273
32.605063
125
py
speechbrain
speechbrain-main/recipes/timers-and-such/multistage/train.py
#!/usr/bin/env/python3 """ Recipe for "multistage" (speech -> ASR -> text -> NLU -> semantics) SLU. We transcribe each minibatch using a model trained on LibriSpeech, then feed the transcriptions into a seq2seq model to map them to semantics. (The transcriptions could be done offline to make training faster; the bene...
14,030
33.138686
117
py
speechbrain
speechbrain-main/recipes/VoxLingua107/lang_id/create_wds_shards.py
################################################################################ # # Converts the unzipped <LANG_ID>/<VIDEO---0000.000-0000.000.wav> folder # structure of VoxLingua107 into a WebDataset format # # Author(s): Tanel Alumäe, Nik Vaessen ######################################################################...
5,210
27.47541
81
py
speechbrain
speechbrain-main/recipes/VoxLingua107/lang_id/train.py
#!/usr/bin/python3 """Recipe for training language embeddings using the VoxLingua107 Dataset. This recipe is heavily inspired by this: https://github.com/nikvaessen/speechbrain/tree/sharded-voxceleb/my-recipes/SpeakerRec To run this recipe, use the following command: > python train_lang_embeddings_wds.py {hyperparame...
8,757
30.390681
126
py
speechbrain
speechbrain-main/recipes/SLURP/NLU/train.py
#!/usr/bin/env/python3 """ Text-only NLU recipe. This recipes takes the golden ASR transcriptions and tries to estimate the semantics on the top of that. Authors * Loren Lugosch, Mirco Ravanelli 2020 """ import sys import torch import speechbrain as sb from hyperpyyaml import load_hyperpyyaml from speechbrain.utils...
12,701
33.895604
96
py
speechbrain
speechbrain-main/recipes/SLURP/direct/train_with_wav2vec2.py
#!/usr/bin/env/python3 """ Recipe for "direct" (speech -> semantics) SLU. We encode input waveforms into features using the wav2vec2/HuBert model, then feed the features into a seq2seq model to map them to semantics. (Adapted from the LibriSpeech seq2seq ASR recipe written by Ju-Chieh Chou, Mirco Ravanelli, Abdel Heba,...
13,958
35.163212
125
py
speechbrain
speechbrain-main/recipes/SLURP/direct/train.py
#!/usr/bin/env/python3 """ Recipe for "direct" (speech -> semantics) SLU with ASR-based transfer learning. We encode input waveforms into features using a model trained on LibriSpeech, then feed the features into a seq2seq model to map them to semantics. (Adapted from the LibriSpeech seq2seq ASR recipe written by Ju-...
13,228
35.144809
125
py
speechbrain
speechbrain-main/recipes/IEMOCAP/emotion_recognition/train_with_wav2vec2.py
#!/usr/bin/env python3 """Recipe for training an emotion recognition system from speech data only using IEMOCAP. The system classifies 4 emotions ( anger, happiness, sadness, neutrality) with wav2vec2. To run this recipe, do the following: > python train_with_wav2vec2.py hparams/train_with_wav2vec2.yaml --data_folder ...
10,890
35.182724
108
py
speechbrain
speechbrain-main/recipes/IEMOCAP/emotion_recognition/train.py
#!/usr/bin/env python3 """Recipe for training an emotion recognition system from speech data only using IEMOCAP. The system classifies 4 emotions ( anger, happiness, sadness, neutrality) with an ECAPA-TDNN model. To run this recipe, do the following: > python train.py hparams/train.yaml --data_folder /path/to/IEMOCAP...
13,084
34.080429
89
py
speechbrain
speechbrain-main/recipes/LibriMix/separation/dynamic_mixing.py
import speechbrain as sb import numpy as np import torch import torchaudio import glob import os from speechbrain.dataio.batch import PaddedBatch from tqdm import tqdm import warnings import pyloudnorm import random """ The functions to implement Dynamic Mixing For SpeechSeparation Authors * Samuele Cornell 2021 ...
7,257
30.284483
93
py
speechbrain
speechbrain-main/recipes/LibriMix/separation/train.py
#!/usr/bin/env/python3 """Recipe for training a neural speech separation system on Libri2/3Mix datasets. The system employs an encoder, a decoder, and a masking network. To run this recipe, do the following: > python train.py hparams/sepformer-libri2mix.yaml > python train.py hparams/sepformer-libri3mix.yaml The exp...
25,102
35.754026
108
py
speechbrain
speechbrain-main/recipes/LibriMix/meta/preprocess_dynamic_mixing.py
""" This script allows to resample a folder which contains audio files. The files are parsed recursively. An exact copy of the folder is created, with same structure but contained resampled audio files. Resampling is performed by using sox through torchaudio. Author ------ Samuele Cornell, 2020 """ import os import ar...
2,732
27.175258
80
py
speechbrain
speechbrain-main/recipes/ESC50/esc50_prepare.py
""" Creates data manifest files for ESC50 If the data does not exist in the specified --data_folder, we download the data automatically. https://urbansounddataset.weebly.com/urbansound8k.htm://github.com/karolpiczak/ESC-50 Authors: * Cem Subakan 2022, 2023 * Francesco Paissan 2022, 2023 Adapted from the Urbansoun...
12,776
33.814714
160
py
speechbrain
speechbrain-main/recipes/ESC50/classification/train_classifier.py
#!/usr/bin/python3 """Recipe to train a classifier on ESC50 data We employ an encoder followed by a sound classifier. To run this recipe, use the following command: > python train_classifier.py hparams/cnn14.yaml --data_folder yourpath/ESC-50-master Authors * Cem Subakan 2022, 2023 * Francesco Paissan 2022, 2...
15,164
35.454327
92
py
speechbrain
speechbrain-main/recipes/ESC50/interpret/train_l2i.py
#!/usr/bin/python3 """This recipe to train L2I (https://arxiv.org/abs/2202.11479) to interepret audio classifiers. Authors * Cem Subakan 2022, 2023 * Francesco Paissan 2022, 2023 """ import os import sys import torch import torchaudio import speechbrain as sb from hyperpyyaml import load_hyperpyyaml from speec...
24,425
35.026549
95
py
speechbrain
speechbrain-main/recipes/ESC50/interpret/train_piq.py
#!/usr/bin/python3 """This recipe to train PIQ to interepret audio classifiers. Authors * Cem Subakan 2022, 2023 * Francesco Paissan 2022, 2023 """ import os import sys import torch import torchaudio import speechbrain as sb from hyperpyyaml import load_hyperpyyaml from speechbrain.utils.distributed import run...
26,143
33.627815
92
py
speechbrain
speechbrain-main/recipes/ESC50/interpret/train_nmf.py
#!/usr/bin/python3 """The recipe to train an NMF model with amortized inference on ESC50 data. To run this recipe, use the following command: > python train_nmf.py hparams/nmf.yaml --data_folder /yourpath/ESC-50-master Authors * Cem Subakan 2022, 2023 * Francesco Paissan 2022, 2023 """ import sys import tor...
4,783
32.222222
86
py
speechbrain
speechbrain-main/recipes/AISHELL-1/ASR/seq2seq/train.py
#!/usr/bin/env/python3 """ AISHELL-1 seq2seq model recipe. (Adapted from the LibriSpeech recipe.) """ import sys import torch import logging import speechbrain as sb from speechbrain.utils.distributed import run_on_main from hyperpyyaml import load_hyperpyyaml logger = logging.getLogger(__name__) # Define trainin...
13,009
34.162162
89
py
speechbrain
speechbrain-main/recipes/AISHELL-1/ASR/CTC/train_with_wav2vec.py
#!/usr/bin/env/python3 """AISHELL-1 CTC recipe. The system employs a wav2vec2 encoder and a CTC decoder. Decoding is performed with greedy decoding. To run this recipe, do the following: > python train_with_wav2vec2.py hparams/train_with_wav2vec2.yaml With the default hyperparameters, the system employs a pretrained ...
13,335
33.282776
89
py
speechbrain
speechbrain-main/recipes/AISHELL-1/ASR/transformer/train_with_wav2vect.py
#!/usr/bin/env/python3 """ AISHELL-1 transformer model recipe. (Adapted from the LibriSpeech recipe.). It is designed to work with wav2vec2 pre-training. """ import sys import torch import logging import speechbrain as sb from speechbrain.utils.distributed import run_on_main from hyperpyyaml import load_hyperpyyaml ...
17,879
35.341463
94
py
speechbrain
speechbrain-main/recipes/AISHELL-1/ASR/transformer/train.py
#!/usr/bin/env/python3 """ AISHELL-1 transformer model recipe. (Adapted from the LibriSpeech recipe.) """ import sys import torch import logging import speechbrain as sb from speechbrain.utils.distributed import run_on_main from hyperpyyaml import load_hyperpyyaml logger = logging.getLogger(__name__) # Define tra...
17,133
35.147679
94
py