hubertsiuzdak
commited on
Commit
•
c84c6ac
1
Parent(s):
9ec51ea
Update README.md
Browse files
README.md
CHANGED
@@ -37,7 +37,7 @@ Install it using:
|
|
37 |
```bash
|
38 |
pip install snac
|
39 |
```
|
40 |
-
To encode (and
|
41 |
|
42 |
```python
|
43 |
import torch
|
@@ -47,7 +47,15 @@ model = SNAC.from_pretrained("hubertsiuzdak/snac_32khz").eval().cuda()
|
|
47 |
audio = torch.randn(1, 1, 32000).cuda() # B, 1, T
|
48 |
|
49 |
with torch.inference_mode():
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
```
|
52 |
|
53 |
⚠️ Note that `codes` is a list of token sequences of variable lengths, each corresponding to a different temporal
|
|
|
37 |
```bash
|
38 |
pip install snac
|
39 |
```
|
40 |
+
To encode (and decode) audio with SNAC in Python, use the following code:
|
41 |
|
42 |
```python
|
43 |
import torch
|
|
|
47 |
audio = torch.randn(1, 1, 32000).cuda() # B, 1, T
|
48 |
|
49 |
with torch.inference_mode():
|
50 |
+
codes = model.encode(audio)
|
51 |
+
audio_hat = model.decode(codes)
|
52 |
+
```
|
53 |
+
|
54 |
+
You can also encode and reconstruct in a single call:
|
55 |
+
|
56 |
+
```python
|
57 |
+
with torch.inference_mode():
|
58 |
+
audio_hat, codes = model(audio)
|
59 |
```
|
60 |
|
61 |
⚠️ Note that `codes` is a list of token sequences of variable lengths, each corresponding to a different temporal
|