### Run HuBERT Pre-training (First Iteration) Source: https://github.com/pytorch/audio/blob/main/examples/self_supervised_learning/README.md Execute the SLURM command to start the first iteration of HuBERT pre-training. Ensure you have generated K-Means labels beforehand and are in the 'examples' directory. Adjust dataset path, experiment directory, and training parameters as needed. ```bash cd examples srun \ --gpus-per-node=8 \ --ntasks-per-node=8 \ -N 4 \ --cpus-per-task=10 \ python -m self_supervised_learning.train_hubert \ --dataset-path hubert/exp/data/mfcc/ \ --exp-dir self_supervised_learning/exp_iter1 \ --feature-type mfcc \ --num-class 100 \ --max-updates 250000 \ --learning-rate 0.0005 \ --gpus 8 \ --num-nodes 4 ``` -------------------------------- ### Check TorchAudio Installation Source: https://github.com/pytorch/audio/blob/main/docs/source/build.jetson.rst Import the torchaudio library and print its version to confirm a successful installation. ```python import torchaudio print(torchaudio.__version__) ``` -------------------------------- ### Install Face Detection from GitHub Source: https://github.com/pytorch/audio/blob/main/examples/avsr/data_prep/tools/README.md Use this method to install the library directly from its GitHub repository. Ensure Git LFS is installed for handling large files. This installs the package in editable mode. ```Shell git clone https://github.com/hhj1897/face_detection.git cd face_detection git lfs pull pip install -e . cd .. ``` -------------------------------- ### Install Additional Dependencies Source: https://github.com/pytorch/audio/blob/main/examples/asr/librispeech_conformer_rnnt_biasing/README.md Installs necessary Python packages for the project. Ensure PyTorch and TorchAudio are installed with GPU support. ```bash pip install pytorch-lightning sentencepiece ``` -------------------------------- ### Install Additional Dependencies Source: https://github.com/pytorch/audio/blob/main/examples/asr/librispeech_conformer_rnnt/README.md Installs necessary Python packages for training and evaluation. Ensure PyTorch and TorchAudio are installed nightly or from source with GPU support. ```bash pip install pytorch-lightning sentencepiece tensorboard ``` -------------------------------- ### Install Dependencies Source: https://github.com/pytorch/audio/blob/main/examples/avsr/data_prep/README.md Installs all required dependency packages for the project. Ensure you have the `requirements.txt` file in your current directory. ```Shell pip install -r requirements.txt ``` -------------------------------- ### Install Dependencies Source: https://github.com/pytorch/audio/blob/main/examples/avsr/README.md Installs PyTorch and other necessary packages for the project. Ensure PyTorch is installed from source if needed. ```Shell pip install torch torchvision torchaudio pytorch-lightning sentencepiece ``` -------------------------------- ### Install Build Tools for TorchAudio Source: https://github.com/pytorch/audio/blob/main/docs/source/build.jetson.rst Install the 'ninja' build system, which is required for building TorchAudio. ```bash pip install ninja ``` -------------------------------- ### Install pip in User Environment Source: https://github.com/pytorch/audio/blob/main/docs/source/build.jetson.rst Download and run the get-pip.py script to install pip in the user's home directory. This avoids permission issues when installing packages. ```bash wget https://bootstrap.pypa.io/get-pip.py python get-pip.py --user ``` -------------------------------- ### Install TensorBoard Support Source: https://github.com/pytorch/audio/blob/main/examples/pipeline_tacotron2/README.md Installs packages required for using TensorBoard to visualize training metrics and results. ```bash pip install tensorboard pillow ``` -------------------------------- ### Build Documentation with Tutorials Source: https://github.com/pytorch/audio/blob/main/CONTRIBUTING.md Installs additional requirements and builds the documentation including tutorials, which can be time-consuming. ```bash pip install -r requirements-tutorials.txt BUILD_GALLERY=1 make html ``` -------------------------------- ### Install sentencepiece and download pretrained files Source: https://github.com/pytorch/audio/blob/main/examples/asr/librispeech_cuda_ctc_decoder/README.md Installs the sentencepiece library and downloads necessary pretrained model files for the speech recognition inference script. ```bash pip install sentencepiece # download pretrained files wget -nc https://huggingface.co/Zengwei/icefall-asr-librispeech-pruned-transducer-stateless7-ctc-2022-12-01/resolve/main/data/lang_bpe_500/bpe.model wget -nc https://huggingface.co/Zengwei/icefall-asr-librispeech-pruned-transducer-stateless7-ctc-2022-12-01/resolve/main/exp/cpu_jit.pt ``` -------------------------------- ### Build Documentation Source: https://github.com/pytorch/audio/blob/main/CONTRIBUTING.md Commands to build the HTML documentation locally after installing requirements. ```bash cd docs make html ``` -------------------------------- ### Build and Install TorchAudio Source: https://github.com/pytorch/audio/blob/main/docs/source/build.jetson.rst Clone the TorchAudio repository, navigate into the directory, and install it in editable mode using pip, enabling CUDA support. The '-v' flag provides verbose output during installation. ```bash git clone https://github.com/pytorch/audio cd audio USE_CUDA=1 pip install -v -e . --no-use-pep517 ``` -------------------------------- ### Install TorchAudio Dependencies Source: https://github.com/pytorch/audio/blob/main/docs/source/build.jetson.rst Install the necessary FFmpeg development libraries required for building TorchAudio. ```bash sudo apt install libavformat-dev libavcodec-dev libavutil-dev libavdevice-dev libavfilter-dev ``` -------------------------------- ### Install Face Detection from Compressed Files Source: https://github.com/pytorch/audio/blob/main/examples/avsr/data_prep/tools/README.md Use this method if you encounter over-quota issues with GitHub repositories. Download the zip file, extract it, and then install the package in editable mode. ```Shell wget https://www.doc.ic.ac.uk/~pm4115/tracker/face_detection.zip -O ./face_detection.zip unzip -o ./face_detection.zip -d ./ cd face_detection pip install -e . cd .. ``` -------------------------------- ### Install Ninja Build Tool Source: https://github.com/pytorch/audio/blob/main/docs/source/build.linux.rst Installs the Ninja build system, which is a required dependency for building torchaudio. ```bash conda install ninja ``` -------------------------------- ### Install Testing Dependencies Source: https://github.com/pytorch/audio/blob/main/CONTRIBUTING.md Installs the necessary Python packages for running tests in Torchaudio. ```bash pip install typing pytest scipy numpy parameterized ``` -------------------------------- ### Build Documentation Requirements Source: https://github.com/pytorch/audio/blob/main/CONTRIBUTING.md Installs the Python package requirements for building the documentation locally. ```bash cd docs pip install -r requirements.txt ``` -------------------------------- ### Check Installed JetPack Version Source: https://github.com/pytorch/audio/blob/main/docs/source/build.jetson.rst Verify the installed version of the nvidia-jetpack package. ```bash # JetPack $ apt list --installed | grep nvidia-jetpack ``` -------------------------------- ### Install PyTorch Nightly Build Source: https://github.com/pytorch/audio/blob/main/docs/source/build.linux.rst Installs the nightly build of PyTorch for CPU. Ensure you have selected the desired PyTorch version from their official website. ```bash pip install --pre --index-url https://download.pytorch.org/whl/nightly/cpu ``` -------------------------------- ### Check Installed CUDA Toolkit Version Source: https://github.com/pytorch/audio/blob/main/docs/source/build.jetson.rst Verify the installed version of the CUDA toolkit. ```bash # CUDA $ apt list --installed | grep cuda-toolkit ``` -------------------------------- ### Build Libtorchaudio and Applications Source: https://github.com/pytorch/audio/blob/main/examples/libtorchaudio/README.md These commands are used to build libtorchaudio and its associated applications. Ensure you have a working PyTorch installation and follow the steps to clone submodules, create a build directory, and configure CMake with the correct prefix path. ```bash git submodule update mkdir build cd build cmake -GNinja \ -DCMAKE_PREFIX_PATH="$(python -c 'import torch;print(torch.utils.cmake_prefix_path)')" \ -DBUILD_RNNT=ON \ .. cmake --build . ``` -------------------------------- ### Install Required Packages for Tacotron2 Source: https://github.com/pytorch/audio/blob/main/examples/pipeline_tacotron2/README.md Installs essential libraries for running the Tacotron2 pipeline, including librosa for audio processing, tqdm for progress bars, inflect for number-to-word conversion, and joblib for parallel processing. ```bash pip install librosa tqdm inflect joblib ``` -------------------------------- ### Install DeepPhonemizer for Phoneme Input Source: https://github.com/pytorch/audio/blob/main/examples/pipeline_tacotron2/README.md Installs the DeepPhonemizer package, version 0.0.15, which is used as the phonemizer for converting text to phonemes in the Tacotron2 training pipeline. ```bash pip install deep-phonemizer==0.0.15 ``` -------------------------------- ### Add NVIDIA Jetson Repository and Install JetPack Source: https://github.com/pytorch/audio/blob/main/docs/source/build.jetson.rst Add the NVIDIA Jetson repository to your system's sources and update the package list. Then, upgrade existing packages and install the JetPack meta-package. A reboot is required after this step. ```bash sudo bash -c 'echo "deb https://repo.download.nvidia.com/jetson/common r34.1 main" >> /etc/apt/sources.list.d/nvidia-l4t-apt-source.list' sudo bash -c 'echo "deb https://repo.download.nvidia.com/jetson/t234 r34.1 main" >> /etc/apt/sources.list.d/nvidia-l4t-apt-source.list' sudo apt update sudo apt dist-upgrade # REBOOT sudo apt install nvidia-jetpack ``` -------------------------------- ### Generate Audio with Torchaudio Pretrained Models Source: https://github.com/pytorch/audio/blob/main/examples/pipeline_tacotron2/README.md This example demonstrates generating audio using specific torchaudio pretrained checkpoints for both Tacotron2 and WaveRNN. It specifies the checkpoint names and requires DeepPhonemizer for phoneme preprocessing. ```bash python inference.py \ --checkpoint-path tacotron2_english_phonemes_1500_epochs_wavernn_ljspeech \ --wavernn-checkpoint-path wavernn_10k_epochs_8bits_ljspeech \ --vocoder wavernn \ --n-fft 2048 \ --mel-fmin 40 \ --mel-fmax 11025 \ --input-text "Hello world!" \ --text-preprocessor english_phonemes \ --phonimizer DeepPhonemizer \ --phoimizer-checkpoint ./en_us_cmudict_forward.pt \ --cmudict-root ./ \ --output-path "./outputs.wav" ``` -------------------------------- ### torchaudio.datasets.LIBRISPEECH Dataset Example Source: https://context7.com/pytorch/audio/llms.txt Example of using the LIBRISPEECH dataset. It automatically downloads and caches the data. The dataset returns tuples of (waveform, sample_rate, utterance, speaker_id, chapter_id, utterance_id). ```python import torchaudio from torch.utils.data import DataLoader # Downloads to ./data/LibriSpeech/train-clean-100 dataset = torchaudio.datasets.LIBRISPEECH( root="./data", url="train-clean-100", download=True, ) print(f"Utterances: {len(dataset)}") # 28539 waveform, sample_rate, transcript, speaker_id, chapter_id, utt_id = dataset[0] print(waveform.shape, sample_rate) # e.g., torch.Size([1, 93680]) 16000 print(transcript[:50]) loader = DataLoader(dataset, batch_size=None, num_workers=4) ``` -------------------------------- ### torchaudio.datasets.SPEECHCOMMANDS Dataset Example Source: https://context7.com/pytorch/audio/llms.txt Example of using the SPEECHCOMMANDS dataset for keyword spotting. It returns (waveform, sample_rate, label, speaker_id, utterance_number) and supports V1 (30 classes) and V2 (35 classes). ```python import torchaudio dataset = torchaudio.datasets.SPEECHCOMMANDS( root="./data", url="speech_commands_v0.02", subset="training", download=True, ) waveform, sr, label, speaker_id, utt_num = dataset[0] print(f"Label: {label}, shape: {waveform.shape}, sr: {sr}") # Unique labels labels = set(item[2] for item in dataset) print(f"Classes ({len(labels)}): {sorted(labels)}") ``` -------------------------------- ### Verify pip Installation Location Source: https://github.com/pytorch/audio/blob/main/docs/source/build.jetson.rst After installing pip in the user environment, check that the 'pip' command points to the correct executable in the user's local bin directory. ```bash $ which pip /home/USER/.local/bin/pip ``` -------------------------------- ### Download and Install PyTorch for Jetson Source: https://github.com/pytorch/audio/blob/main/docs/source/build.jetson.rst Download the specific PyTorch wheel file provided by NVIDIA for your JetPack version and install it using pip. Ensure you use the correct package name corresponding to your system's architecture and Python version. ```bash $ package=torch-1.13.0a0+340c4120.nv22.06-cp38-cp38-linux_aarch64.whl $ wget "https://developer.download.nvidia.com/compute/redist/jp/v50/pytorch/${package}" $ pip install --no-cache "${package}" ``` -------------------------------- ### Sample Training Command Source: https://github.com/pytorch/audio/blob/main/examples/asr/librispeech_conformer_rnnt_biasing/README.md Example SLURM command for training a Conformer RNN-T model with TCPGen. Requires specifying experiment directory, LibriSpeech path, SentencePiece model, and biasing list. Adjust droprate and maxsize for biasing list configuration. ```bash srun --cpus-per-task=16 --gpus-per-node=1 -N 1 --ntasks-per-node=1 python train.py --exp-dir --librispeech-path --sp-model-path ./spm_unigram_600_100suffix.model --biasing --biasing-list ./blists/rareword_f15.txt --droprate 0.1 --maxsize 200 --epochs 90 ``` -------------------------------- ### Verify PyTorch Installation and CUDA Accessibility Source: https://github.com/pytorch/audio/blob/main/docs/source/build.jetson.rst Run a Python script to check the installed PyTorch version, confirm CUDA availability, and test CUDA device accessibility by creating a tensor on the GPU. ```python import torch print(torch.__version__) print(torch.cuda.is_available()) print(torch.empty((1, 2), device=torch.device("cuda"))) ``` -------------------------------- ### SLURM Job Submission Script Source: https://github.com/pytorch/audio/blob/main/examples/source_separation/README.md Example script for submitting a training job to a SLURM cluster. ```bash #!/bin/bash #SBATCH --job-name=source_separation #SBATCH --output=/checkpoint/%u/jobs/%x/%j.out #SBATCH --error=/checkpoint/%u/jobs/%x/%j.err #SBATCH --nodes=1 #SBATCH --ntasks-per-node=2 #SBATCH --cpus-per-task=8 #SBATCH --mem-per-cpu=16G #SBATCH --gpus-per-node=2 #srun env srun wrapper.sh $@ ``` -------------------------------- ### Sample Evaluation Command Source: https://github.com/pytorch/audio/blob/main/examples/asr/librispeech_conformer_rnnt_biasing/README.md Example SLURM command for evaluating a trained Conformer RNN-T model with TCPGen. Specify the model checkpoint, dataset path, SentencePiece model, experiment directory, and biasing list. Set droprate to 0.0 for evaluation. ```bash srun --cpus-per-task=16 --gpus-per-node=1 -N 1 --ntasks-per-node=1 python eval.py --checkpoint-path --librispeech-path --sp-model-path ./spm_unigram_600_100suffix.model --expdir --use-cuda --biasing --biasing-list ./blists/all_rare_words.txt --droprate 0.0 --maxsize 1000 ``` -------------------------------- ### Build Specific Tutorial Source: https://github.com/pytorch/audio/blob/main/CONTRIBUTING.md Builds only a specific tutorial by using the GALLERY_PATTERN environment variable. Omitting BUILD_GALLERY assumes it is set to 1. ```bash BUILD_GALLERY=1 GALLERY_PATTERN=forced_alignment_tutorial.py make html ``` ```bash GALLERY_PATTERN=forced_alignment_tutorial.py make html ``` -------------------------------- ### Check Installed cuDNN Version Source: https://github.com/pytorch/audio/blob/main/docs/source/build.jetson.rst Verify the installed version of the cuDNN library. ```bash # cuDNN $ apt list --installed | grep cudnn ``` -------------------------------- ### Sample Training Command Source: https://github.com/pytorch/audio/blob/main/examples/asr/librispeech_conformer_rnnt/README.md Launches the training script for the Conformer RNN-T model. Requires a full LibriSpeech dataset, a SentencePiece model, and pre-computed global statistics. ```bash srun --cpus-per-task=12 --gpus-per-node=8 -N 4 --ntasks-per-node=8 python train.py --exp-dir ./experiments --librispeech-path ./librispeech/ --global-stats-path ./global_stats.json --sp-model-path ./spm_unigram_1023.model --epochs 160 ``` -------------------------------- ### Run HuBERT Pre-training (1st Iteration) Source: https://github.com/pytorch/audio/blob/main/examples/hubert/README.md Command to train a HuBERTPretrainModel for the first iteration using PyTorch Lightning on GPU nodes. This is for 250k steps on 32 GPUs. ```bash srun --gpus-per-node=8 --ntasks-per-node=8 -N 4 --cpus-per-task=10 python train.py --dataset-path ./exp/data/mfcc/ --exp-dir ./exp_iter1 --feature-type mfcc --num-class 100 --max-updates 250000 --learning-rate 0.0005 --gpus 8 --num-nodes 4 ``` -------------------------------- ### Load and Use a Dataset with DataLoader Source: https://github.com/pytorch/audio/blob/main/docs/source/datasets.rst Demonstrates how to instantiate a dataset (YESNO) and load it using PyTorch's DataLoader. Ensure the dataset is downloaded if necessary. ```python yesno_data = torchaudio.datasets.YESNO('.', download=True) data_loader = torch.utils.data.DataLoader( yesno_data, batch_size=1, shuffle=True, num_workers=args.nThreads) ``` -------------------------------- ### Run Training Script Source: https://github.com/pytorch/audio/blob/main/examples/source_separation/README.md Execute the PyTorch-Lightning training script. Use `--help` for a full list of parameters. ```bash python lightning_train.py \ [--data-dir DATA_DIR] \ [--num-gpu NUM_GPU] \ [--num-workers NUM_WORKERS] \ ... ``` ```bash python lightning_train.py --help ``` -------------------------------- ### Instantiate and Use Audio Processing Pipeline Source: https://github.com/pytorch/audio/blob/main/docs/source/transforms.rst Demonstrates how to instantiate a custom audio processing pipeline and move it to a CUDA device for computation. This snippet shows the typical workflow for preparing and running a transform pipeline on audio data. ```python # Instantiate a pipeline pipeline = MyPipeline() # Move the computation graph to CUDA pipeline.to(device=torch.device("cuda"), dtype=torch.float32) # Perform the transform features = pipeline(waveform) ``` -------------------------------- ### Run HuBERT Pre-training (2nd Iteration) Source: https://github.com/pytorch/audio/blob/main/examples/hubert/README.md Command to train the HuBERT model for the second iteration for 400k steps. This uses the clustering labels generated in the second pre-processing step. ```bash srun --gpus-per-node=8 --ntasks-per-node=8 -N 4 --cpus-per-task=10 python train.py --dataset-path ./exp/data/hubert_6/ --exp-dir ./exp_iter2 --feature-type hubert --num-class 500 --max-updates 400000 --learning-rate 0.0005 --gpus 8 --num-nodes 4 ``` -------------------------------- ### Run HuBERT Pre-processing (1st Iteration) Source: https://github.com/pytorch/audio/blob/main/examples/hubert/README.md Command to generate data file lists and train a KMeans clustering model using MFCC features for the first iteration of HuBERT pre-training. ```bash srun --cpus-per-task=24 python preprocess.py --root-dir /home/datasets --feat-type mfcc --exp-dir ./exp --num-cluster 100 ``` -------------------------------- ### Run Wav2Letter++ Training Pipeline Source: https://github.com/pytorch/audio/blob/main/examples/pipeline_wav2letter/README.md Invoke the main training script with specified dataset paths, hyperparameters, and training configurations. Ensure dataset paths are correctly set before execution. ```bash DATASET_ROOT = // DATASET_FOLDER_IN_ARCHIVE = 'LibriSpeech' python main.py \ --reduce-lr-valid \ --dataset-root "${DATASET_ROOT}" \ --dataset-folder-in-archive "${DATASET_FOLDER_IN_ARCHIVE}" \ --dataset-train train-clean-100 train-clean-360 train-other-500 \ --dataset-valid dev-clean \ --batch-size 128 \ --learning-rate .6 \ --momentum .8 \ --weight-decay .00001 \ --clip-grad 0. \ --gamma .99 \ --hop-length 160 \ --win-length 400 \ --n-bins 13 \ --normalize \ --optimizer adadelta \ --scheduler reduceonplateau \ --epochs 40 ``` -------------------------------- ### Generate Audio with WaveRNN Vocoder (Phonemes) Source: https://github.com/pytorch/audio/blob/main/examples/pipeline_tacotron2/README.md This command generates audio using WaveRNN with phoneme-based text preprocessing. It requires installing DeepPhonemizer and downloading its pretrained weights. ```bash python inference.py --checkpoint-path ${model_path} \ --vocoder wavernn \ --n-fft 2048 \ --mel-fmin 40 \ --mel-fmax 11025 \ --input-text "Hello world!" \ --text-preprocessor english_phonemes \ --phonimizer DeepPhonemizer \ --phoimizer-checkpoint ./en_us_cmudict_forward.pt \ --cmudict-root ./ \ --output-path "./outputs.wav" ``` -------------------------------- ### VGGishBundle.VGGishInputProcessor Source: https://github.com/pytorch/audio/blob/main/docs/source/_templates/autosummary/bundle_class.rst Documentation for VGGishBundle.VGGishInputProcessor, detailing its callable methods. ```APIDOC ## VGGishBundle.VGGishInputProcessor ### Description Documentation for VGGishBundle.VGGishInputProcessor. ### Methods __call__ .. container:: py attribute .. automethod:: torchaudio.prototype.models.vggish.VGGishBundle.VGGishInputProcessor.__call__ ``` -------------------------------- ### Enable MSVC 2022 x64 Toolset Source: https://github.com/pytorch/audio/blob/main/docs/source/build.windows.rst Call the vcvarsall.bat script to enable the MSVC x64 toolset for compilation. Ensure the path to the script is correct for your Visual Studio installation. ```batch call "C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 ``` -------------------------------- ### View Head of File List Source: https://github.com/pytorch/audio/blob/main/examples/libtorchaudio/speech_recognition/README.md Display the first few lines of the generated file list to verify its format and content. ```bash head flist-de.txt ``` -------------------------------- ### Build TorchScript Pipeline from Fairseq Source: https://github.com/pytorch/audio/blob/main/examples/libtorchaudio/speech_recognition/README.md Use this script to create TorchScript files for audio loading, encoding, and decoding from a fairseq wav2vec model. ```bash mkdir -p pipeline-fairseq python build_pipeline_from_fairseq.py \ --model-file "wav2vec_small_960.pt" \ --dict-dir \ --output-path "./pipeline-fairseq/" ``` -------------------------------- ### SLURM Wrapper Script for Training Source: https://github.com/pytorch/audio/blob/main/examples/source_separation/README.md A wrapper script to configure and launch the PyTorch-Lightning training job on a SLURM cluster. Ensure dataset paths and resource allocations are correctly set. ```bash #!/bin/bash num_speakers=2 this_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" exp_dir="/checkpoint/${USER}/exp/" root_dir="/dataset/" # The directory where the directory ``Libri2Mix`` or ``Libri3Mix`` is stored. num_gpu=2 # The number of GPUs used on one node. num_node=1 # The number of nodes used on the cluster. batch_size=6 # The batch size per GPU. mkdir -p "${exp_dir}" python -u \ "${this_dir}/lightning_train.py" \ --num-speakers "${num_speakers}" \ --sample-rate 8000 \ --root-dir "${root_dir}" \ --exp-dir "${exp_dir}" \ --num-gpu ${num_gpu} \ --num-node ${num_node} \ --batch-size ${batch_size} \ ``` -------------------------------- ### Wav2Letter++ Training Output Log Source: https://github.com/pytorch/audio/blob/main/examples/pipeline_wav2letter/README.md Example JSON output lines from the training process, detailing metrics like character error rate (CER), word error rate (WER), loss, and learning rate per iteration and epoch. This format is suitable for parsing with libraries like pandas. ```json {"name": "train", "epoch": 40, "batch char error": 925, "batch char total": 22563, "batch char error rate": 0.040996321411159865, "epoch char error": 1135098.0, "epoch char total": 23857713.0, "epoch char error rate": 0.047577821059378154, "batch word error": 791, "batch word total": 4308, "batch word error rate": 0.18361188486536675, "epoch word error": 942906.0, "epoch word total": 4569507.0, "epoch word error rate": 0.20634742435015418, "lr": 0.06, "batch size": 128, "n_channel": 13, "n_time": 1685, "dataset length": 132096.0, "iteration": 1032.0, "loss": 0.07428030669689178, "cumulative loss": 90.47326805442572, "average loss": 0.08766789540157531, "iteration time": 1.9895553588867188, "epoch time": 2036.8874564170837} ``` ```json {"name": "train", "epoch": 40, "batch char error": 1131, "batch char total": 24260, "batch char error rate": 0.0466199505358615, "epoch char error": 1136229.0, "epoch char total": 23881973.0, "epoch char error rate": 0.04757684802675223, "batch word error": 957, "batch word total": 4657, "batch word error rate": 0.2054971011380717, "epoch word error": 943863.0, "epoch word total": 4574164.0, "epoch word error rate": 0.20634655862798099, "lr": 0.06, "batch size": 128, "n_channel": 13, "n_time": 1641, "dataset length": 132224.0, "iteration": 1033.0, "loss": 0.08775319904088974, "cumulative loss": 90.5610212534666, "average loss": 0.08766797798012256, "iteration time": 2.108018159866333, "epoch time": 2038.99547457695} ``` ```json {"name": "train", "epoch": 40, "batch char error": 1099, "batch char total": 23526, "batch char error rate": 0.0467142735696676, "epoch char error": 1137328.0, "epoch char total": 23905499.0, "epoch char error rate": 0.04757599914563591, "batch word error": 936, "batch word total": 4544, "batch word error rate": 0.20598591549295775, "epoch word error": 944799.0, "epoch word total": 4578708.0, "epoch word error rate": 0.20634620071863066, "lr": 0.06, "batch size": 128, "n_channel": 13, "n_time": 1682, "dataset length": 132352.0, "iteration": 1034.0, "loss": 0.0791337713599205, "cumulative loss": 90.64015502482653, "average loss": 0.08765972439538348, "iteration time": 2.0329701900482178, "epoch time": 2041.0284447669983} ``` ```json {"name": "train", "epoch": 40, "batch char error": 1023, "batch char total": 22399, "batch char error rate": 0.045671681771507655, "epoch char error": 1138351.0, "epoch char total": 23927898.0, "epoch char error rate": 0.04757421650660664, "batch word error": 863, "batch word total": 4318, "batch word error rate": 0.1998610467809171, "epoch word error": 945662.0, "epoch word total": 4583026.0, "epoch word error rate": 0.20634009058643787, "lr": 0.06, "batch size": 128, "n_channel": 13, "n_time": 1644, "dataset length": 132480.0, "iteration": 1035.0, "loss": 0.07874362915754318, "cumulative loss": 90.71889865398407, "average loss": 0.08765110981061262, "iteration time": 1.9106628894805908, "epoch time": 2042.9391076564789} ``` ```json {"name": "validation", "epoch": 40, "cumulative loss": 12.095281183719635, "dataset length": 2688.0, "iteration": 21.0, "batch char error": 1867, "batch char total": 14792, "batch char error rate": 0.12621687398593834, "epoch char error": 37119.0, "epoch char total": 280923.0, "epoch char error rate": 0.13213229247872194, "batch word error": 1155, "batch word total": 2841, "batch word error rate": 0.4065469904963041, "epoch word error": 22601.0, "epoch word total": 54008.0, "epoch word error rate": 0.418475040734706, "average loss": 0.575965770653316, "validation time": 24.185853481292725} ``` -------------------------------- ### Run HuBERT Pre-processing (2nd Iteration) Source: https://github.com/pytorch/audio/blob/main/examples/hubert/README.md Command to train a new KMeans clustering model using the output from the 6th transformer layer of the first pre-training iteration. The number of clusters is increased to 500. ```bash srun --cpus-per-task=24 python preprocess.py --root-dir /home/datasets --feat-type hubert --exp-dir ./exp --layer-index 6 --checkpoint-path ./exp_iter1/ --num-rank 40 checkpoints_librispeech_hubert_pretrain_base/xxx.ckpt --num-cluster 500 --percent 0.1 ``` -------------------------------- ### Build TorchScript Pipeline from Hugging Face Transformers Source: https://github.com/pytorch/audio/blob/main/examples/libtorchaudio/speech_recognition/README.md Use this script to import and convert a wav2vec2.0 model from Hugging Face Hub into TorchScript format for C++ applications. ```bash mkdir -p pipeline-hf python build_pipeline_from_huggingface_transformers.py \ --model facebook/wav2vec2-large-xlsr-53-german \ --output-path ./pipeline-hf/ ``` -------------------------------- ### Run HuBERT Fine-tuning Source: https://github.com/pytorch/audio/blob/main/examples/hubert/README.md Command to fine-tune the pre-trained HuBERT model on the LibriLightLimited dataset. Feature extraction layers are frozen initially, then unfrozen along with the CTC layer. ```bash srun --gpus-per-node=1 -N 1 --ntasks-per-node=1 --cpus-per-task=10 \ python finetune.py --dataset-path /root/datasets/ --exp-dir ./exp_finetune \ --checkpoint ./exp_iter2/checkpoints_librispeech_hubert_pretrain_base/epoch=361-step=399999.ckpt \ --gpus 1 --debug --warmup-updates 2000 --hold-updates 8000 --decay-updates 10000 --max-updates 20000 --learning-rate 5e-5 ``` -------------------------------- ### Sample Evaluation Command Source: https://github.com/pytorch/audio/blob/main/examples/asr/librispeech_conformer_rnnt/README.md Evaluates a trained Conformer RNN-T model on the LibriSpeech test-clean dataset. Ensure the checkpoint path and dataset paths are correctly specified. ```bash srun python eval.py --checkpoint-path ./experiments/checkpoints/epoch=159.ckpt --librispeech-path ./librispeech/ --sp-model-path ./spm_unigram_1023.model --use-cuda ``` -------------------------------- ### Build torchaudio In-Place Source: https://github.com/pytorch/audio/blob/main/docs/source/build.linux.rst Builds the torchaudio library in-place using pip. The '-v' flag provides verbose output, and '--no-build-isolation' is required for in-place builds. ```bash pip install -e . -v --no-build-isolation ``` -------------------------------- ### Tacotron2TTSBundle.TextProcessor Source: https://github.com/pytorch/audio/blob/main/docs/source/_templates/autosummary/bundle_class.rst Documentation for Tacotron2TTSBundle.TextProcessor, including its properties and callable methods. ```APIDOC ## Tacotron2TTSBundle.TextProcessor ### Description Documentation for Tacotron2TTSBundle.TextProcessor. Properties ---------- tokens .. container:: py attribute .. autoproperty:: torchaudio.prototype.models.tacotron2.Tacotron2TTSBundle.TextProcessor.tokens Methods ------- __call__ .. container:: py attribute .. automethod:: torchaudio.prototype.models.tacotron2.Tacotron2TTSBundle.TextProcessor.__call__ ``` -------------------------------- ### Wav2Vec2FABundle.Tokenizer Source: https://github.com/pytorch/audio/blob/main/docs/source/_templates/autosummary/bundle_class.rst Documentation for Wav2Vec2FABundle.Tokenizer, detailing its callable methods. ```APIDOC ## Wav2Vec2FABundle.Tokenizer ### Description Documentation for Wav2Vec2FABundle.Tokenizer. ### Methods __call__ .. container:: py attribute .. automethod:: torchaudio.prototype.models.wav2vec2.Wav2Vec2FABundle.Tokenizer.__call__ ``` -------------------------------- ### VGGishBundle.VGGish Source: https://github.com/pytorch/audio/blob/main/docs/source/_templates/autosummary/bundle_class.rst Documentation for VGGishBundle.VGGish, detailing its forward method. ```APIDOC ## VGGishBundle.VGGish ### Description Documentation for VGGishBundle.VGGish. Methods ------- forward .. container:: py attribute .. automethod:: torchaudio.prototype.models.vggish.VGGishBundle.VGGish.forward ``` -------------------------------- ### Clone torchaudio Repository Source: https://github.com/pytorch/audio/blob/main/docs/source/build.linux.rst Clones the torchaudio repository from GitHub and navigates into the project directory. ```bash git clone https://github.com/pytorch/audio cd audio ``` -------------------------------- ### Generate VoxForge German Dataset File List Source: https://github.com/pytorch/audio/blob/main/examples/libtorchaudio/speech_recognition/README.md Create a file list for the VoxForge German dataset by running a Python script with the path to your dataset. The output file `flist-de.txt` will contain audio paths and their transcriptions. ```bash python parse_voxforge.py > ./flist-de.txt ``` -------------------------------- ### Run Inference Script for LibriSpeech Source: https://github.com/pytorch/audio/blob/main/examples/asr/librispeech_ctc_decoder/README.md This command shows how to execute the inference script. Specify the path to the LibriSpeech dataset, the desired split, the pre-trained model, and parameters for beam search, language model weight, and word score. ```bash python inference.py \ --librispeech_path ./librispeech/ \ --split test-other \ --model WAV2VEC2_ASR_BASE_960H \ --beam-size 1500 \ --lm-weight 1.74 \ --word-score 0.52 ``` -------------------------------- ### Launch Bash from Miniconda Source: https://github.com/pytorch/audio/blob/main/docs/source/build.windows.rst Optional step to launch a Bash environment from Miniconda for a Linux/macOS-like user experience. Note that file paths and module compatibility may differ in this environment. ```bash Miniconda3\Library\bin\bash.exe ``` -------------------------------- ### Fork and Create Branch Source: https://github.com/pytorch/audio/blob/main/CONTRIBUTING.md Standard Git commands to fork the repository and create a new branch for development. ```bash git checkout main && git checkout -b my_cool_feature ``` -------------------------------- ### Perform WaveRNN Inference Source: https://github.com/pytorch/audio/blob/main/examples/pipeline_wavernn/README.md Run the inference script using a pre-trained checkpoint to generate an audio waveform. The output file path can be specified. ```bash python inference.py \ --checkpoint-name wavernn_10k_epochs_8bits_ljspeech \ --output-wav-path ./output.wav ``` -------------------------------- ### Wav2Vec2Model Source: https://github.com/pytorch/audio/blob/main/docs/source/_templates/autosummary/model_class.rst Documentation for the Wav2Vec2Model class, including its methods and related factory functions. ```APIDOC ## Wav2Vec2Model ### Description Documentation for the Wav2Vec2Model class. ### Methods #### forward .. automethod:: torchaudio.models.Wav2Vec2Model.forward #### extract_features .. automethod:: torchaudio.models.Wav2Vec2Model.extract_features ### Factory Functions .. autosummary:: :toctree: ../generated :nosignatures: ~torchaudio.models.wav2vec2_model ~torchaudio.models.wav2vec2_base ~torchaudio.models.wav2vec2_large ~torchaudio.models.wav2vec2_large_lv60k ~torchaudio.models.wav2vec2_xlsr_300m ~torchaudio.models.wav2vec2_xlsr_1b ~torchaudio.models.wav2vec2_xlsr_2b ~torchaudio.models.hubert_base ~torchaudio.models.hubert_large ~torchaudio.models.hubert_xlarge ~torchaudio.models.wavlm_model ~torchaudio.models.wavlm_base ~torchaudio.models.wavlm_large ### Utility Functions .. currentmodule:: torchaudio.models .. autosummary:: :toctree: ../generated :nosignatures: ~torchaudio.models.wav2vec2.utils.import_fairseq_model ~torchaudio.models.wav2vec2.utils.import_huggingface_model .. autosummary:: :toctree: ../generated :nosignatures: ~torchaudio.models.emformer_hubert_model ~torchaudio.models.emformer_hubert_base ~torchaudio.models.conformer_wav2vec2_model ~torchaudio.models.conformer_wav2vec2_base ``` -------------------------------- ### torchaudio.load_with_torchcodec Source: https://github.com/pytorch/audio/blob/main/docs/source/torchaudio.rst Loads an audio file using TorchCodec. ```APIDOC ## torchaudio.load_with_torchcodec ### Description Loads an audio file using TorchCodec. This is the recommended way to load audio files. ### Method Not applicable (Python function) ### Endpoint Not applicable (Python function) ### Parameters Refer to the official TorchCodec documentation for detailed parameters. ### Request Example ```python import torchaudio speech_waveform, sample_rate = torchaudio.load_with_torchcodec("speech.wav") ``` ### Response - **waveform** (Tensor) - The audio waveform. - **sample_rate** (int) - The sample rate of the audio. ```