Skip to content

Commit ac4323d

Browse files
authored
Prepare for pypi release (#6)
* update versions + deps * update readme * add programmatic usage section * lint correction * bug fix for odd strikes
1 parent 98e762e commit ac4323d

File tree

6 files changed

+44
-11
lines changed

6 files changed

+44
-11
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,5 @@ archived/
172172
*.zip
173173
*.pth
174174
encoded_out/
175-
recon/
175+
recon/
176176
recons/

README.md

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ neural audio codec, introduced in the paper titled **High-Fidelity Audio Compres
2222

2323
### Installation
2424
```
25-
git clone https://github.com/descriptinc/descript-audio-codec
26-
cd descript-audio-codec
27-
pip install .
25+
pip install descript-audio-codec
26+
```
27+
OR
28+
29+
```
30+
pip install git+https://github.com/descriptinc/descript-audio-codec
2831
```
2932

3033
### Weights
@@ -36,7 +39,6 @@ python3 -m dac download
3639
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)
3740

3841

39-
4042
### Compress audio
4143
```
4244
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
5759
re-create it in the output directory. Please use `python -m dac decode --help`
5860
for more options.
5961

62+
### Programmatic Usage
63+
```py
64+
import dac
65+
from dac.utils import load_model
66+
from dac.model import DAC
67+
68+
from dac.utils.encode import process as encode
69+
from dac.utils.decode import process as decode
70+
71+
from audiotools import AudioSignal
72+
73+
# Init an empty model
74+
model = DAC()
75+
76+
# Load compatible pre-trained model
77+
model = load_model(dac.__model_version__)
78+
model.eval()
79+
model.to('cuda')
80+
81+
# Load audio signal file
82+
signal = AudioSignal('input.wav')
83+
84+
# Encode audio signal
85+
encoded_out = encode(signal, 'cuda', model)
86+
87+
# Decode audio signal
88+
recon = decode(encoded_out, 'cuda', model, preserve_sample_rate=True)
89+
90+
# Write to file
91+
recon.write('recon.wav')
92+
```
93+
6094
### Docker image
6195
We provide a dockerfile to build a docker image with all the necessary
6296
dependencies.

dac/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.0.1"
1+
__version__ = "0.0.2"
22
__model_version__ = "0.0.1"
33
import audiotools
44

dac/__main__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def run(stage: str):
2525
stage_fn()
2626
return
2727

28-
2928
stage_fn()
3029

3130

dac/model/dac.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __init__(self, dim: int = 16, stride: int = 1):
4949
dim,
5050
kernel_size=2 * stride,
5151
stride=stride,
52-
padding=stride // 2,
52+
padding=math.ceil(stride / 2),
5353
),
5454
)
5555

@@ -96,7 +96,7 @@ def __init__(self, input_dim: int = 16, output_dim: int = 8, stride: int = 1):
9696
output_dim,
9797
kernel_size=2 * stride,
9898
stride=stride,
99-
padding=stride // 2,
99+
padding=math.ceil(stride / 2),
100100
),
101101
ResidualUnit(output_dim, dilation=1),
102102
ResidualUnit(output_dim, dilation=3),

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name="dac",
9-
version="0.0.1",
9+
version="0.0.2",
1010
classifiers=[
1111
"Intended Audience :: Developers",
1212
"Natural Language :: English",
@@ -28,7 +28,7 @@
2828
keywords=["audio", "compression", "machine learning"],
2929
install_requires=[
3030
"argbind>=0.3.7",
31-
"audiotools @ git+https://github.com/descriptinc/audiotools.git@0.7.0",
31+
"descript-audiotools==0.7.1",
3232
"einops",
3333
"numpy",
3434
"torch",

0 commit comments

Comments
 (0)