Skip to content

Commit

Permalink
Prepare for pypi release (#6)
Browse files Browse the repository at this point in the history
* update versions + deps

* update readme

* add programmatic usage section

* lint correction

* bug fix for odd strikes
  • Loading branch information
eeishaan authored Jun 14, 2023
1 parent 98e762e commit ac4323d
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,5 @@ archived/
*.zip
*.pth
encoded_out/
recon/
recon/
recons/
42 changes: 38 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion dac/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.0.1"
__version__ = "0.0.2"
__model_version__ = "0.0.1"
import audiotools

Expand Down
1 change: 0 additions & 1 deletion dac/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def run(stage: str):
stage_fn()
return


stage_fn()


Expand Down
4 changes: 2 additions & 2 deletions dac/model/dac.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
)

Expand Down Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="dac",
version="0.0.1",
version="0.0.2",
classifiers=[
"Intended Audience :: Developers",
"Natural Language :: English",
Expand All @@ -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",
Expand Down

0 comments on commit ac4323d

Please sign in to comment.