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/recipes/TIMIT/ASR/seq2seq/train.py
#!/usr/bin/env python3 """Recipe for training a phoneme recognizer on TIMIT. The system relies on an encoder, a decoder, and attention mechanisms between them. Training is done with NLL. CTC loss is also added on the top of the encoder. Greedy search is using for validation, while beamsearch is used at test time to imp...
12,912
34.869444
83
py
speechbrain
speechbrain-main/recipes/TIMIT/ASR/CTC/timit_prepare.py
../../timit_prepare.py
22
22
22
py
speechbrain
speechbrain-main/recipes/TIMIT/ASR/CTC/train.py
#!/usr/bin/env python3 """Recipe for training a phoneme recognizer on TIMIT. The system relies on a model trained with CTC. Greedy search is using for validation, while beamsearch is used at test time to improve the system performance. To run this recipe, do the following: > python train.py hparams/train.yaml --data_f...
9,074
33.637405
80
py
speechbrain
speechbrain-main/recipes/TIMIT/Alignment/timit_prepare.py
../timit_prepare.py
19
19
19
py
speechbrain
speechbrain-main/recipes/TIMIT/Alignment/train.py
#!/usr/bin/env python3 """Recipe for training a HMM-DNN alignment system on the TIMIT dataset. The system is trained can be trained with Viterbi, forward, or CTC loss. To run this recipe, do the following: > python train.py hparams/train.yaml --data_folder /path/to/TIMIT Authors * Elena Rastorgueva 2020 * Mirco Rav...
10,757
34.272131
83
py
speechbrain
speechbrain-main/recipes/fluent-speech-commands/prepare.py
import os import logging from speechbrain.dataio.dataio import read_audio try: import pandas as pd except ImportError: err_msg = ( "The optional dependency pandas must be installed to run this recipe.\n" ) err_msg += "Install using `pip install pandas`.\n" raise ImportError(err_msg) logger...
2,812
26.048077
80
py
speechbrain
speechbrain-main/recipes/fluent-speech-commands/Tokenizer/prepare.py
../prepare.py
13
13
13
py
speechbrain
speechbrain-main/recipes/fluent-speech-commands/Tokenizer/train.py
#!/usr/bin/env/python3 """Recipe for training a BPE tokenizer for Fluent Speech Commands. The tokenizer coverts semantics into sub-word units that can be used to train a language (LM) or an acoustic model (AM). To run this recipe, do the following: > python train.py hparams/tokenizer_bpe51.yaml Authors * Abdel Heba...
1,446
25.796296
72
py
speechbrain
speechbrain-main/recipes/fluent-speech-commands/direct/prepare.py
../prepare.py
13
13
13
py
speechbrain
speechbrain-main/recipes/fluent-speech-commands/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-...
12,070
33.686782
125
py
speechbrain
speechbrain-main/recipes/CommonVoice/common_voice_prepare.py
""" Data preparation. Download: https://voice.mozilla.org/en/datasets Author ------ Titouan Parcollet Luca Della Libera 2022 Pooneh Mousavi 2022 """ import os import csv import re import logging import torchaudio import unicodedata from tqdm.contrib import tzip logger = logging.getLogger(__name__) def prepare_commo...
11,693
29.854881
149
py
speechbrain
speechbrain-main/recipes/CommonVoice/self-supervised-learning/wav2vec2/common_voice_prepare.py
../../common_voice_prepare.py
29
29
29
py
speechbrain
speechbrain-main/recipes/CommonVoice/self-supervised-learning/wav2vec2/train_hf_wav2vec2.py
#!/usr/bin/env python3 import sys import torch import logging import speechbrain as sb import torchaudio from hyperpyyaml import load_hyperpyyaml from speechbrain.utils.distributed import run_on_main """Recipe for pretraining a wav2vec 2.0 model on CommonVoice EN. Note that it can be trained with ANY dataset as long ...
12,890
33.746631
84
py
speechbrain
speechbrain-main/recipes/CommonVoice/ASR/transducer/common_voice_prepare.py
../../common_voice_prepare.py
29
29
29
py
speechbrain
speechbrain-main/recipes/CommonVoice/ASR/transducer/train.py
#!/usr/bin/env/python3 """Recipe for training a Transducer ASR system with librispeech. The system employs an encoder, a decoder, and an joint network between them. Decoding is performed with beamsearch coupled with a neural language model. To run this recipe, do the following: > python train.py hparams/train.yaml Wi...
16,161
37.028235
89
py
speechbrain
speechbrain-main/recipes/CommonVoice/ASR/seq2seq/common_voice_prepare.py
../../common_voice_prepare.py
29
29
29
py
speechbrain
speechbrain-main/recipes/CommonVoice/ASR/seq2seq/train_with_wav2vec.py
#!/usr/bin/env python3 import sys import torch import logging import speechbrain as sb import torchaudio from hyperpyyaml import load_hyperpyyaml from speechbrain.tokenizers.SentencePiece import SentencePiece from speechbrain.utils.data_utils import undo_padding from speechbrain.utils.distributed import run_on_main ""...
15,201
35.719807
89
py
speechbrain
speechbrain-main/recipes/CommonVoice/ASR/seq2seq/train.py
#!/usr/bin/env python3 import sys import torch import logging import speechbrain as sb import torchaudio from hyperpyyaml import load_hyperpyyaml from speechbrain.tokenizers.SentencePiece import SentencePiece from speechbrain.utils.data_utils import undo_padding from speechbrain.utils.distributed import run_on_main ""...
12,748
36.061047
89
py
speechbrain
speechbrain-main/recipes/CommonVoice/ASR/CTC/common_voice_prepare.py
../../common_voice_prepare.py
29
29
29
py
speechbrain
speechbrain-main/recipes/CommonVoice/ASR/CTC/train_with_wav2vec.py
#!/usr/bin/env python3 import sys import torch import logging import speechbrain as sb import torchaudio from hyperpyyaml import load_hyperpyyaml from speechbrain.tokenizers.SentencePiece import SentencePiece from speechbrain.utils.data_utils import undo_padding from speechbrain.utils.distributed import run_on_main ""...
14,594
36.51928
89
py
speechbrain
speechbrain-main/recipes/CommonVoice/ASR/transformer/common_voice_prepare.py
../../common_voice_prepare.py
29
29
29
py
speechbrain
speechbrain-main/recipes/CommonVoice/ASR/transformer/train.py
#!/usr/bin/env python3 """Recipe for training a Transformer ASR system with CommonVoice The system employs an encoder, a decoder, and an attention mechanism between them. Decoding is performed with (CTC/Att joint) beamsearch. To run this recipe, do the following: > python train.py hparams/transformer.yaml With the de...
16,735
35.863436
109
py
speechbrain
speechbrain-main/recipes/CommonVoice/ASR/transformer/train_with_whisper.py
#!/usr/bin/env python3 """Recipe for training a whisper-based ASR system with CommonVoice. The system employs whisper from OpenAI (https://cdn.openai.com/papers/whisper.pdf). This recipe take the whisper encoder-decoder to fine-tune on. To run this recipe, do the following: > python train_with_whisper.py hparams/train...
11,891
34.60479
89
py
speechbrain
speechbrain-main/recipes/AMI/ami_prepare.py
""" Data preparation. Download: http://groups.inf.ed.ac.uk/ami/download/ Prepares metadata files (JSON) from manual annotations "segments/" using RTTM format (Oracle VAD). """ import os import logging import xml.etree.ElementTree as et import glob import json from ami_splits import get_AMI_split from speechbrain.da...
16,456
28.921818
101
py
speechbrain
speechbrain-main/recipes/AMI/ami_splits.py
""" AMI corpus contained 100 hours of meeting recording. This script returns the standard train, dev and eval split for AMI corpus. For more information on dataset please refer to http://groups.inf.ed.ac.uk/ami/corpus/datasets.shtml """ ALLOWED_OPTIONS = ["scenario_only", "full_corpus", "full_corpus_asr"] def get_AM...
4,914
21.442922
100
py
speechbrain
speechbrain-main/recipes/AMI/Diarization/ami_prepare.py
../ami_prepare.py
17
17
17
py
speechbrain
speechbrain-main/recipes/AMI/Diarization/experiment.py
#!/usr/bin/python3 """This recipe implements diarization system using deep embedding extraction followed by spectral clustering. To run this recipe: > python experiment.py hparams/<your_hyperparams_file.yaml> e.g., python experiment.py hparams/ecapa_tdnn.yaml Condition: Oracle VAD (speech regions taken from the grou...
22,324
32.172363
135
py
speechbrain
speechbrain-main/recipes/Switchboard/switchboard_prepare.py
""" This script prepares the data of the switchboard-1 release 2 corpus (LDC97S62). Optionally, the Fisher corpus transcripts (LDC2004T19 and LDC2005T19) can be added to the CSVs for Tokenizer and LM training. The test set is based on the eval2000/Hub 5 data (LDC2002S09/LDC2002T43). The datasets can be obtained from: ...
42,755
33.122905
114
py
speechbrain
speechbrain-main/recipes/Switchboard/LM/switchboard_prepare.py
../switchboard_prepare.py
25
25
25
py
speechbrain
speechbrain-main/recipes/Switchboard/LM/train.py
#!/usr/bin/env python3 """Recipe for training a Language Model on Switchboard and Fisher corpus. To run this recipe, do the following: > pip install datasets > python train.py hparams/<params>.yaml Authors * Jianyuan Zhong 2021 * Ju-Chieh Chou 2020 * Dominik Wagner 2022 """ import sys import logging import torch f...
7,050
32.417062
93
py
speechbrain
speechbrain-main/recipes/Switchboard/Tokenizer/switchboard_prepare.py
../switchboard_prepare.py
25
25
25
py
speechbrain
speechbrain-main/recipes/Switchboard/Tokenizer/train.py
#!/usr/bin/env/python3 """Recipe for training a BPE tokenizer with Switchboard. The tokenizer coverts words into sub-word units that can be used to train a language (LM) or an acoustic model (AM). When doing a speech recognition experiment you have to make sure that the acoustic and language models are trained with the...
1,910
30.85
72
py
speechbrain
speechbrain-main/recipes/Switchboard/ASR/normalize_util.py
""" This script provides some utility functions that can be used during inference of ASR models. The intended use is to import `normalize_words` after decoding and tokenization. Note that this will only work, when UPPERCASE letters are used throughout the recipe. Author ------ Dominik Wagner 2022 """ import re import...
8,294
38.5
95
py
speechbrain
speechbrain-main/recipes/Switchboard/ASR/seq2seq/switchboard_prepare.py
../../switchboard_prepare.py
28
28
28
py
speechbrain
speechbrain-main/recipes/Switchboard/ASR/seq2seq/train.py
#!/usr/bin/env/python3 """Recipe for training a sequence-to-sequence ASR system with Switchboard. The system employs an encoder, a decoder, and an attention mechanism between them. Decoding is performed with beamsearch. To run this recipe, do the following: > python train.py hparams/train_BPE1000.yaml With the defaul...
17,124
34.901468
89
py
speechbrain
speechbrain-main/recipes/Switchboard/ASR/seq2seq/normalize_util.py
../normalize_util.py
20
20
20
py
speechbrain
speechbrain-main/recipes/Switchboard/ASR/CTC/switchboard_prepare.py
../../switchboard_prepare.py
28
28
28
py
speechbrain
speechbrain-main/recipes/Switchboard/ASR/CTC/train_with_wav2vec.py
#!/usr/bin/env python3 import functools import os import sys from pathlib import Path import torch import logging import speechbrain as sb import torchaudio from hyperpyyaml import load_hyperpyyaml from speechbrain.tokenizers.SentencePiece import SentencePiece from speechbrain.utils.data_utils import undo_padding fro...
15,887
34.623318
116
py
speechbrain
speechbrain-main/recipes/Switchboard/ASR/CTC/normalize_util.py
../normalize_util.py
20
20
20
py
speechbrain
speechbrain-main/recipes/Switchboard/ASR/transformer/switchboard_prepare.py
../../switchboard_prepare.py
28
28
28
py
speechbrain
speechbrain-main/recipes/Switchboard/ASR/transformer/train.py
#!/usr/bin/env python3 """Recipe for training a Transformer ASR system with Switchboard. 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...
20,245
35.677536
105
py
speechbrain
speechbrain-main/recipes/Switchboard/ASR/transformer/normalize_util.py
../normalize_util.py
20
20
20
py
speechbrain
speechbrain-main/recipes/Google-speech-commands/prepare_GSC.py
""" Data preparation for Google Speech Commands v0.02. Download: http://download.tensorflow.org/data/speech_commands_v0.02.tar.gz Author ------ David Raby-Pepin 2021 """ import os from os import walk import glob import shutil import logging import torch import re import hashlib import copy import numpy as np from s...
11,265
30.915014
119
py
speechbrain
speechbrain-main/recipes/Google-speech-commands/train.py
#!/usr/bin/python3 """Recipe for training a classifier using the Google Speech Commands v0.02 Dataset. To run this recipe, use the following command: > python train.py {hyperparameter_file} Using your own hyperparameter file or one of the following: hyperparams/xvect.yaml (xvector system) Author * Mirco Rava...
10,834
31.056213
80
py
speechbrain
speechbrain-main/recipes/IWSLT22_lowresource/prepare_iwslt22.py
#!/usr/bin/env python3 """ Tamasheq-French data processing. Author ------ Marcely Zanon Boito 2022 """ import json import os def write_json(json_file_name, data): with open(json_file_name, mode="w", encoding="utf-8") as output_file: json.dump( data, output_file, ensur...
1,873
23.986667
80
py
speechbrain
speechbrain-main/recipes/IWSLT22_lowresource/train.py
#!/usr/bin/env python3 """Recipe for fine-tuning a wav2vec model for the ST task (no transcriptions). Author * Marcely Zanon Boito, 2022 """ import sys import torch import logging import speechbrain as sb from speechbrain.tokenizers.SentencePiece import SentencePiece from speechbrain.utils.distributed import run_on_...
16,143
36.284065
100
py
speechbrain
speechbrain-main/recipes/Voicebank/voicebank_prepare.py
# -*- coding: utf-8 -*- """ Data preparation. Download and resample, use ``download_vctk`` below. https://datashare.is.ed.ac.uk/handle/10283/2791 Authors: * Szu-Wei Fu, 2020 * Peter Plantinga, 2020 """ import os import json import string import urllib import shutil import logging import tempfile import torchaudio ...
14,761
30.14346
80
py
speechbrain
speechbrain-main/recipes/Voicebank/enhance/SEGAN/voicebank_prepare.py
../../voicebank_prepare.py
26
26
26
py
speechbrain
speechbrain-main/recipes/Voicebank/enhance/SEGAN/train.py
#!/usr/bin/env/python3 """Recipe for training a speech enhancement system with the Voicebank dataset based on the SEGAN model architecture. (based on the paper: Pascual et al. https://arxiv.org/pdf/1703.09452.pdf). To run this recipe, do the following: > python train.py hparams/train.yaml Authors * Francis Carter 20...
17,802
33.568932
116
py
speechbrain
speechbrain-main/recipes/Voicebank/enhance/MetricGAN/voicebank_prepare.py
../../voicebank_prepare.py
26
26
26
py
speechbrain
speechbrain-main/recipes/Voicebank/enhance/MetricGAN/train.py
#!/usr/bin/env/python3 """ Recipe for training a speech enhancement system with the Voicebank dataset. To run this recipe, do the following: > python train.py hparams/{hyperparam_file}.yaml Authors * Szu-Wei Fu 2020 * Peter Plantinga 2021 """ import os import sys import shutil import pickle import torch import tor...
22,525
35.687296
80
py
speechbrain
speechbrain-main/recipes/Voicebank/enhance/spectral_mask/voicebank_prepare.py
../../voicebank_prepare.py
26
26
26
py
speechbrain
speechbrain-main/recipes/Voicebank/enhance/spectral_mask/train.py
#!/usr/bin/env/python3 """Recipe for training a speech enhancement system with the Voicebank dataset. To run this recipe, do the following: > python train.py hparams/{hyperparam_file}.yaml Authors * Szu-Wei Fu 2020 """ import os import sys import torch import torchaudio import speechbrain as sb from pesq import pesq...
9,102
33.481061
84
py
speechbrain
speechbrain-main/recipes/Voicebank/enhance/waveform_map/voicebank_prepare.py
../../voicebank_prepare.py
26
26
26
py
speechbrain
speechbrain-main/recipes/Voicebank/enhance/waveform_map/train.py
#!/usr/bin/env/python3 """Recipe for training a waveform-based speech enhancement system with the Voicebank dataset. To run this recipe, do the following: > python train.py hparams/{hyperparam_file}.yaml Authors * Szu-Wei Fu 2020 """ import os import sys import torch import torchaudio import speechbrain as sb from p...
8,228
33.145228
83
py
speechbrain
speechbrain-main/recipes/Voicebank/enhance/MetricGAN-U/voicebank_prepare.py
# -*- coding: utf-8 -*- """ Data preparation. Download and resample, use ``download_vctk`` below. https://datashare.is.ed.ac.uk/handle/10283/2791 Authors: * Szu-Wei Fu, 2020 * Peter Plantinga, 2020 """ import os import json import string import urllib import shutil import logging import tempfile import torchaudio ...
14,812
30.054507
80
py
speechbrain
speechbrain-main/recipes/Voicebank/enhance/MetricGAN-U/train.py
#!/usr/bin/env/python3 """ Recipe for training MetricGAN-U (Unsupervised) with the Voicebank dataset. To run this recipe, do the following: > python train.py hparams/{hyperparam_file}.yaml Authors * Szu-Wei Fu 2021/09 """ import os import sys import shutil import torch import torchaudio import speechbrain as sb imp...
27,522
34.331194
103
py
speechbrain
speechbrain-main/recipes/Voicebank/MTL/ASR_enhance/composite_eval.py
"""Composite objective enhancement scores in Python (CSIG, CBAK, COVL) Taken from https://github.com/facebookresearch/denoiser/blob/master/scripts/matlab_eval.py Authors * adiyoss (https://github.com/adiyoss) """ from scipy.linalg import toeplitz from tqdm import tqdm from pesq import pesq import librosa import nump...
15,193
33.531818
90
py
speechbrain
speechbrain-main/recipes/Voicebank/MTL/ASR_enhance/voicebank_prepare.py
../../voicebank_prepare.py
26
26
26
py
speechbrain
speechbrain-main/recipes/Voicebank/MTL/ASR_enhance/train.py
#!/usr/bin/env python3 """Recipe for multi-task learning, using seq2seq and enhancement objectives. To run this recipe, do the following: > python train.py hparams/{config file} --data_folder /path/to/noisy-vctk There's three provided files for three stages of training: > python train.py hparams/pretrain_perceptual.y...
21,897
37.826241
82
py
speechbrain
speechbrain-main/recipes/Voicebank/ASR/CTC/voicebank_prepare.py
../../voicebank_prepare.py
26
26
26
py
speechbrain
speechbrain-main/recipes/Voicebank/ASR/CTC/train.py
# /usr/bin/env python3 """Recipe for doing ASR with phoneme targets and CTC loss on Voicebank To run this recipe, do the following: > python train.py hparams/{hyperparameter file} --data_folder /path/to/noisy-vctk Use your own hyperparameter file or the provided `hyperparams.yaml` To use noisy inputs, change `input_...
7,651
33.781818
81
py
speechbrain
speechbrain-main/recipes/Voicebank/dereverb/spectral_mask/voicebank_revb_prepare.py
# -*- coding: utf-8 -*- """ Data preparation. First "Manually" Download VoiceBank-SLR [1] from: https://bio-asplab.citi.sinica.edu.tw/Opensource.html#VB-SLR [1] “MetricGAN-U: Unsupervised speech enhancement/ dereverberation based only on noisy/ reverberated speech” Authors: * Szu-Wei Fu, 2020 * Peter Plantinga, 20...
9,316
28.958199
108
py
speechbrain
speechbrain-main/recipes/Voicebank/dereverb/spectral_mask/train.py
#!/usr/bin/env/python3 """Recipe for training a speech enhancement system with the Voicebank dataset. To run this recipe, do the following: > python train.py hparams/{hyperparam_file}.yaml Authors * Szu-Wei Fu 2020 """ import os import sys import torch import torchaudio import speechbrain as sb from pesq import pesq...
9,295
33.686567
84
py
speechbrain
speechbrain-main/recipes/Voicebank/dereverb/MetricGAN-U/voicebank_revb_prepare.py
# -*- coding: utf-8 -*- """ Data preparation. First "Manually" Download VoiceBank-SLR [1] from: https://bio-asplab.citi.sinica.edu.tw/Opensource.html#VB-SLR [1] “MetricGAN-U: Unsupervised speech enhancement/ dereverberation based only on noisy/ reverberated speech” Authors: * Szu-Wei Fu, 2020 * Peter Plantinga, 20...
9,317
28.865385
108
py
speechbrain
speechbrain-main/recipes/Voicebank/dereverb/MetricGAN-U/train.py
#!/usr/bin/env/python3 """ Recipe for training MetricGAN-U (Unsupervised) with the Voicebank dataset. To run this recipe, do the following: > python train.py hparams/{hyperparam_file}.yaml Authors * Szu-Wei Fu 2021/09 """ import os import sys import shutil import torch import torchaudio import speechbrain as sb imp...
28,023
34.60864
103
py
speechbrain
speechbrain-main/recipes/LibriTTS/libritts_prepare.py
from speechbrain.utils.data_utils import get_all_files, download_file from speechbrain.processing.speech_augmentation import Resample import json import os import shutil import random import logging import torchaudio logger = logging.getLogger(__name__) LIBRITTS_URL_PREFIX = "https://www.openslr.org/resources/60/" d...
7,710
33.424107
115
py
speechbrain
speechbrain-main/recipes/LibriTTS/vocoder/hifigan/libritts_prepare.py
../../libritts_prepare.py
25
25
25
py
speechbrain
speechbrain-main/recipes/LibriTTS/vocoder/hifigan/train.py
#!/usr/bin/env python3 """Recipe for training a hifi-gan vocoder. For more details about hifi-gan: https://arxiv.org/pdf/2010.05646.pdf To run this recipe, do the following: > python train.py hparams/train.yaml --data_folder /path/to/LibriTTS Authors * Duret Jarod 2021 * Yingzhi WANG 2022 * Pradnya Kandarkar 2022 ...
15,335
35.688995
90
py
speechbrain
speechbrain-main/recipes/DVoice/dvoice_prepare.py
""" Data preparation. Download: https://dvoice.ma/ Author ------ Abdou Mohamed Naira 2022 """ import os import csv import re import logging import torchaudio import unicodedata from tqdm.contrib import tzip import random import pandas as pd from tqdm import tqdm import numpy as np import glob logger = logging.getLog...
15,401
29.804
80
py
speechbrain
speechbrain-main/recipes/DVoice/ASR/CTC/train_with_wav2vec2.py
#!/usr/bin/env python3 import sys import torch import logging import speechbrain as sb import torchaudio from hyperpyyaml import load_hyperpyyaml from speechbrain.tokenizers.SentencePiece import SentencePiece from speechbrain.utils.data_utils import undo_padding from speechbrain.utils.distributed import run_on_main ""...
14,424
36.273902
105
py
speechbrain
speechbrain-main/recipes/DVoice/ASR/CTC/dvoice_prepare.py
../../dvoice_prepare.py
23
23
23
py
speechbrain
speechbrain-main/tests/__init__.py
""" Availing scripts for testing to be imported, i.e., code in tests/utils. """
80
26
75
py
speechbrain
speechbrain-main/tests/consistency/test_recipe.py
"""Tests for checking the recipes and their files. Authors * Mirco Ravanelli 2022 """ import os import csv from speechbrain.utils.data_utils import get_all_files, get_list_from_csv __skip_list = ["README.md", "setup"] def test_recipe_list( search_folder="recipes", hparam_ext=[".yaml"], hparam_field="H...
6,945
31.157407
104
py
speechbrain
speechbrain-main/tests/consistency/test_yaml.py
"""Consistency check between yaml files and script files. Authors * Mirco Ravanelli 2022 """ import os import csv from tests.consistency.test_recipe import __skip_list from tests.utils.check_yaml import check_yaml_vs_script def test_yaml_script_consistency(recipe_folder="tests/recipes"): """This test checks the...
1,717
30.814815
92
py
speechbrain
speechbrain-main/tests/consistency/test_HF_repo.py
"""Library for the HuggingFace (HF) repositories. Authors * Mirco Ravanelli 2022 * Andreas Nautsch 2022 """ import os import csv from speechbrain.utils.data_utils import download_file def run_HF_check( recipe_folder="tests/recipes", field="HF_repo", output_folder="HF_repos", ): """Checks if the code report...
3,526
27.443548
89
py
speechbrain
speechbrain-main/tests/consistency/test_docstrings.py
"""Tests for checking the docstrings of functions and classes. Authors * Mirco Ravanelli 2022 """ from tests.utils.check_docstrings import check_docstrings def test_recipe_list(base_folder="."): check_folders = ["speechbrain", "tools", "templates"] assert check_docstrings(base_folder, check_folders)
313
25.166667
62
py
speechbrain
speechbrain-main/tests/unittests/test_dataset.py
def test_dynamic_item_dataset(): from speechbrain.dataio.dataset import DynamicItemDataset import operator data = { "utt1": {"foo": -1, "bar": 0, "text": "hello world"}, "utt2": {"foo": 1, "bar": 2, "text": "how are you world"}, "utt3": {"foo": 3, "bar": 4, "text": "where are you wo...
3,451
37.786517
82
py
speechbrain
speechbrain-main/tests/unittests/test_normalization.py
import torch import torch.nn def test_BatchNorm1d(device): from speechbrain.nnet.normalization import BatchNorm1d input = torch.randn(100, 10, device=device) + 2.0 norm = BatchNorm1d(input_shape=input.shape).to(device) output = norm(input) assert input.shape == output.shape current_mean = o...
5,689
28.635417
76
py
speechbrain
speechbrain-main/tests/unittests/test_superpowers.py
import sys import pytest @pytest.mark.skipif( sys.platform.startswith("win"), reason="shell tools not necessarily available on Windows", ) def test_run_shell(): from speechbrain.utils.superpowers import run_shell out, err, code = run_shell("echo -n hello") assert out.decode() == "hello" asser...
684
26.4
71
py
speechbrain
speechbrain-main/tests/unittests/test_core.py
def test_parse_arguments(): from speechbrain.core import parse_arguments filename, run_opts, overrides = parse_arguments( ["params.yaml", "--device=cpu", "--seed=3", "--data_folder", "TIMIT"] ) assert filename == "params.yaml" assert run_opts["device"] == "cpu" assert overrides == "seed...
1,475
35
80
py
speechbrain
speechbrain-main/tests/unittests/test_samplers.py
import torch def test_ConcatDatasetBatchSampler(device): from torch.utils.data import TensorDataset, ConcatDataset, DataLoader from speechbrain.dataio.sampler import ( ReproducibleRandomSampler, ConcatDatasetBatchSampler, ) import numpy as np datasets = [] for i in range(3): ...
1,418
27.959184
80
py
speechbrain
speechbrain-main/tests/unittests/test_pretrainer.py
def test_pretrainer(tmpdir, device): import torch from torch.nn import Linear # save a model in tmpdir/original/model.ckpt first_model = Linear(32, 32).to(device) pretrained_dir = tmpdir / "original" pretrained_dir.mkdir() with open(pretrained_dir / "model.ckpt", "wb") as fo: torch....
843
35.695652
79
py
speechbrain
speechbrain-main/tests/unittests/test_dropout.py
import torch import torch.nn def test_dropout(device): from speechbrain.nnet.dropout import Dropout2d inputs = torch.rand([4, 10, 32], device=device) drop = Dropout2d(drop_rate=0.0).to(device) outputs = drop(inputs) assert torch.all(torch.eq(inputs, outputs)) drop = Dropout2d(drop_rate=1.0)...
497
22.714286
67
py
speechbrain
speechbrain-main/tests/unittests/test_augment.py
import os import torch from speechbrain.dataio.dataio import write_audio def test_add_noise(tmpdir, device): from speechbrain.processing.speech_augmentation import AddNoise # Test concatenation of batches wav_a = torch.sin(torch.arange(8000.0, device=device)).unsqueeze(0) a_len = torch.ones(1, device...
8,419
38.345794
80
py
speechbrain
speechbrain-main/tests/unittests/test_categorical_encoder.py
import pytest def test_categorical_encoder(device): from speechbrain.dataio.encoder import CategoricalEncoder encoder = CategoricalEncoder() encoder.update_from_iterable("abcd") integers = encoder.encode_sequence("dcba") assert all(isinstance(i, int) for i in integers) assert encoder.is_conti...
8,005
35.557078
80
py
speechbrain
speechbrain-main/tests/unittests/test_counting.py
def test_pad_ends(): from speechbrain.lm.counting import pad_ends assert next(pad_ends(["a", "b", "c"])) == "<s>" assert next(pad_ends(["a", "b", "c"], pad_left=False)) == "a" assert list(pad_ends(["a", "b", "c"], pad_left=False))[-1] == "</s>" assert list(pad_ends([], pad_left=False)) assert l...
1,040
33.7
75
py
speechbrain
speechbrain-main/tests/unittests/test_edit_distance.py
def test_accumulatable_wer_stats(): from speechbrain.utils.edit_distance import accumulatable_wer_stats refs = [[[1, 2, 3], [4, 5, 6]], [[7, 8], [9]]] hyps = [[[1, 2, 4], [5, 6]], [[7, 8], [10]]] # Test basic functionality: stats = accumulatable_wer_stats(refs[0], hyps[0]) assert stats["WER"] =...
2,313
35.730159
71
py
speechbrain
speechbrain-main/tests/unittests/test_RNN.py
import torch import torch.nn from collections import OrderedDict def test_RNN(device): from speechbrain.nnet.RNN import RNN, GRU, LSTM, LiGRU, QuasiRNN, RNNCell # Check RNN inputs = torch.randn(4, 2, 7, device=device) net = RNN( hidden_size=5, input_shape=inputs.shape, num_la...
5,091
29.130178
79
py
speechbrain
speechbrain-main/tests/unittests/test_features.py
import torch def test_deltas(device): from speechbrain.processing.features import Deltas size = torch.Size([10, 101, 20], device=device) inp = torch.ones(size, device=device) compute_deltas = Deltas(input_size=20).to(device) out = torch.zeros(size, device=device) assert torch.sum(compute_del...
4,139
30.12782
72
py
speechbrain
speechbrain-main/tests/unittests/test_profiling.py
def test_profile_class(device): import torch from torch.optim import SGD from speechbrain.core import Brain from speechbrain.utils.profiling import profile @profile class SimpleBrain(Brain): def compute_forward(self, batch, stage): return self.modules.model(batch[0]) ...
81,815
78.820488
185
py
speechbrain
speechbrain-main/tests/unittests/test_multi_mic.py
import torch def test_gccphat(device): from speechbrain.processing.features import STFT from speechbrain.processing.multi_mic import Covariance, GccPhat # Creating the test signal fs = 16000 delay = 60 sig = torch.randn([10, fs], device=device) sig_delayed = torch.cat( (torch.z...
916
24.472222
70
py
speechbrain
speechbrain-main/tests/unittests/test_signal_processing.py
import torch def test_normalize(device): from speechbrain.processing.signal_processing import compute_amplitude from speechbrain.processing.signal_processing import rescale import random import numpy as np for scale in ["dB", "linear"]: for amp_type in ["peak", "avg"]: for te...
1,035
32.419355
77
py
speechbrain
speechbrain-main/tests/unittests/test_checkpoints.py
import pytest def test_checkpointer(tmpdir, device): from speechbrain.utils.checkpoints import Checkpointer import torch class Recoverable(torch.nn.Module): def __init__(self, param): super().__init__() self.param = torch.nn.Parameter(torch.tensor([param])) def fo...
14,332
35.940722
93
py
speechbrain
speechbrain-main/tests/unittests/test_embedding.py
import torch def test_embedding(device): from speechbrain.nnet.embedding import Embedding # create one hot vector and consider blank as zero vector embedding_dim = 39 blank_id = 39 size_dict = 40 emb = Embedding( num_embeddings=size_dict, consider_as_one_hot=True, blank_id=blank_id ...
783
26.034483
78
py
speechbrain
speechbrain-main/tests/unittests/test_ngram_lm.py
def test_backofff_ngram_lm(): from speechbrain.lm.ngram import BackoffNgramLM import math HALF = math.log(0.5) ngrams = { 1: {tuple(): {"a": HALF, "b": HALF}}, 2: {("a",): {"a": HALF, "b": HALF}, ("b",): {"a": HALF}}, } backoffs = {1: {("b",): 0.0}} lm = BackoffNgramLM(ngram...
901
32.407407
65
py
speechbrain
speechbrain-main/tests/unittests/test_epoch_loop.py
def test_epoch_loop_recovery(tmpdir): from speechbrain.utils.checkpoints import Checkpointer from speechbrain.utils.epoch_loop import EpochCounter epoch_counter = EpochCounter(2) recoverer = Checkpointer(tmpdir, {"epoch": epoch_counter}) for epoch in epoch_counter: assert epoch == 1 ...
1,315
32.74359
62
py
speechbrain
speechbrain-main/tests/unittests/test_dependency_graph.py
import pytest def test_dependency_graph(): from speechbrain.utils.depgraph import ( DependencyGraph, CircularDependencyError, ) dg = DependencyGraph() # a->b->c dg.add_edge("b", "c") dg.add_edge("a", "b") assert dg.is_valid() eval_order = [node.key for node in dg.get_e...
2,357
30.026316
73
py
speechbrain
speechbrain-main/tests/unittests/test_activations.py
import torch import torch.nn def test_softmax(device): from speechbrain.nnet.activations import Softmax inputs = torch.tensor([1, 2, 3], device=device).float() act = Softmax(apply_log=False) outputs = act(inputs) assert torch.argmax(outputs) == 2 assert torch.jit.trace(act, inputs)
312
19.866667
59
py
speechbrain
speechbrain-main/tests/unittests/test_batching.py
import pytest import torch import numpy as np def test_batch_pad_right_to(device): from speechbrain.utils.data_utils import batch_pad_right import random n_channels = 40 batch_lens = [1, 5] for b in batch_lens: rand_lens = [random.randint(10, 53) for x in range(b)] tensors = [ ...
2,404
28.329268
77
py