|
| 1 | +# Descript Audio Codec (.dac) |
| 2 | + |
| 3 | +<!--  --> |
| 4 | + |
| 5 | + |
| 6 | +This repository contains training and inference scripts |
| 7 | +for the Descript Audio Codec (.dac), a high fidelity general |
| 8 | +neural audio codec. |
| 9 | + |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | +### Installation |
| 14 | +``` |
| 15 | +git clone https://github.com/descriptinc/descript-audio-codec |
| 16 | +cd descript-audio-codec |
| 17 | +pip install . |
| 18 | +``` |
| 19 | + |
| 20 | +### Compress audio |
| 21 | +``` |
| 22 | +python3 -m dac encode /path/to/input --output /path/to/output/codes |
| 23 | +``` |
| 24 | + |
| 25 | +This command will create `.dac` files with the same name as the input files. |
| 26 | +It will also preserve the directory structure relative to input root and |
| 27 | +re-create it in the output directory. Please use `python -m dac encode --help` |
| 28 | +for more options. |
| 29 | + |
| 30 | +### Reconstruct audio from compressed codes |
| 31 | +``` |
| 32 | +python3 -m dac decode /path/to/output/codes --output /path/to/reconstructed_input |
| 33 | +``` |
| 34 | + |
| 35 | +This command will create `.wav` files with the same name as the input files. |
| 36 | +It will also preserve the directory structure relative to input root and |
| 37 | +re-create it in the output directory. Please use `python -m dac decode --help` |
| 38 | +for more options. |
| 39 | + |
| 40 | +### Docker image |
| 41 | +We provide a dockerfile to build a docker image with all the necessary |
| 42 | +dependencies. |
| 43 | +1. Building the image. |
| 44 | + ``` |
| 45 | + docker build -t dac . |
| 46 | + ``` |
| 47 | +2. Using the image. |
| 48 | +
|
| 49 | + Usage on CPU: |
| 50 | + ``` |
| 51 | + docker run dac <command> |
| 52 | + ``` |
| 53 | +
|
| 54 | + Usage on GPU: |
| 55 | + ``` |
| 56 | + docker run --gpus=all dac <command> |
| 57 | + ``` |
| 58 | +
|
| 59 | + `<command>` can be one of the compression and reconstruction commands listed |
| 60 | + above. For example, if you want to run compression, |
| 61 | +
|
| 62 | + ``` |
| 63 | + docker run --gpus=all dac python3 -m dac encode ... |
| 64 | + ``` |
| 65 | +
|
| 66 | +
|
| 67 | +## Training |
| 68 | +The baseline model configuration can be trained using the following commands. |
| 69 | +
|
| 70 | +### Pre-requisites |
| 71 | +Please install the correct dependencies |
| 72 | +``` |
| 73 | +pip install -e ".[dev]" |
| 74 | +``` |
| 75 | +
|
| 76 | +
|
| 77 | +### Single GPU training |
| 78 | +``` |
| 79 | +export CUDA_VISIBLE_DEVICES=0 |
| 80 | +python scripts/train.py --args.load conf/ablations/baseline.yml --save_path runs/baseline/ |
| 81 | +``` |
| 82 | +
|
| 83 | +### Multi GPU training |
| 84 | +``` |
| 85 | +export CUDA_VISIBLE_DEVICES=0,1 |
| 86 | +torchrun --nproc_per_node gpu scripts/train.py --args.load conf/ablations/baseline.yml --save_path runs/baseline/ |
| 87 | +``` |
| 88 | +
|
| 89 | +## Testing |
| 90 | +We provide two test scripts to test CLI + training functionality. Please |
| 91 | +make sure that the trainig pre-requisites are satisfied before launching these |
| 92 | +tests. To launch these tests please run |
| 93 | +``` |
| 94 | +python -m pytest tests |
| 95 | +``` |
0 commit comments