-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a436c61
Showing
60 changed files
with
4,007 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.pth | ||
*.wav | ||
*.dac | ||
tests/ | ||
runs/ |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/env.sh | ||
venv/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# Files created by experiments | ||
output/ | ||
snapshot/ | ||
*.m4a | ||
*.wav | ||
notebooks/scratch.ipynb | ||
notebooks/inspect.ipynb | ||
notebooks/effects.ipynb | ||
notebooks/*.ipynb | ||
notebooks/*.gif | ||
notebooks/*.wav | ||
notebooks/*.mp4 | ||
*runs/ | ||
boards/ | ||
samples/ | ||
*.ipynb | ||
|
||
results.json | ||
metrics.csv | ||
mprofile_* | ||
mem.png | ||
|
||
results/ | ||
mprofile* | ||
*.png | ||
# do not ignore the test wav file | ||
!tests/audio/short_test_audio.wav | ||
!tests/audio/output.wav | ||
*/.DS_Store | ||
.DS_Store | ||
env.sh | ||
_codebraid/ | ||
**/*.html | ||
**/*.exec.md | ||
flagged/ | ||
log.txt | ||
ckpt/ | ||
.syncthing* | ||
tests/assets/ | ||
archived/ | ||
|
||
*_remote_module_* | ||
*.zip | ||
*.pth | ||
encoded_out/ | ||
recon/ | ||
recons/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
repos: | ||
- repo: https://github.com/asottile/reorder_python_imports | ||
rev: v2.5.0 | ||
hooks: | ||
- id: reorder-python-imports | ||
- repo: https://github.com/psf/black | ||
rev: 23.1.0 | ||
hooks: | ||
- id: black | ||
language_version: python3 | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.0.1 | ||
hooks: | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime | ||
|
||
COPY . /app | ||
WORKDIR /app | ||
|
||
RUN apt update && apt install -y git | ||
# install the package | ||
RUN pip install . | ||
|
||
# cache the model | ||
RUN python3 -m dac download |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023-present, Descript | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Descript Audio Codec (.dac) | ||
|
||
<!-- ![](https://static.arxiv.org/static/browse/0.3.4/images/icons/favicon-32x32.png) --> | ||
|
||
|
||
This repository contains training and inference scripts | ||
for the Descript Audio Codec (.dac), a high fidelity general | ||
neural audio codec. | ||
|
||
|
||
## Usage | ||
|
||
### Installation | ||
``` | ||
git clone https://github.com/descriptinc/descript-audio-codec | ||
cd descript-audio-codec | ||
pip install . | ||
``` | ||
|
||
### Compress audio | ||
``` | ||
python3 -m dac encode /path/to/input --output /path/to/output/codes | ||
``` | ||
|
||
This command will create `.dac` files with the same name as the input files. | ||
It will also preserve the directory structure relative to input root and | ||
re-create it in the output directory. Please use `python -m dac encode --help` | ||
for more options. | ||
|
||
### Reconstruct audio from compressed codes | ||
``` | ||
python3 -m dac decode /path/to/output/codes --output /path/to/reconstructed_input | ||
``` | ||
|
||
This command will create `.wav` files with the same name as the input files. | ||
It will also preserve the directory structure relative to input root and | ||
re-create it in the output directory. Please use `python -m dac decode --help` | ||
for more options. | ||
|
||
### Docker image | ||
We provide a dockerfile to build a docker image with all the necessary | ||
dependencies. | ||
1. Building the image. | ||
``` | ||
docker build -t dac . | ||
``` | ||
2. Using the image. | ||
Usage on CPU: | ||
``` | ||
docker run dac <command> | ||
``` | ||
Usage on GPU: | ||
``` | ||
docker run --gpus=all dac <command> | ||
``` | ||
`<command>` can be one of the compression and reconstruction commands listed | ||
above. For example, if you want to run compression, | ||
``` | ||
docker run --gpus=all dac python3 -m dac encode ... | ||
``` | ||
## Training | ||
The baseline model configuration can be trained using the following commands. | ||
### Pre-requisites | ||
Please install the correct dependencies | ||
``` | ||
pip install -e ".[dev]" | ||
``` | ||
### Single GPU training | ||
``` | ||
export CUDA_VISIBLE_DEVICES=0 | ||
python scripts/train.py --args.load conf/ablations/baseline.yml --save_path runs/baseline/ | ||
``` | ||
### Multi GPU training | ||
``` | ||
export CUDA_VISIBLE_DEVICES=0,1 | ||
torchrun --nproc_per_node gpu scripts/train.py --args.load conf/ablations/baseline.yml --save_path runs/baseline/ | ||
``` | ||
## Testing | ||
We provide two test scripts to test CLI + training functionality. Please | ||
make sure that the trainig pre-requisites are satisfied before launching these | ||
tests. To launch these tests please run | ||
``` | ||
python -m pytest tests | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
$include: | ||
- conf/base.yml | ||
|
||
batch_size: 12 | ||
val_batch_size: 12 | ||
num_workers: 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$include: | ||
- conf/base.yml | ||
- conf/1gpu.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
$include: | ||
- conf/base.yml | ||
- conf/1gpu.yml | ||
|
||
Discriminator.sample_rate: 44100 | ||
Discriminator.fft_sizes: [2048, 1024, 512] | ||
Discriminator.bands: | ||
- [0.0, 0.05] | ||
- [0.05, 0.1] | ||
- [0.1, 0.25] | ||
- [0.25, 0.5] | ||
- [0.5, 1.0] | ||
|
||
|
||
# re-weight lambdas to make up for | ||
# lost discriminators vs baseline | ||
lambdas: | ||
mel/loss: 15.0 | ||
adv/feat_loss: 5.0 | ||
adv/gen_loss: 1.0 | ||
vq/commitment_loss: 0.25 | ||
vq/codebook_loss: 1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
$include: | ||
- conf/base.yml | ||
- conf/1gpu.yml | ||
|
||
Discriminator.sample_rate: 44100 | ||
Discriminator.fft_sizes: [2048, 1024, 512] | ||
Discriminator.bands: | ||
- [0.0, 0.2] | ||
- [0.2, 0.4] | ||
- [0.4, 0.6] | ||
- [0.6, 0.8] | ||
- [0.8, 1.0] | ||
|
||
|
||
# re-weight lambdas to make up for | ||
# lost discriminators vs baseline | ||
lambdas: | ||
mel/loss: 15.0 | ||
adv/feat_loss: 5.0 | ||
adv/gen_loss: 1.0 | ||
vq/commitment_loss: 0.25 | ||
vq/codebook_loss: 1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
$include: | ||
- conf/base.yml | ||
- conf/1gpu.yml | ||
|
||
lambdas: | ||
mel/loss: 1.0 | ||
waveform/loss: 1.0 | ||
vq/commitment_loss: 0.25 | ||
vq/codebook_loss: 1.0 |
Oops, something went wrong.