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/recipes/LJSpeech/TTS/tacotron2/train.py
# -*- coding: utf-8 -*- """ Recipe for training the Tacotron Text-To-Speech model, an end-to-end neural text-to-speech (TTS) system To run this recipe, do the following: # python train.py --device=cuda:0 --max_grad_norm=1.0 --data_folder=/your_folder/LJSpeech-1.1 hparams/train.yaml to infer simply load saved mod...
13,447
32.53616
113
py
speechbrain
speechbrain-main/recipes/LJSpeech/TTS/vocoder/hifi_gan/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/LJspeech Authors * Duret Jarod 2021 * Yingzhi WANG 2022 """ import sys import tor...
14,460
34.618227
90
py
speechbrain
speechbrain-main/recipes/Fisher-Callhome-Spanish/fisher_callhome_prepare.py
""" Data preparation Author ----- YAO-FEI, CHENG 2021 """ import os import re import json import string import logging import subprocess from typing import List from dataclasses import dataclass, field import torch import torchaudio from tqdm import tqdm from speechbrain.utils.data_utils import get_all_files from ...
25,525
33.682065
114
py
speechbrain
speechbrain-main/recipes/Fisher-Callhome-Spanish/ST/transformer/train.py
#!/usr/bin/env/python3 """Recipe for training a Transformer based ST system with Fisher-Callhome. 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 hpara...
23,243
35.778481
91
py
speechbrain
speechbrain-main/recipes/UrbanSound8k/urbansound8k_prepare.py
""" Creates data manifest files from UrbanSound8k, suitable for use in SpeechBrain. https://urbansounddataset.weebly.com/urbansound8k.html From the authors of UrbanSound8k: 1. Don't reshuffle the data! Use the predefined 10 folds and perform 10-fold (not 5-fold) cross validation The experiments conducted by vast maj...
14,774
37.476563
122
py
speechbrain
speechbrain-main/recipes/UrbanSound8k/SoundClassification/custom_model.py
""" This file contains a very simple TDNN module to use for sound class identification. 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 * David Whipps 2021 * Ala Eddine Limame 2021 Adapted...
5,731
29.489362
83
py
speechbrain
speechbrain-main/recipes/UrbanSound8k/SoundClassification/train.py
#!/usr/bin/python3 """Recipe for training sound class embeddings (e.g, xvectors) using the UrbanSound8k. We employ an encoder followed by a sound classifier. To run this recipe, use the following command: > python train_class_embeddings.py {hyperparameter_file} Using your own hyperparameter file or one of the followi...
16,914
36.175824
115
py
speechbrain
speechbrain-main/recipes/CommonLanguage/common_language_prepare.py
""" Data preparation of CommonLangauge dataset for LID. Download: https://zenodo.org/record/5036977#.YNo1mHVKg5k Author ------ Pavlo Ruban 2021 """ import os import csv import logging import torchaudio from tqdm.contrib import tzip from speechbrain.utils.data_utils import get_all_files logger = logging.getLogger(__...
7,969
24.876623
94
py
speechbrain
speechbrain-main/recipes/CommonLanguage/lang_id/train.py
#!/usr/bin/env python3 import os import sys import torch import logging import torchaudio import speechbrain as sb from hyperpyyaml import load_hyperpyyaml from common_language_prepare import prepare_common_language """Recipe for training a LID system with CommonLanguage. To run this recipe, do the following: > pytho...
10,881
33.328076
80
py
speechbrain
speechbrain-main/recipes/Aishell1Mix/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,142
30.46696
93
py
speechbrain
speechbrain-main/recipes/Aishell1Mix/separation/train.py
#!/usr/bin/env/python3 """Recipe for training a neural speech separation system on Aishell1Mix2/3 datasets. The system employs an encoder, a decoder, and a masking network. To run this recipe, do the following: > python train.py hparams/sepformer-aishell1mix2.yaml > python train.py hparams/sepformer-aishell1mix3.yaml ...
25,295
36.090909
108
py
speechbrain
speechbrain-main/recipes/Aishell1Mix/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,781
27.10101
80
py
speechbrain
speechbrain-main/recipes/LibriSpeech/librispeech_prepare.py
""" Data preparation. Download: http://www.openslr.org/12 Author ------ Mirco Ravanelli, Ju-Chieh Chou, Loren Lugosch 2020 """ import os import csv import random from collections import Counter import logging import torchaudio from tqdm.contrib import tzip from speechbrain.utils.data_utils import download_file, get_...
12,515
27.905312
87
py
speechbrain
speechbrain-main/recipes/LibriSpeech/LM/train.py
#!/usr/bin/env python3 """Recipe for training a Language Model with librispeech train-960 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-Chieh Cho...
7,083
31.645161
94
py
speechbrain
speechbrain-main/recipes/LibriSpeech/G2P/evaluate.py
"""Recipe for evaluating a grapheme-to-phoneme system with librispeech lexicon. The script may be use in isolation or in combination with Orion to fit hyperparameters that do not require model retraining (e.g. Beam Search) """ from hyperpyyaml import load_hyperpyyaml from speechbrain.dataio.batch import PaddedBatch f...
14,699
34.083532
88
py
speechbrain
speechbrain-main/recipes/LibriSpeech/G2P/train_lm.py
#!/usr/bin/env python3 """Recipe for training a language model with a phoneme model. > 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 * Artem Ploujnikov 2021 """ im...
7,998
30.996
80
py
speechbrain
speechbrain-main/recipes/LibriSpeech/G2P/train.py
#!/usr/bin/env/python3 """Recipe for training a grapheme-to-phoneme system with one of the available datasets. See README.md for more details Authors * Loren Lugosch 2020 * Mirco Ravanelli 2020 * Artem Ploujnikov 2021 """ from speechbrain.dataio.dataset import ( FilteredSortedDynamicItemDataset, DynamicIte...
43,545
32.887938
87
py
speechbrain
speechbrain-main/recipes/LibriSpeech/self-supervised-learning/wav2vec2/train_sb_wav2vec2.py
#!/usr/bin/env python3 """Recipe for pretraining wav2vec2 (https://arxiv.org/abs/2006.11477). See config file for model definition. See the readme of the recipe for advices on the pretraining that may appear a bit challenging depending on your available resources. To run this recipe call python train.py hparams/train_...
13,411
33.836364
111
py
speechbrain
speechbrain-main/recipes/LibriSpeech/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,705
38.124122
89
py
speechbrain
speechbrain-main/recipes/LibriSpeech/ASR/seq2seq/train.py
#!/usr/bin/env/python3 """Recipe for training a sequence-to-sequence ASR system with librispeech. The system employs an encoder, a decoder, and an attention mechanism between them. Decoding is performed with beamsearch coupled with a neural language model. To run this recipe, do the following: > python train.py hparam...
15,618
35.92435
89
py
speechbrain
speechbrain-main/recipes/LibriSpeech/ASR/CTC/train_with_wav2vec.py
#!/usr/bin/env/python3 """Recipe for training a wav2vec-based ctc ASR system with librispeech. The system employs wav2vec as its encoder. Decoding is performed with ctc greedy decoder. To run this recipe, do the following: > python train_with_wav2vec.py hparams/train_{hf,sb}_wav2vec.yaml The neural network is trained o...
16,312
36.415138
89
py
speechbrain
speechbrain-main/recipes/LibriSpeech/ASR/CTC/train_with_whisper.py
#!/usr/bin/env/python3 """Recipe for training a whisper-based ctc ASR system with librispeech. The system employs whisper from OpenAI (https://cdn.openai.com/papers/whisper.pdf). This recipe take only the whisper encoder and add a DNN + CTC to fine-tune. If you want to use the full whisper system, please refer to the ...
13,226
35.238356
89
py
speechbrain
speechbrain-main/recipes/LibriSpeech/ASR/transformer/train.py
#!/usr/bin/env python3 """Recipe for training a Transformer ASR system with librispeech. 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...
19,105
36.171206
105
py
speechbrain
speechbrain-main/recipes/LibriSpeech/ASR/transformer/train_with_whisper.py
#!/usr/bin/env python3 """Recipe for training a whisper-based ASR system with librispeech. The system employs whisper from OpenAI (https://cdn.openai.com/papers/whisper.pdf). This recipe take the whisper encoder-decoder to fine-tune on the NLL. If you want to only use the whisper encoder system, please refer to the re...
11,771
34.457831
89
py
speechbrain
speechbrain-main/recipes/MEDIA/SLU/CTC/train_hf_wav2vec.py
#!/usr/bin/env python3 """ Recipe for training a CTC based SLU system with Media. The system employs a wav2vec2 model and a decoder. To run this recipe, do the following: > python train_with_wav2vec.py hparams/train_with_wav2vec.yaml With the default hyperparameters, the system employs a VanillaNN encoder. The neur...
13,866
34.284987
83
py
speechbrain
speechbrain-main/recipes/MEDIA/ASR/CTC/train_hf_wav2vec.py
#!/usr/bin/env python3 """ Recipe for training a CTC based ASR system with Media. The system employs a wav2vec2 model and a decoder. To run this recipe, do the following: > python train_with_wav2vec.py hparams/train_with_wav2vec.yaml With the default hyperparameters, the system employs a VanillaNN encoder. The neur...
12,920
33.827493
83
py
speechbrain
speechbrain-main/recipes/REAL-M/sisnr-estimation/train.py
#!/usr/bin/env/python3 """ Recipe for training a Blind SI-SNR estimator Authors: * Cem Subakan 2021 * Mirco Ravanelli 2021 * Samuele Cornell 2021 """ import os import sys import torch import speechbrain as sb import speechbrain.nnet.schedulers as schedulers from speechbrain.utils.distributed import run_on_main fro...
29,744
35.631773
152
py
speechbrain
speechbrain-main/recipes/WHAMandWHAMR/separation/dynamic_mixing.py
import speechbrain as sb import numpy as np import torch import torchaudio import glob import os from pathlib import Path import random from speechbrain.processing.signal_processing import rescale from speechbrain.dataio.batch import PaddedBatch """ The functions to implement Dynamic Mixing For SpeechSeparation Autho...
7,212
30.915929
107
py
speechbrain
speechbrain-main/recipes/WHAMandWHAMR/separation/train.py
#!/usr/bin/env/python3 """Recipe for training a neural speech separation system on WHAM! and WHAMR! datasets. The system employs an encoder, a decoder, and a masking network. To run this recipe, do the following: > python train.py hparams/sepformer-wham.yaml --data_folder /your_path/wham_original > python train.py hpa...
25,297
36.039531
108
py
speechbrain
speechbrain-main/recipes/WHAMandWHAMR/meta/create_whamr_rirs.py
""" Adapted from the original WHAMR script to obtain the Room Impulse ResponsesRoom Impulse Responses Authors * Cem Subakan 2021 """ import os import pandas as pd import argparse import torchaudio from wham_room import WhamRoom from scipy.signal import resample_poly import torch from speechbrain.pretrained.fetchi...
4,052
27.542254
97
py
speechbrain
speechbrain-main/recipes/WHAMandWHAMR/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/WHAMandWHAMR/enhancement/dynamic_mixing.py
import speechbrain as sb import numpy as np import torch import torchaudio import glob import os from pathlib import Path import random from speechbrain.processing.signal_processing import rescale from speechbrain.dataio.batch import PaddedBatch """ The functions to implement Dynamic Mixing For SpeechSeparation Autho...
7,223
30.964602
107
py
speechbrain
speechbrain-main/recipes/WHAMandWHAMR/enhancement/train.py
#!/usr/bin/env/python3 """Recipe for training a neural speech separation system on WHAM! and WHAMR! datasets. The system employs an encoder, a decoder, and a masking network. To run this recipe, do the following: > python train.py hparams/sepformer-wham.yaml --data_folder /your_path/wham_original > python train.py hpa...
29,072
36.465206
108
py
speechbrain
speechbrain-main/recipes/LibriParty/VAD/commonlanguage_prepare.py
import os import logging import torchaudio import speechbrain as sb from speechbrain.utils.data_utils import get_all_files logger = logging.getLogger(__name__) COMMON_LANGUAGE_URL = ( "https://zenodo.org/record/5036977/files/CommonLanguage.tar.gz?download=1" ) def prepare_commonlanguage(folder, csv_file, max_no...
3,586
36.757895
78
py
speechbrain
speechbrain-main/recipes/LibriParty/VAD/data_augment.py
"""This library is used to create data on-the-fly for VAD. Authors * Mirco Ravanelli 2020 """ import torch import torchaudio import random # fade-in/fade-out definition fade_in = torchaudio.transforms.Fade(fade_in_len=1000, fade_out_len=0) fade_out = torchaudio.transforms.Fade(fade_in_len=0, fade_out_len=1000) de...
13,096
29.45814
83
py
speechbrain
speechbrain-main/recipes/LibriParty/VAD/musan_prepare.py
import os import logging import torchaudio import speechbrain as sb from speechbrain.utils.data_utils import get_all_files logger = logging.getLogger(__name__) def prepare_musan(folder, music_csv, noise_csv, speech_csv, max_noise_len=None): """Prepare the musan dataset (music, noise, speech). Arguments ...
3,700
37.154639
80
py
speechbrain
speechbrain-main/recipes/LibriParty/VAD/train.py
#!/usr/bin/env python3 """ Recipe for training a Voice Activity Detection (VAD) model on LibriParty. This code heavily relis on data augmentation with external datasets. (e.g, open_rir, musan, CommonLanguge is used as well). Make sure you download all the datasets before staring the experiment: - LibriParty: https://d...
9,259
30.931034
96
py
speechbrain
speechbrain-main/recipes/LibriParty/generate_dataset/local/resample_folder.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 a...
2,091
29.318841
79
py
speechbrain
speechbrain-main/recipes/LibriParty/generate_dataset/local/create_mixtures_metadata.py
""" This file contains functions to create json metadata used to create mixtures which simulate a multi-party conversation in a noisy scenario. Author ------ Samuele Cornell, 2020 """ import numpy as np from pathlib import Path import json import os from tqdm import tqdm import torchaudio def _read_metadata(file_p...
7,619
35.285714
80
py
speechbrain
speechbrain-main/recipes/LibriParty/generate_dataset/local/create_mixtures_from_metadata.py
""" This file contains functions to create mixtures given json metadata. The mixtures simulate a multi-party conversation in a noisy scenario. Author ------ Samuele Cornell, 2020 """ import os import torch import json import numpy as np import torchaudio from speechbrain.processing.signal_processing import rescale, ...
6,540
33.246073
80
py
speechbrain
speechbrain-main/recipes/WSJ0Mix/separation/dynamic_mixing.py
import speechbrain as sb import numpy as np import torch import torchaudio import glob import os from pathlib import Path import random from speechbrain.processing.signal_processing import rescale from speechbrain.dataio.batch import PaddedBatch """ The functions to implement Dynamic Mixing For SpeechSeparation Autho...
7,309
32.378995
93
py
speechbrain
speechbrain-main/recipes/WSJ0Mix/separation/train.py
#!/usr/bin/env/python3 """Recipe for training a neural speech separation system on 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/sepformer.yaml > python train.py hparams/dualpath_rnn.yaml > python train.py hparams/co...
23,418
35.706897
108
py
speechbrain
speechbrain-main/recipes/WSJ0Mix/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/VoxCeleb/voxceleb_prepare.py
""" Data preparation. Download: http://www.robots.ox.ac.uk/~vgg/data/voxceleb/ """ import os import csv import logging import glob import random import shutil import sys # noqa F401 import numpy as np import torch import torchaudio from tqdm.contrib import tqdm from speechbrain.dataio.dataio import ( load_pkl, ...
16,001
29.192453
103
py
speechbrain
speechbrain-main/recipes/VoxCeleb/SpeakerRec/train_speaker_embeddings.py
#!/usr/bin/python3 """Recipe for training speaker embeddings (e.g, xvectors) using the VoxCeleb Dataset. We employ an encoder followed by a speaker classifier. To run this recipe, use the following command: > python train_speaker_embeddings.py {hyperparameter_file} Using your own hyperparameter file or one of the fol...
8,833
33.108108
85
py
speechbrain
speechbrain-main/recipes/VoxCeleb/SpeakerRec/speaker_verification_cosine.py
#!/usr/bin/python3 """Recipe for training a speaker verification system based on cosine distance. The cosine distance is computed on the top of pre-trained embeddings. The pre-trained model is automatically downloaded from the web if not specified. This recipe is designed to work on a single GPU. To run this recipe, r...
9,905
33.515679
85
py
speechbrain
speechbrain-main/recipes/VoxCeleb/SpeakerRec/speaker_verification_plda.py
#!/usr/bin/python3 """Recipe for training a speaker verification system based on PLDA using the voxceleb dataset. The system employs a pre-trained model followed by a PLDA transformation. The pre-trained model is automatically downloaded from the web if not specified. To run this recipe, run the following command: ...
12,496
32.414439
94
py
speechbrain
speechbrain-main/recipes/TIMIT/ASR/transducer/train_wav2vec.py
#!/usr/bin/env/python3 """Recipe for training a phoneme recognizer with Transducer loss on the TIMIT dataset. To run this recipe, do the following: > python train.py hparams/train.yaml --data_folder /path/to/TIMIT Authors * Abdel Heba 2020 * Mirco Ravanelli 2020 * Ju-Chieh Chou 2020 """ import os import sys impor...
12,544
32.632708
83
py
speechbrain
speechbrain-main/recipes/TIMIT/ASR/transducer/train.py
#!/usr/bin/env/python3 """Recipe for training a phoneme recognizer with Transducer loss on the TIMIT dataset. To run this recipe, do the following: > python train.py hparams/train.yaml --data_folder /path/to/TIMIT Authors * Abdel Heba 2020 * Mirco Ravanelli 2020 * Ju-Chieh Chou 2020 """ import os import sys impor...
10,118
33.301695
83
py
speechbrain
speechbrain-main/recipes/TIMIT/ASR/seq2seq_knowledge_distillation/train_kd.py
#!/usr/bin/env python3 """Recipe for doing ASR with phoneme targets and joint seq2seq and CTC loss on the TIMIT dataset following a knowledge distillation scheme as reported in " Distilling Knowledge from Ensembles of Acoustic Models for Joint CTC-Attention End-to-End Speech Recognition", Yan Gao et al. To run this r...
18,522
34.081439
81
py
speechbrain
speechbrain-main/recipes/TIMIT/ASR/seq2seq_knowledge_distillation/save_teachers.py
#!/usr/bin/env python3 """Recipe for doing ASR with phoneme targets and joint seq2seq and CTC loss on the TIMIT dataset following a knowledge distillation scheme as reported in " Distilling Knowledge from Ensembles of Acoustic Models for Joint CTC-Attention End-to-End Speech Recognition", Yan Gao et al. To run this r...
14,025
34.329975
152
py
speechbrain
speechbrain-main/recipes/TIMIT/ASR/seq2seq_knowledge_distillation/train_teacher.py
#!/usr/bin/env python3 """Recipe for doing ASR with phoneme targets and joint seq2seq and CTC loss on the TIMIT dataset following a knowledge distillation scheme as reported in " Distilling Knowledge from Ensembles of Acoustic Models for Joint CTC-Attention End-to-End Speech Recognition", Yan Gao et al. To run this re...
11,903
34.323442
80
py
speechbrain
speechbrain-main/recipes/TIMIT/ASR/seq2seq/train_with_wav2vec2.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...
13,829
33.575
83
py
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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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_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_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