### Install pre-commit Package Source: https://github.com/k2-fsa/icefall/blob/master/contributing.md Install the pre-commit package using pip. This is a one-time setup step. ```bash pip install pre-commit ``` -------------------------------- ### Whisper Model Installation and Training Setup Source: https://github.com/k2-fsa/icefall/blob/master/egs/aishell/ASR/RESULTS.md Installs Whisper model requirements and prepares data for fine-tuning. ```bash pip install -r whisper/requirements.txt ./prepare.sh --stage 30 --stop_stage 30 ``` -------------------------------- ### Install Documentation Dependencies Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/contributing/doc.md Navigate to the docs directory and install the required Python packages for building documentation. ```bash cd docs pip install -r requirements.txt ``` -------------------------------- ### Install Dependencies and Build Documentation Source: https://github.com/k2-fsa/icefall/blob/master/docs/README.md Navigate to the docs directory, install requirements, clean previous builds, and generate HTML documentation. ```bash cd /path/to/icefall/docs pip install -r requirements.txt make clean make html ``` -------------------------------- ### Install kaldifeat Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/for-dummies/model-export.md Install the kaldifeat library with specific version and PyTorch compatibility. Use the provided URL for CPU-specific builds. ```bash pip install kaldifeat==1.25.3.dev20231221+cpu.torch2.0.0 -f https://csukupeangfj.github.io/kaldifeat/cpu.html ``` -------------------------------- ### Install Dependencies and Download Models Source: https://github.com/k2-fsa/icefall/blob/master/egs/speech_llm/ASR_LLM/RESULTS.md Installs necessary Python packages and downloads pre-trained Whisper and Qwen models required for fine-tuning. ```bash pip install -r whisper_llm_zh/requirements.txt pip install huggingface_hub['cli'] mkdir -p models/whisper models/qwen # For aishell fine-tuned whisper model huggingface-cli download --local-dir models/whisper yuekai/icefall_asr_aishell_whisper exp_large_v2/whisper-large-v2-aishell1-epoch-10-avg-6.pt # For multi-hans fine-tuned whisper model # huggingface-cli download --local-dir models/whisper yuekai/icefall_asr_multi-hans-zh_whisper v1.1/whisper-large-v2-multi-hans-zh-epoch-3-avg-10.pt # huggingface-cli download --local-dir models/qwen Qwen/Qwen2-7B-Instruct huggingface-cli download --local-dir models/qwen Qwen/Qwen2-1.5B-Instruct ``` -------------------------------- ### Install kaldifeat Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/for-dummies/model-export.md Install the kaldifeat library with a specific version and PyTorch compatibility. This command is used for installing the necessary tools for feature extraction. ```bash pip install kaldifeat==1.25.3.dev20231221+cpu.torch2.0.0 -f https://csukuangfj.github.io/kaldifeat/cpu.html ``` -------------------------------- ### TensorBoard Upload Output Example Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/Non-streaming-ASR/yesno/tdnn.md This is an example of the output you might see after uploading TensorBoard logs. It includes a link to view your experiment. ```default TensorFlow installation not found - running with reduced feature set. Uploading started and will continue reading any new data as it's added to the logdir. To stop uploading, press Ctrl-C. New experiment created. View your TensorBoard at: https://tensorboard.dev/experiment/yKUbhb5wRmOSXYkId1z9eg/ [2021-08-23T23:49:41] Started scanning logdir. [2021-08-23T23:49:42] Total uploaded: 135 scalars, 0 tensors, 0 binary objects Listening for new data in logdir... ``` -------------------------------- ### Install k2 (CPU) Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/for-dummies/environment-setup.md Installs the k2 library for CPU. A separate command is provided for users in China who might face issues accessing Hugging Face. ```bash # Please refer to https://k2-fsa.github.io/k2/installation/from_wheels.html#linux-cpu-example pip install k2==1.24.4.dev20231220+cpu.torch2.0.0 -f https://k2-fsa.github.io/k2/cpu.html # For users from China # 中国国内用户,如果访问不了 huggingface, 请使用 # pip install k2==1.24.4.dev20231220+cpu.torch2.0.0 -f https://k2-fsa.github.io/k2/cpu-cn.html ``` -------------------------------- ### Install sherpa-onnx Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/TTS/ljspeech/vits.md Install the sherpa-onnx package, which provides tools for running ONNX models. ```bash pip install sherpa-onnx ``` -------------------------------- ### TensorBoard Upload Output Example Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/Non-streaming-ASR/aishell/tdnn_lstm_ctc.md This is an example of the output you might see when uploading TensorBoard logs. It includes experiment creation and upload progress. ```default TensorFlow installation not found - running with reduced feature set. Upload started and will continue reading any new data as it's added to the logdir. To stop uploading, press Ctrl-C. New experiment created. View your TensorBoard at: https://tensorboard.dev/experiment/LJI9MWUORLOw3jkdhxwk8A/ [2021-09-13T11:59:23] Started scanning logdir. [2021-09-13T11:59:24] Total uploaded: 4454 scalars, 0 tensors, 0 binary objects Listening for new data in logdir... ``` -------------------------------- ### Install Git LFS Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/Non-streaming-ASR/aishell/tdnn_lstm_ctc.md Install git-lfs using apt-get if you have sudo permissions. This is required for downloading language models from Hugging Face. ```bash sudo apt-get install git-lfs git-lfs install ``` -------------------------------- ### Install k2 from Wheels Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/installation/index.md Installs the k2 library using pre-compiled wheels, specifying the CUDA and PyTorch versions. A fallback URL for users in China is provided. ```bash (test-icefall) kuangfangjun:~$ pip install k2==1.24.3.dev20230725+cuda11.6.torch1.13.0 -f https://k2-fsa.github.io/k2/cuda.html # For users from China # 中国国内用户,如果访问不了 huggingface, 请使用 # pip install k2==1.24.3.dev20230725+cuda11.6.torch1.13.0 -f https://k2-fsa.github.io/k2/cuda-cn.html Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Looking in links: https://k2-fsa.github.io/k2/cuda.html Collecting k2==1.24.3.dev20230725+cuda11.6.torch1.13.0 Downloading https://huggingface.co/csukuangfj/k2/resolve/main/ubuntu-cuda/k2-1.24.3.dev20230725%2Bcuda11.6.torch1.13.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (104.3 MB) ________________________________________ 104.3/104.3 MB 5.1 MB/s eta 0:00:00 Requirement already satisfied: torch==1.13.0 in /star-fj/fangjun/test-icefall/lib/python3.8/site-packages (from k2==1.24.3.dev20230725+cuda11.6.torch1.13.0) (1.13.0+cu116) Collecting graphviz Using cached https://pypi.tuna.tsinghua.edu.cn/packages/de/5e/fcbb22c68208d39edff467809d06c9d81d7d27426460ebc598e55130c1aa/graphviz-0.20.1-py3-none-any.whl (47 kB) Requirement already satisfied: typing-extensions in /star-fj/fangjun/test-icefall/lib/python3.8/site-packages (from torch==1.13.0->k2==1.24.3.dev20230725+cuda11.6.torch1.13.0) (4.7.1) Installing collected packages: graphviz, k2 Successfully installed graphviz-0.20.1 k2-1.24.3.dev20230725+cuda11.6.torch1.13.0 ``` -------------------------------- ### Simulated Streaming Decoding Example (Epoch-based) Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/Streaming-ASR/librispeech/pruned_transducer_stateless.md Example command for performing simulated streaming decoding using epoch-based checkpoints. Requires setting `--simulate-streaming` and `--causal-convolution` to 1. ```bash for m in greedy_search fast_beam_search modified_beam_search; do for epoch in 25 20; do for avg in 7 5 3 1; do ./pruned_transducer_stateless4/decode.py \ --epoch $epoch \ --avg $avg \ --simulate-streaming 1 \ --causal-convolution 1 \ --decode-chunk-size 16 \ --left-context 64 \ --exp-dir pruned_transducer_stateless4/exp \ --max-duration 600 \ --decoding-method $m done done done ``` -------------------------------- ### Serve Documentation Locally Source: https://github.com/k2-fsa/icefall/blob/master/docs/README.md Change to the build HTML directory and start a local HTTP server to view the documentation in a browser. ```bash cd build/html python3 -m http.server 8000 ``` -------------------------------- ### Example Output of Alignment Script Source: https://github.com/k2-fsa/icefall/blob/master/egs/librispeech/ASR/transducer_stateless/README.md This is an example of the output produced by the alignment script, showing cut IDs and lists of words with their corresponding start times in seconds. ```text 5694-64029-0022-1998-0 [('THE', '0.20'), ('LEADEN', '0.36'), ('HAIL', '0.72'), ('STORM', '1.00'), ('SWEPT', '1.48'), ('THEM', '1.88'), ('OFF', '2.00'), ('THE', '2.24'), ('FIELD', '2.36'), ('THEY', '3.20'), ('FELL', '3.36'), ('BACK', '3.64'), ('AND', '3.92'), ('RE', '4.04'), ('FORMED', '4.20')] 3081-166546-0040-308-0 [('IN', '0.32'), ('OLDEN', '0.60'), ('DAYS', '1.00'), ('THEY', '1.40'), ('WOULD', '1.56'), ('HAVE', '1.76'), ('SAID', '1.92'), ('STRUCK', '2.60'), ('BY', '3.16'), ('A', '3.36'), ('BOLT', '3.44'), ('FROM', '3.84'), ('HEAVEN', '4.04')] 2035-147960-0016-1283-0 [('A', '0.44'), ('SNAKE', '0.52'), ('OF', '0.84'), ('HIS', '0.96'), ('SIZE', '1.12'), ('IN', '1.60'), ('FIGHTING', '1.72'), ('TRIM', '2.12'), ('WOULD', '2.56'), ('BE', '2.76'), ('MORE', '2.88'), ('THAN', '3.08'), ('ANY', '3.28'), ('BOY', '3.56'), ('COULD', '3.88'), ('HANDLE', '4.04')] 2428-83699-0020-1734-0 [('WHEN', '0.28'), ('THE', '0.48'), ('TRAP', '0.60'), ('DID', '0.88'), ('APPEAR', '1.08'), ('IT', '1.80'), ('LOOKED', '1.96'), ('TO', '2.24'), ('ME', '2.36'), ('UNCOMMONLY', '2.52'), ('LIKE', '3.16'), ('AN', '3.40'), ('OPEN', '3.56'), ('SPRING', '3.92'), ('CART', '4.28')] 8297-275154-0026-2108-0 [('LET', '0.44'), ('ME', '0.72'), ('REST', '0.92'), ('A', '1.32'), ('LITTLE', '1.40'), ('HE', '1.80'), ('PLEADED', '2.00'), ('IF', '3.04'), ("I'M", '3.28'), ('NOT', '3.52'), ('IN', '3.76'), ('THE', '3.88'), ('WAY', '4.00')] 652-129742-0007-1002-0 [('SURROUND', '0.28'), ('WITH', '0.80'), ('A', '0.92'), ('GARNISH', '1.00'), ('OF', '1.44'), ('COOKED', '1.56'), ('AND', '1.88'), ('DICED', '4.16'), ('CARROTS', '4.28'), ('TURNIPS', '4.44'), ('GREEN', '4.60'), ('PEAS', '4.72')] ``` -------------------------------- ### Prepare Data for Yesno Recipe Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/installation/index.md Set up the environment and navigate to the yesno recipe directory to prepare the dataset. ```bash (test-icefall) kuangfangjun:icefall$ export PYTHONPATH=/tmp/icefall:$PYTHONPATH (test-icefall) kuangfangjun:icefall$ cd /tmp/icefall (test-icefall) kuangfangjun:icefall$ cd egs/yesno/ASR (test-icefall) kuangfangjun:ASR$ ./prepare.sh ``` -------------------------------- ### HTTP Server Output Source: https://github.com/k2-fsa/icefall/blob/master/docs/README.md Example output when starting the Python HTTP server, indicating the address and port it is serving on. ```text Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ... ``` -------------------------------- ### Setup Experiment Directory and Checkpoint Link Source: https://github.com/k2-fsa/icefall/blob/master/egs/speech_llm/ASR_LLM/RESULTS.md Create a directory for ASR LLM experiments and create a symbolic link to a specific checkpoint file. ```bash mkdir -p whisper_llm_zh/exp_aishell_whisper_qwen2_1.5B ln -s models/checkpoint/epoch-10-avg-5.pt whisper_llm_zh/exp_aishell_whisper_qwen2_1.5B/epoch-999.pt ``` -------------------------------- ### Download and Setup Icefall Repository Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/installation/index.md Clones the Icefall repository, installs its requirements, and sets the PYTHONPATH environment variable to include the Icefall directory. ```bash cd /tmp git clone https://github.com/k2-fsa/icefall cd icefall pip install -r requirements.txt export PYTHONPATH=/tmp/icefall:$PYTHONPATH ``` -------------------------------- ### Distributed Data Parallel Training Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/Non-streaming-ASR/aishell/stateless_transducer.md Configure and start distributed training using multiple GPUs. This example uses GPUs 0 and 3 for training with a world size of 2. ```bash #!/bin/bash cd egs/aishell/ASR export CUDA_VISIBLE_DEVICES="0,3" ./transducer_stateless_modified/train.py --world-size 2 ``` -------------------------------- ### Start Fine-tuning with Adapters Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/Finetune/adapter/finetune_adapter.md Initiates a fine-tuning experiment for a Zipformer model using adapters. This command configures parameters like adapter dimension, learning rate, and the pre-trained checkpoint to use. ```bash $ do_finetune=1 $ use_adapters=1 $ adapter_dim=8 $ ./zipformer_adapter/train.py \ --world-size 2 \ --num-epochs 20 \ --start-epoch 1 \ --exp-dir zipformer_adapter/exp_giga_finetune_adapters${use_adapters}_adapter_dim${adapter_dim} \ --use-fp16 1 \ --base-lr 0.045 \ --use-adapters $use_adapters --adapter-dim $adapter_dim \ --bpe-model data/lang_bpe_500/bpe.model \ --do-finetune $do_finetune \ --master-port 13022 \ --finetune-ckpt icefall-asr-librispeech-zipformer-2023-05-15/exp/pretrained.pt \ --max-duration 1000 ``` -------------------------------- ### Build Documentation Locally Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/contributing/doc.md After writing documentation, navigate to the docs directory and use the make command to build the HTML output. ```bash cd docs make html ``` -------------------------------- ### Train Large-Scale Librispeech ASR Model Source: https://github.com/k2-fsa/icefall/blob/master/egs/librispeech/ASR/RESULTS.md Command to initiate training for a large-scale Librispeech ASR model. This example shows the setup for using 2 A100 GPUs and exporting the CUDA visible devices. ```bash export CUDA_VISIBLE_DEVICES="0,1" ``` -------------------------------- ### Example Data Cut JSON Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/for-dummies/data-preparation.md This JSON object represents a single audio cut, including its ID, start and end times, channel information, supervision details (text, language), and feature extraction parameters. It also contains information about the original recording. ```json {"id": "0_0_0_1_0_1_1_0-1", "start": 0, "duration": 6.11, "channel": 0, "supervisions": [{"id": "0_0_0_1_0_1_1_0", "recording_id": "0_0_0_1_0_1_1_0", "start": 0.0, "duration": 6.11, "channel": 0, "text": "NO NO NO YES NO YES YES NO", "language": "Hebrew"}], "features": {"type": "kaldi-fbank", "num_frames": 611, "num_features": 23, "frame_shift": 0.01, "sampling_rate": 8000, "start": 0, "duration": 6.11, "storage_type": "lilcom_chunky", "storage_path": "data/fbank/yesno_feats_train.lca", "storage_key": "16570,12964,2929", "channels": 0}, "recording": {"id": "0_0_0_1_0_1_1_0", "sources": [{"type": "file", "channels": [0], "source": "/tmp/icefall/egs/yesno/ASR/download/waves_yesno/0_0_0_1_0_1_1_0.wav"}], "sampling_rate": 8000, "num_samples": 48880, "duration": 6.11, "channel_ids": [0]}, "type": "MonoCut"} ``` ```json {"id": "0_0_1_0_0_1_1_0-2", "start": 0, "duration": 6.02, "channel": 0, "supervisions": [{"id": "0_0_1_0_0_1_1_0", "recording_id": "0_0_1_0_0_1_1_0", "start": 0.0, "duration": 6.02, "channel": 0, "text": "NO NO YES NO NO YES YES NO", "language": "Hebrew"}], "features": {"type": "kaldi-fbank", "num_frames": 602, "num_features": 23, "frame_shift": 0.01, "sampling_rate": 8000, "start": 0, "duration": 6.02, "storage_type": "lilcom_chunky", "storage_path": "data/fbank/yesno_feats_train.lca", "storage_key": "32463,12936,2696", "channels": 0}, "recording": {"id": "0_0_1_0_0_1_1_0", "sources": [{"type": "file", "channels": [0], "source": "/tmp/icefall/egs/yesno/ASR/download/waves_yesno/0_0_1_0_0_1_1_0.wav"}], "sampling_rate": 8000, "num_samples": 48160, "duration": 6.02, "channel_ids": [0]}, "type": "MonoCut"} ``` -------------------------------- ### Start Training Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/for-dummies/training.md This command initiates the training process. Ensure you are in the correct directory and have set up the Python path. Training will use CPU if CUDA_VISIBLE_DEVICES is empty. ```bash cd /tmp/icefall export PYTHONPATH=/tmp/icefall:$PYTHONPATH cd egs/yesno/ASR # We use CPU for training by setting the following environment variable export CUDA_VISIBLE_DEVICES="" ./tdnn/train.py ``` -------------------------------- ### Install lhotse Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/installation/index.md Use pip to install the lhotse library. This command installs lhotse and its dependencies. ```bash pip install lhotse ``` -------------------------------- ### Verify CUDA Installation Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/installation/index.md Checks the installed CUDA version using the 'nvcc' command. This is useful after installing the CUDA toolkit. ```bash nvcc --version ``` -------------------------------- ### Install Whisper Requirements Source: https://github.com/k2-fsa/icefall/blob/master/egs/multi_zh-hans/ASR/RESULTS.md Installs the necessary Python packages for the Whisper model training. Ensure you have the correct version of pip installed. ```bash pip install -r whisper/requirements.txt ``` -------------------------------- ### Start Training with 4 GPUs Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/Non-streaming-ASR/librispeech/zipformer_ctc_blankskip.md Initiates the training process using 4 GPUs. This command sets up the environment and specifies training parameters. ```bash export CUDA_VISIBLE_DEVICES="0,1,2,3" ./pruned_transducer_stateless7_ctc_bs/train.py \ --world-size 4 \ --num-epochs 30 \ --start-epoch 1 \ --full-libri 1 \ --exp-dir pruned_transducer_stateless7_ctc_bs/exp \ --max-duration 600 \ --use-fp16 1 ``` -------------------------------- ### Verify Torchaudio Installation Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/installation/index.md Confirms that torchaudio has been installed successfully by displaying its version. ```bash (test-icefall) kuangfangjun:~$ python3 -c "import torchaudio; print(torchaudio.__version__)" 0.13.0+cu116 ``` -------------------------------- ### Display Training Options Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/Non-streaming-ASR/timit/tdnn_ligru_ctc.md View all available command-line options for the training script by running it with the --help flag. ```bash ./tdnn_ligru_ctc/train.py --help ``` -------------------------------- ### Install Lhotse Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/for-dummies/environment-setup.md Installs the latest version of the lhotse library from its GitHub repository. ```bash pip install git+https://github.com/lhotse-speech/lhotse ``` -------------------------------- ### Install PyTorch and Torchaudio (CPU) Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/for-dummies/environment-setup.md Installs specific versions of PyTorch and torchaudio for CPU usage. This order of installation is important. For macOS users, a different command without the '+cpu' suffix is provided. ```bash # We use torch 2.0.0 and torchaduio 2.0.0 in this tutorial. # Other versions should also work. pip install torch==2.0.0+cpu torchaudio==2.0.0+cpu -f https://download.pytorch.org/whl/torch_stable.html # If you are using macOS, please use the following command to install torch and torchaudio # pip install torch==2.0.0 torchaudio==2.0.0 -f https://download.pytorch.org/whl/torch_stable.html ``` -------------------------------- ### View TensorBoard Logs Locally Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/Non-streaming-ASR/librispeech/zipformer_ctc_blankskip.md Starts a local TensorBoard server to view training logs. Navigate to the tensorboard directory first. ```bash cd pruned_transducer_stateless7_ctc_bs/exp/tensorboard tensorboard --logdir . --port 6008 ``` -------------------------------- ### Install CTC Dependencies Source: https://github.com/k2-fsa/icefall/blob/master/icefall/ctc/README.md Installs the necessary Python packages for CTC decoding in Icefall. ```bash pip install kaldifst kaldi-decoder ``` -------------------------------- ### Get Training Help Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/Non-streaming-ASR/librispeech/tdnn_lstm_ctc.md Display available training options for the train.py script using the --help flag. ```bash ./tdnn_lstm_ctc/train.py --help ``` -------------------------------- ### Start Training with 6 GPUs Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/Non-streaming-ASR/librispeech/pruned_transducer_stateless.md Initiates the training process using 6 GPUs, specifying epochs, experiment directory, and maximum duration. ```bash export CUDA_VISIBLE_DEVICES="0,1,2,3,4,5" ./pruned_transducer_stateless4/train.py \ --world-size 6 \ --num-epochs 30 \ --start-epoch 1 \ --exp-dir pruned_transducer_stateless4/exp \ --full-libri 1 \ --max-duration 300 ``` -------------------------------- ### Verify sherpa-onnx Installation Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/TTS/ljspeech/vits.md Verify that sherpa-onnx has been installed correctly by checking its command-line tool. ```bash which sherpa-onnx-offline-tts sherpa-onnx-offline-tts --help ``` -------------------------------- ### Invoking the Training Stage Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/contributing/how-to-create-a-recipe.md Shows how to run the training script for a custom recipe, including how to access help for available options. ```bash $ cd egs/foo/ASR $ ./bar/train.py $ ./bar/train.py --help ``` -------------------------------- ### Verify PyTorch Installation Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/installation/index.md Checks if PyTorch has been installed correctly by printing its version number. ```bash (test-icefall) kuangfangjun:~$ python3 -c "import torch; print(torch.__version__)" 1.13.0+cu116 ``` -------------------------------- ### Prepare for MVQ Training Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/Non-streaming-ASR/librispeech/distillation.md This command initiates the preparation for MVQ (Multi-Vector Quantization) training by running stage 3. It's a prerequisite for the actual knowledge distillation training. ```bash ./prepare.sh --stage 3 --stop_stage 3 ``` -------------------------------- ### Install ONNX Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/model-export/export-onnx.md Install the ONNX package using pip. This is a prerequisite for exporting models. ```bash pip install onnx ``` -------------------------------- ### Install Dependencies Source: https://github.com/k2-fsa/icefall/blob/master/egs/wenetspeech4tts/TTS/README.md Installs necessary Python packages for kaldialign, lhotse, tensorboard, bigvganinference, and sentencepiece. ```bash pip install kaldialign lhotse tensorboard bigvganinference sentencepiece ``` -------------------------------- ### Start Stateless Transducer Training Source: https://github.com/k2-fsa/icefall/blob/master/egs/librispeech/ASR/transducer_stateless/README.md Use this command to initiate the training process for a stateless transducer ASR model. Ensure you are in the correct directory and have set the CUDA visible devices. ```bash cd egs/librispeech/ASR export CUDA_VISIBLE_DEVICES="0,1,2,3" ./transducer_stateless/train.py \ --world-size 4 \ --num-epochs 30 \ --start-epoch 0 \ --exp-dir transducer_stateless/exp \ --full-libri 1 \ --max-duration 250 \ --lr-factor 2.5 ``` -------------------------------- ### Install Icefall Requirements Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/for-dummies/environment-setup.md Installs dependencies required by icefall using the provided requirements file. ```bash pip install -r ./requirements.txt ``` -------------------------------- ### Install Extra Dependencies Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/TTS/ljspeech/vits.md Install necessary packages for TTS recipes, including piper_phonemize, numba, and espnet_tts_frontend. ```bash pip install piper_phonemize -f https://k2-fsa.github.io/icefall/piper_phonemize.html pip install numba espnet_tts_frontend ``` -------------------------------- ### Display Training Options Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/Non-streaming-ASR/aishell/stateless_transducer.md Use this command to view all available training options for the stateless transducer model. ```bash cd egs/aishell/ASR ./transducer_stateless_modified/train.py --help ``` -------------------------------- ### Display Training Options Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/Non-streaming-ASR/librispeech/pruned_transducer_stateless.md Shows the available training options that can be passed from the command line. Use this to understand configurable parameters. ```bash cd egs/librispeech/ASR ./pruned_transducer_stateless4/train.py --help ``` -------------------------------- ### Verify lhotse Installation Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/installation/index.md Run this Python command to confirm that lhotse has been installed successfully and to display its version. ```bash (test-icefall) kuangfangjun:~$ python3 -c "import lhotse; print(lhotse.__version__)" 1.16.0.dev+git.7640d66.clean ``` -------------------------------- ### Display Training Help Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/for-dummies/training.md Prints the usage information for the training script, allowing you to see available options for customization. ```bash ./tdnn/train.py --help ``` -------------------------------- ### Install optimized_transducer Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/Non-streaming-ASR/aishell/stateless_transducer.md Install the optimized_transducer library using pip. This library is used for computing the transducer loss efficiently. ```bash pip install optimized_transducer ``` -------------------------------- ### Download Qwen Model Source: https://github.com/k2-fsa/icefall/blob/master/egs/speech_llm/ASR_LLM/RESULTS.md Use huggingface-cli to download the Qwen2-7B-Instruct model to a local directory. ```bash huggingface-cli download --local-dir models/qwen Qwen/Qwen2-7B-Instruct ``` -------------------------------- ### Multi-GPU Training with All Available GPUs Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/Non-streaming-ASR/librispeech/zipformer_ctc_blankskip.md Utilize all available GPUs for DDP training by setting the --world-size argument to the number of GPUs. This example assumes 4 GPUs are available. ```bash cd egs/librispeech/ASR ./pruned_transducer_stateless7_ctc_bs/train.py --world-size 4 ``` -------------------------------- ### Install Git Pre-Commit Hooks Source: https://github.com/k2-fsa/icefall/blob/master/contributing.md Install the Git pre-commit hooks for the project. This enables automatic code checks before commits. ```bash pre-commit install ``` -------------------------------- ### Start Decoding Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/for-dummies/decoding.md This command initiates the decoding process. Ensure you are in the correct directory and have set up the Python path. Decoding is performed on CPU by default. ```bash cd /tmp/icefall export PYTHONPATH=/tmp/icefall:$PYTHONPATH cd egs/yesno/ASR # We use CPU for decoding by setting the following environment variable export CUDA_VISIBLE_DEVICES="" ./tdnn/decode.py ``` -------------------------------- ### Start DDP Training on Specific GPUs Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/Non-streaming-ASR/aishell/conformer_ctc.md Configure and start Distributed Data Parallel (DDP) training on specified GPUs. ```bash #!/bin/bash cd egs/aishell/ASR export CUDA_VISIBLE_DEVICES="0,3" ./conformer_ctc/train.py --world-size 2 ``` -------------------------------- ### Start Stateless RNN-Transducer Training Source: https://github.com/k2-fsa/icefall/blob/master/egs/aishell/ASR/transducer_stateless/README.md Use this command to begin training the stateless RNN-Transducer model. Ensure CUDA devices are configured and adjust parameters like world size, epochs, and experiment directory as needed. ```bash cd egs/aishell/ASR export CUDA_VISIBLE_DEVICES="0,1,2,3,4,5,6,7" ./transducer_stateless/train.py \ --world-size 8 \ --num-epochs 30 \ --start-epoch 0 \ --exp-dir transducer_stateless/exp \ --max-duration 250 \ --lr-factor 2.5 ``` -------------------------------- ### View TensorBoard Logs Locally Source: https://github.com/k2-fsa/icefall/blob/master/docs/source/recipes/Non-streaming-ASR/librispeech/pruned_transducer_stateless.md Starts a local TensorBoard server to view training logs. Access it via the provided URL in your browser. ```bash #!/bin/bash cd pruned_transducer_stateless4/exp/tensorboard tensorboard --logdir . --port 6008 ``` -------------------------------- ### Prepare Data and Features Source: https://github.com/k2-fsa/icefall/blob/master/egs/librispeech/WSASR/README.md Prepares the dataset by adding an OTC token and computing SSL features. Ensure 'feature_type' is set to 'ssl' or 'fbank'. ```bash # feature_type can be ssl or fbank feature_type=ssl feature_dir="data/${feature_type}" manifest_dir="${feature_dir}" lang_dir="data/lang" lm_dir="data/lm" exp_dir="conformer_ctc2/exp" otc_token="" ./prepare.sh \ --feature-type "${feature_type}" \ --feature-dir "${feature_dir}" \ --lang-dir "${lang_dir}" \ --lm-dir "${lm_dir}" \ --otc-token "${otc_token}" ```