From ac4323d6c1e2128e5a09402babf1489158d40537 Mon Sep 17 00:00:00 2001 From: Ishaan Kumar Date: Wed, 14 Jun 2023 16:19:24 -0400 Subject: [PATCH] Prepare for pypi release (#6) * update versions + deps * update readme * add programmatic usage section * lint correction * bug fix for odd strikes --- .gitignore | 2 +- README.md | 42 ++++++++++++++++++++++++++++++++++++++---- dac/__init__.py | 2 +- dac/__main__.py | 1 - dac/model/dac.py | 4 ++-- setup.py | 4 ++-- 6 files changed, 44 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index a7f37b9..d54f088 100644 --- a/.gitignore +++ b/.gitignore @@ -172,5 +172,5 @@ archived/ *.zip *.pth encoded_out/ -recon/ +recon/ recons/ diff --git a/README.md b/README.md index b4be9ea..73abf82 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,12 @@ neural audio codec, introduced in the paper titled **High-Fidelity Audio Compres ### Installation ``` -git clone https://github.com/descriptinc/descript-audio-codec -cd descript-audio-codec -pip install . +pip install descript-audio-codec +``` +OR + +``` +pip install git+https://github.com/descriptinc/descript-audio-codec ``` ### Weights @@ -36,7 +39,6 @@ python3 -m dac download We provide a Dockerfile that installs all required dependencies for encoding and decoding. The build process caches model weights inside the image. This allows the image to be used without an internet connection. [Please refer to instructions below.](#docker-image) - ### Compress audio ``` python3 -m dac encode /path/to/input --output /path/to/output/codes @@ -57,6 +59,38 @@ 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. +### Programmatic Usage +```py +import dac +from dac.utils import load_model +from dac.model import DAC + +from dac.utils.encode import process as encode +from dac.utils.decode import process as decode + +from audiotools import AudioSignal + +# Init an empty model +model = DAC() + +# Load compatible pre-trained model +model = load_model(dac.__model_version__) +model.eval() +model.to('cuda') + +# Load audio signal file +signal = AudioSignal('input.wav') + +# Encode audio signal +encoded_out = encode(signal, 'cuda', model) + +# Decode audio signal +recon = decode(encoded_out, 'cuda', model, preserve_sample_rate=True) + +# Write to file +recon.write('recon.wav') +``` + ### Docker image We provide a dockerfile to build a docker image with all the necessary dependencies. diff --git a/dac/__init__.py b/dac/__init__.py index bb6e173..d872b73 100644 --- a/dac/__init__.py +++ b/dac/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.0.1" +__version__ = "0.0.2" __model_version__ = "0.0.1" import audiotools diff --git a/dac/__main__.py b/dac/__main__.py index 338b238..c19e004 100644 --- a/dac/__main__.py +++ b/dac/__main__.py @@ -25,7 +25,6 @@ def run(stage: str): stage_fn() return - stage_fn() diff --git a/dac/model/dac.py b/dac/model/dac.py index f7fd762..b5a29b2 100644 --- a/dac/model/dac.py +++ b/dac/model/dac.py @@ -49,7 +49,7 @@ def __init__(self, dim: int = 16, stride: int = 1): dim, kernel_size=2 * stride, stride=stride, - padding=stride // 2, + padding=math.ceil(stride / 2), ), ) @@ -96,7 +96,7 @@ def __init__(self, input_dim: int = 16, output_dim: int = 8, stride: int = 1): output_dim, kernel_size=2 * stride, stride=stride, - padding=stride // 2, + padding=math.ceil(stride / 2), ), ResidualUnit(output_dim, dilation=1), ResidualUnit(output_dim, dilation=3), diff --git a/setup.py b/setup.py index bcab119..8af83fd 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="dac", - version="0.0.1", + version="0.0.2", classifiers=[ "Intended Audience :: Developers", "Natural Language :: English", @@ -28,7 +28,7 @@ keywords=["audio", "compression", "machine learning"], install_requires=[ "argbind>=0.3.7", - "audiotools @ git+https://github.com/descriptinc/audiotools.git@0.7.0", + "descript-audiotools==0.7.1", "einops", "numpy", "torch",