Update README.md
Browse files
README.md
CHANGED
@@ -3,9 +3,37 @@ license: mit
|
|
3 |
tags:
|
4 |
- model_hub_mixin
|
5 |
- pytorch_model_hub_mixin
|
|
|
|
|
6 |
---
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
tags:
|
4 |
- model_hub_mixin
|
5 |
- pytorch_model_hub_mixin
|
6 |
+
base_model:
|
7 |
+
- Alethia/BigCodec
|
8 |
---
|
9 |
|
10 |
+
# BigCodec
|
11 |
+
|
12 |
+
Python library for bigcodec. This is something that the author of bigcodec didn't do, so I'm doing it for him.
|
13 |
+
|
14 |
+
## Setup
|
15 |
+
|
16 |
+
```
|
17 |
+
pip install bigcodec
|
18 |
+
```
|
19 |
+
|
20 |
+
## Usage
|
21 |
+
|
22 |
+
```
|
23 |
+
import torch.accelerator
|
24 |
+
from bigcodec import BigCodec
|
25 |
+
import torchaudio
|
26 |
+
|
27 |
+
codec = BigCodec.from_pretrained("intexcp/bigcodec")
|
28 |
+
|
29 |
+
wav = torchaudio.load("enc.wav")[0]
|
30 |
+
wav = wav.unsqueeze(0)
|
31 |
+
device = torch.accelerator.current_accelerator().type if torch.accelerator.is_available() else "cpu"
|
32 |
+
codec = codec.to(device)
|
33 |
+
wav = wav.to(device)
|
34 |
+
with torch.no_grad():
|
35 |
+
enc = codec.encode(wav)
|
36 |
+
dec = codec.decode(enc)
|
37 |
+
print(enc)
|
38 |
+
torchaudio.save("dec.wav", dec.squeeze(0).cpu(), 16000, encoding="PCM_F")
|
39 |
+
```
|