repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
speechbrain
speechbrain-main/speechbrain/nnet/complex_networks/c_RNN.py
"""Library implementing complex-valued recurrent neural networks. Authors * Titouan Parcollet 2020 """ import torch import logging from speechbrain.nnet.complex_networks.c_linear import CLinear from speechbrain.nnet.complex_networks.c_normalization import ( CBatchNorm, CLayerNorm, ) logger = logging.getLogg...
38,455
31.153846
97
py
speechbrain
speechbrain-main/speechbrain/nnet/complex_networks/c_linear.py
"""Library implementing complex-valued linear transformation. Authors * Titouan Parcollet 2020 """ import torch import logging from speechbrain.nnet.complex_networks.c_ops import ( affect_init, complex_init, unitary_init, complex_linear_op, check_complex_input, ) logger = logging.getLogger(__nam...
4,020
32.508333
97
py
speechbrain
speechbrain-main/speechbrain/nnet/transducer/transducer_joint.py
"""Library implementing transducer_joint. Author Abdelwahab HEBA 2020 """ import torch import logging import torch.nn as nn logger = logging.getLogger(__name__) class Transducer_joint(nn.Module): """Computes joint tensor between Transcription network (TN) & Prediction network (PN) Arguments ------...
3,106
31.364583
89
py
speechbrain
speechbrain-main/speechbrain/nnet/transducer/__init__.py
"""Package containing transducer neural networks """
53
17
48
py
speechbrain
speechbrain-main/speechbrain/nnet/quaternion_networks/q_RNN.py
"""Library implementing quaternion-valued recurrent neural networks. Authors * Titouan Parcollet 2020 """ import torch import logging from speechbrain.nnet.quaternion_networks.q_linear import QLinear from speechbrain.nnet.quaternion_networks.q_normalization import QBatchNorm from torch import Tensor from typing impo...
40,503
32.06449
94
py
speechbrain
speechbrain-main/speechbrain/nnet/quaternion_networks/q_CNN.py
"""Library implementing quaternion-valued convolutional neural networks. Authors * Titouan Parcollet 2020 """ import torch import torch.nn as nn import logging import torch.nn.functional as F from speechbrain.nnet.CNN import get_padding_elem from speechbrain.nnet.quaternion_networks.q_ops import ( unitary_init, ...
20,523
32.980132
94
py
speechbrain
speechbrain-main/speechbrain/nnet/quaternion_networks/q_ops.py
"""This library implements different operations needed by quaternion- valued architectures. This work is inspired by: "Quaternion neural networks" - Parcollet T. "Quaternion recurrent neural networks" - Parcollet T. et al. "Quaternion convolutional neural networks for end-to-end automatic speech recognition" - Parcolle...
28,142
33.362637
80
py
speechbrain
speechbrain-main/speechbrain/nnet/quaternion_networks/q_normalization.py
"""Library implementing quaternion-valued normalization. Authors * Titouan Parcollet 2020 """ import torch from torch.nn import Parameter class QBatchNorm(torch.nn.Module): """This class implements the simplest form of a quaternion batchnorm as described in : "Quaternion Convolutional Neural Network for ...
5,396
31.908537
89
py
speechbrain
speechbrain-main/speechbrain/nnet/quaternion_networks/__init__.py
"""Package containing quaternion neural networks """
53
17
48
py
speechbrain
speechbrain-main/speechbrain/nnet/quaternion_networks/q_linear.py
"""Library implementing quaternion-valued linear transformation. Authors * Titouan Parcollet 2020 """ import torch import logging from speechbrain.nnet.quaternion_networks.q_ops import ( affect_init, unitary_init, quaternion_init, quaternion_linear_op, check_quaternion_input, quaternion_linea...
7,965
34.721973
94
py
speechbrain
speechbrain-main/speechbrain/nnet/loss/transducer_loss.py
""" Transducer loss implementation (depends on numba) Authors * Abdelwahab Heba 2020 """ import torch from torch.autograd import Function from torch.nn import Module try: from numba import cuda except ImportError: err_msg = "The optional dependency Numba is needed to use this module\n" err_msg += "Canno...
14,074
38.985795
167
py
speechbrain
speechbrain-main/speechbrain/nnet/loss/stoi_loss.py
"""Library for computing STOI computation. Reference: "End-to-End Waveform Utterance Enhancement for Direct Evaluation Metrics Optimization by Fully Convolutional Neural Networks", TASLP, 2018 Authors: Szu-Wei, Fu 2020 """ import torch import torchaudio import numpy as np from speechbrain.utils.torch_audio_backen...
6,489
28.770642
76
py
speechbrain
speechbrain-main/speechbrain/nnet/loss/guidedattn_loss.py
"""The Guided Attention Loss implementation This loss can be used to speed up the training of models in which the correspondence between inputs and outputs is roughly linear, and the attention alignments are expected to be approximately diagonal, such as Grapheme-to-Phoneme and Text-to-Speech Authors * Artem Ploujnik...
5,760
31.184358
87
py
speechbrain
speechbrain-main/speechbrain/nnet/loss/__init__.py
"""Package containing specific losses (transducer, stoi ...) """
65
21
60
py
speechbrain
speechbrain-main/speechbrain/nnet/loss/si_snr_loss.py
""" # Authors: * Szu-Wei, Fu 2021 * Mirco Ravanelli 2020 * Samuele Cornell 2020 * Hwidong Na 2020 * Yan Gao 2020 * Titouan Parcollet 2020 """ import torch import numpy as np smallVal = np.finfo("float").eps # To avoid divide by zero def si_snr_loss(y_pred_batch, y_true_batch, lens, reduction="mean"): """...
1,912
27.132353
78
py
speechbrain
speechbrain-main/speechbrain/pretrained/training.py
""" Training utilities for pretrained models Authors * Artem Ploujnikov 2021 """ import os import logging import shutil logger = logging.getLogger(__name__) def save_for_pretrained( hparams, min_key=None, max_key=None, ckpt_predicate=None, pretrainer_key="pretrainer", checkpointer_key="check...
2,987
32.2
82
py
speechbrain
speechbrain-main/speechbrain/pretrained/interfaces.py
"""Defines interfaces for simple inference with pretrained models Authors: * Aku Rouhe 2021 * Peter Plantinga 2021 * Loren Lugosch 2020 * Mirco Ravanelli 2020 * Titouan Parcollet 2021 * Abdel Heba 2021 * Andreas Nautsch 2022 * Pooneh Mousavi 20023 """ import logging import hashlib import sys import speechbrain...
107,365
34.812542
122
py
speechbrain
speechbrain-main/speechbrain/pretrained/fetching.py
"""Downloads or otherwise fetches pretrained models Authors: * Aku Rouhe 2021 * Samuele Cornell 2021 """ import urllib.request import urllib.error import pathlib import logging import huggingface_hub from requests.exceptions import HTTPError logger = logging.getLogger(__name__) def _missing_ok_unlink(path): #...
4,921
34.927007
101
py
speechbrain
speechbrain-main/speechbrain/pretrained/__init__.py
"""Pretrained models""" from .interfaces import * # noqa
59
14
33
py
speechbrain
speechbrain-main/speechbrain/dataio/legacy.py
"""SpeechBrain Extended CSV Compatibility.""" from speechbrain.dataio.dataset import DynamicItemDataset import collections import csv import pickle import logging import torch import torchaudio import re logger = logging.getLogger(__name__) TORCHAUDIO_FORMATS = ["wav", "flac", "aac", "ogg", "flac", "mp3"] ITEM_POSTF...
10,629
32.533123
79
py
speechbrain
speechbrain-main/speechbrain/dataio/dataio.py
""" Data reading and writing. Authors * Mirco Ravanelli 2020 * Aku Rouhe 2020 * Ju-Chieh Chou 2020 * Samuele Cornell 2020 * Abdel HEBA 2020 * Gaelle Laperriere 2021 * Sahar Ghannay 2021 * Sylvain de Langen 2022 """ import os import torch import logging import numpy as np import pickle import hashlib import csv...
34,200
28.560069
187
py
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/iterators.py
"""Webdataset compatible iterators Authors: * Aku Rouhe 2021 """ import bisect import random from dataclasses import dataclass, field from functools import partial from typing import Any from speechbrain.dataio.batch import PaddedBatch @dataclass(order=True) class LengthItem: """ Data class for lenghts""" ...
8,487
37.234234
84
py
speechbrain
speechbrain-main/speechbrain/dataio/__init__.py
"""Data loading and dataset preprocessing """ import os __all__ = [] for filename in os.listdir(os.path.dirname(__file__)): filename = os.path.basename(filename) if filename.endswith(".py") and not filename.startswith("__"): __all__.append(filename[:-3]) from . import * # noqa
297
23.833333
66
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/dataio/wer.py
"""WER print functions. The functions here are used to print the computed statistics with human-readable formatting. They have a file argument, but you can also just use contextlib.redirect_stdout, which may give a nicer syntax. Authors * Aku Rouhe 2020 """ import sys from speechbrain.utils import edit_distance de...
6,315
30.89899
138
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/__init__.py
"""Tools for aligning transcripts and speech signals """
57
18.333333
52
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/lm/arpa.py
r""" Tools for working with ARPA format N-gram models Expects the ARPA format to have: - a \data\ header - counts of ngrams in the order that they are later listed - line breaks between \data\ and \n-grams: sections - \end\ E.G. ``` \data\ ngram 1=2 ngram 2=1 \1-grams: -1.0000 Hello -0.23 ...
7,508
31.647826
80
py
speechbrain
speechbrain-main/speechbrain/lm/counting.py
""" N-gram counting, discounting, interpolation, and backoff Authors * Aku Rouhe 2020 """ import itertools # The following functions are essentially copying the NLTK ngram counting # pipeline with minor differences. Written from scratch, but with enough # inspiration that I feel I want to mention the inspiration so...
4,500
26.613497
79
py
speechbrain
speechbrain-main/speechbrain/lm/ngram.py
""" N-gram language model query interface Authors * Aku Rouhe 2020 """ import collections NEGINFINITY = float("-inf") class BackoffNgramLM: """ Query interface for backoff N-gram language models The ngrams format is best explained by an example query: P( world | <s>, hello ), i.e. trigram model, p...
6,939
33.527363
79
py
speechbrain
speechbrain-main/speechbrain/lm/__init__.py
""" Package defining language models """
41
13
36
py
speechbrain
speechbrain-main/speechbrain/utils/epoch_loop.py
"""Implements a checkpointable epoch counter (loop), optionally integrating early stopping. Authors * Aku Rouhe 2020 * Davide Borra 2021 """ from .checkpoints import register_checkpoint_hooks from .checkpoints import mark_as_saver from .checkpoints import mark_as_loader import logging logger = logging.getLogger(__n...
4,557
33.014925
118
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/callchains.py
"""Chaining together callables, if some require relative lengths""" import inspect def lengths_arg_exists(func): """Returns True if func takes ``lengths`` keyword argument. Arguments --------- func : callable The function, method, or other callable to search for the lengths arg. """ s...
2,361
27.804878
78
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/hpopt.py
"""Utilities for hyperparameter optimization. This wrapper has an optional dependency on Oríon https://orion.readthedocs.io/en/stable/ https://github.com/Epistimio/orion Authors * Artem Ploujnikov 2021 """ import importlib import logging import json import os import speechbrain as sb import sys from datetime import...
13,211
28.756757
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/hparams.py
"""Utilities for hparams files Authors * Artem Ploujnikov 2021 """ def choice(value, choices, default=None): """ The equivalent of a "switch statement" for hparams files. The typical use case is where different options/modules are available, and a top-level flag decides which one to use Argumen...
921
26.117647
82
py
speechbrain
speechbrain-main/speechbrain/utils/DER.py
"""Calculates Diarization Error Rate (DER) which is the sum of Missed Speaker (MS), False Alarm (FA), and Speaker Error Rate (SER) using md-eval-22.pl from NIST RT Evaluation. Authors * Neville Ryant 2018 * Nauman Dawalatabad 2020 Credits This code is adapted from https://github.com/nryant/dscore """ import os im...
4,464
28.183007
104
py
speechbrain
speechbrain-main/speechbrain/utils/superpowers.py
"""Superpowers which should be sparingly used. This library contains functions for importing python files and for running shell commands. Remember, with great power comes great responsibility. Authors * Mirco Ravanelli 2020 * Aku Rouhe 2021 """ import logging import subprocess import importlib import pathlib logg...
1,962
21.306818
85
py
speechbrain
speechbrain-main/speechbrain/utils/parameter_transfer.py
"""Convenience functions for the simplest parameter transfer cases. Use `speechbrain.utils.checkpoints.Checkpointer` to find a checkpoint and the path to the parameter file. Authors * Aku Rouhe 2020 """ import logging import pathlib from speechbrain.pretrained.fetching import fetch from speechbrain.utils.checkpoint...
9,651
32.985915
83
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/text_to_sequence.py
""" from https://github.com/keithito/tacotron """ # ***************************************************************************** # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the foll...
8,219
24.768025
147
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/data_pipeline.py
"""A pipeline for data transformations. Example ------- >>> from hyperpyyaml import load_hyperpyyaml >>> yamlstring = ''' ... pipeline: !new:speechbrain.utils.data_pipeline.DataPipeline ... static_data_keys: [a, b] ... dynamic_items: ... - func: !name:operator.add ... takes: ["a", "b"] .....
18,934
35.273946
80
py
speechbrain
speechbrain-main/speechbrain/utils/__init__.py
""" Package containing various tools (accuracy, checkpoints ...) """ import os __all__ = [] for filename in os.listdir(os.path.dirname(__file__)): filename = os.path.basename(filename) if filename.endswith(".py") and not filename.startswith("__"): __all__.append(filename[:-3]) from . import * # noqa
320
25.75
66
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/depgraph.py
"""A dependency graph for finding evaluation order. Example ------- >>> # The basic use case is that you have a bunch of keys >>> # and some of them depend on each other: >>> database = [] >>> functions = {'read': {'func': lambda: (0,1,2), ... 'needs': []}, ... 'process': {'func': la...
9,678
33.942238
81
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/PLDA_LDA.py
"""A popular speaker recognition/diarization model (LDA and PLDA). Authors * Anthony Larcher 2020 * Nauman Dawalatabad 2020 Relevant Papers - This implementation of PLDA is based on the following papers. - PLDA model Training * Ye Jiang et. al, "PLDA Modeling in I-Vector and Supervector Space for Speaker Ver...
34,751
33.238424
132
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/diarization.py
""" This script contains basic functions used for speaker diarization. This script has an optional dependency on open source scikit-learn (sklearn) library. A few scikit-learn functions are modified in this script as per requirement. Reference --------- This code is written using the following: - Von Luxburg, U. A tu...
36,922
29.743547
116
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/processing/__init__.py
""" Package containing various techniques of speech processing """
67
21.666667
62
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/__init__.py
""" Package defining common blocks (DNN models, processing ...) This subpackage gathers higher level blocks, or "lobes". The classes here may leverage the extended YAML syntax. """ from . import models # noqa
211
29.285714
63
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/__init__.py
""" Package defining neural netword models (CRDNN, Xvectors ...) """
69
22.333333
64
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