notebook update
Browse files- README.md +6 -0
- save_model.ipynb +302 -28
- test_DAC.ipynb +8 -18
README.md
CHANGED
@@ -14,10 +14,16 @@ This model card provides an easy-to-use API for a *pretrained DAC* [1] whose bac
|
|
14 |
|
15 |
# Usage
|
16 |
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
|
19 |
<!--
|
20 |
- different models for different khz
|
|
|
21 |
-->
|
22 |
|
23 |
|
|
|
14 |
|
15 |
# Usage
|
16 |
|
17 |
+
### Load
|
18 |
+
```python
|
19 |
+
from transformers import AutoModel
|
20 |
+
model = AutoModel.from_pretrained('hance-ai/descript-audio-codec', trust_remote_code=True)
|
21 |
+
```
|
22 |
|
23 |
|
24 |
<!--
|
25 |
- different models for different khz
|
26 |
+
- how to adjust model parameters
|
27 |
-->
|
28 |
|
29 |
|
save_model.ipynb
CHANGED
@@ -101,52 +101,307 @@
|
|
101 |
},
|
102 |
{
|
103 |
"cell_type": "code",
|
104 |
-
"execution_count":
|
105 |
"metadata": {},
|
106 |
"outputs": [
|
107 |
{
|
108 |
-
"
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
}
|
120 |
],
|
121 |
"source": [
|
122 |
"# load the uploaded model\n",
|
123 |
"from transformers import AutoModel\n",
|
124 |
-
"model = AutoModel.from_pretrained('hance-ai/descript-audio-codec',
|
|
|
|
|
125 |
]
|
126 |
},
|
127 |
{
|
128 |
"cell_type": "code",
|
129 |
-
"execution_count":
|
130 |
"metadata": {},
|
131 |
-
"outputs": [
|
132 |
-
{
|
133 |
-
"data": {
|
134 |
-
"text/plain": [
|
135 |
-
"device(type='cpu')"
|
136 |
-
]
|
137 |
-
},
|
138 |
-
"execution_count": 9,
|
139 |
-
"metadata": {},
|
140 |
-
"output_type": "execute_result"
|
141 |
-
}
|
142 |
-
],
|
143 |
"source": [
|
144 |
-
"model.
|
145 |
]
|
146 |
},
|
147 |
{
|
148 |
"cell_type": "code",
|
149 |
-
"execution_count":
|
150 |
"metadata": {},
|
151 |
"outputs": [
|
152 |
{
|
@@ -168,6 +423,25 @@
|
|
168 |
"print('zq.shape:', zq.shape)\n",
|
169 |
"print('s.shape:', s.shape)"
|
170 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
}
|
172 |
],
|
173 |
"metadata": {
|
|
|
101 |
},
|
102 |
{
|
103 |
"cell_type": "code",
|
104 |
+
"execution_count": 7,
|
105 |
"metadata": {},
|
106 |
"outputs": [
|
107 |
{
|
108 |
+
"data": {
|
109 |
+
"text/plain": [
|
110 |
+
"DAC(\n",
|
111 |
+
" (dac): DAC(\n",
|
112 |
+
" (encoder): Encoder(\n",
|
113 |
+
" (block): Sequential(\n",
|
114 |
+
" (0): Conv1d(1, 64, kernel_size=(7,), stride=(1,), padding=(3,))\n",
|
115 |
+
" (1): EncoderBlock(\n",
|
116 |
+
" (block): Sequential(\n",
|
117 |
+
" (0): ResidualUnit(\n",
|
118 |
+
" (block): Sequential(\n",
|
119 |
+
" (0): Snake1d()\n",
|
120 |
+
" (1): Conv1d(64, 64, kernel_size=(7,), stride=(1,), padding=(3,))\n",
|
121 |
+
" (2): Snake1d()\n",
|
122 |
+
" (3): Conv1d(64, 64, kernel_size=(1,), stride=(1,))\n",
|
123 |
+
" )\n",
|
124 |
+
" )\n",
|
125 |
+
" (1): ResidualUnit(\n",
|
126 |
+
" (block): Sequential(\n",
|
127 |
+
" (0): Snake1d()\n",
|
128 |
+
" (1): Conv1d(64, 64, kernel_size=(7,), stride=(1,), padding=(9,), dilation=(3,))\n",
|
129 |
+
" (2): Snake1d()\n",
|
130 |
+
" (3): Conv1d(64, 64, kernel_size=(1,), stride=(1,))\n",
|
131 |
+
" )\n",
|
132 |
+
" )\n",
|
133 |
+
" (2): ResidualUnit(\n",
|
134 |
+
" (block): Sequential(\n",
|
135 |
+
" (0): Snake1d()\n",
|
136 |
+
" (1): Conv1d(64, 64, kernel_size=(7,), stride=(1,), padding=(27,), dilation=(9,))\n",
|
137 |
+
" (2): Snake1d()\n",
|
138 |
+
" (3): Conv1d(64, 64, kernel_size=(1,), stride=(1,))\n",
|
139 |
+
" )\n",
|
140 |
+
" )\n",
|
141 |
+
" (3): Snake1d()\n",
|
142 |
+
" (4): Conv1d(64, 128, kernel_size=(4,), stride=(2,), padding=(1,))\n",
|
143 |
+
" )\n",
|
144 |
+
" )\n",
|
145 |
+
" (2): EncoderBlock(\n",
|
146 |
+
" (block): Sequential(\n",
|
147 |
+
" (0): ResidualUnit(\n",
|
148 |
+
" (block): Sequential(\n",
|
149 |
+
" (0): Snake1d()\n",
|
150 |
+
" (1): Conv1d(128, 128, kernel_size=(7,), stride=(1,), padding=(3,))\n",
|
151 |
+
" (2): Snake1d()\n",
|
152 |
+
" (3): Conv1d(128, 128, kernel_size=(1,), stride=(1,))\n",
|
153 |
+
" )\n",
|
154 |
+
" )\n",
|
155 |
+
" (1): ResidualUnit(\n",
|
156 |
+
" (block): Sequential(\n",
|
157 |
+
" (0): Snake1d()\n",
|
158 |
+
" (1): Conv1d(128, 128, kernel_size=(7,), stride=(1,), padding=(9,), dilation=(3,))\n",
|
159 |
+
" (2): Snake1d()\n",
|
160 |
+
" (3): Conv1d(128, 128, kernel_size=(1,), stride=(1,))\n",
|
161 |
+
" )\n",
|
162 |
+
" )\n",
|
163 |
+
" (2): ResidualUnit(\n",
|
164 |
+
" (block): Sequential(\n",
|
165 |
+
" (0): Snake1d()\n",
|
166 |
+
" (1): Conv1d(128, 128, kernel_size=(7,), stride=(1,), padding=(27,), dilation=(9,))\n",
|
167 |
+
" (2): Snake1d()\n",
|
168 |
+
" (3): Conv1d(128, 128, kernel_size=(1,), stride=(1,))\n",
|
169 |
+
" )\n",
|
170 |
+
" )\n",
|
171 |
+
" (3): Snake1d()\n",
|
172 |
+
" (4): Conv1d(128, 256, kernel_size=(8,), stride=(4,), padding=(2,))\n",
|
173 |
+
" )\n",
|
174 |
+
" )\n",
|
175 |
+
" (3): EncoderBlock(\n",
|
176 |
+
" (block): Sequential(\n",
|
177 |
+
" (0): ResidualUnit(\n",
|
178 |
+
" (block): Sequential(\n",
|
179 |
+
" (0): Snake1d()\n",
|
180 |
+
" (1): Conv1d(256, 256, kernel_size=(7,), stride=(1,), padding=(3,))\n",
|
181 |
+
" (2): Snake1d()\n",
|
182 |
+
" (3): Conv1d(256, 256, kernel_size=(1,), stride=(1,))\n",
|
183 |
+
" )\n",
|
184 |
+
" )\n",
|
185 |
+
" (1): ResidualUnit(\n",
|
186 |
+
" (block): Sequential(\n",
|
187 |
+
" (0): Snake1d()\n",
|
188 |
+
" (1): Conv1d(256, 256, kernel_size=(7,), stride=(1,), padding=(9,), dilation=(3,))\n",
|
189 |
+
" (2): Snake1d()\n",
|
190 |
+
" (3): Conv1d(256, 256, kernel_size=(1,), stride=(1,))\n",
|
191 |
+
" )\n",
|
192 |
+
" )\n",
|
193 |
+
" (2): ResidualUnit(\n",
|
194 |
+
" (block): Sequential(\n",
|
195 |
+
" (0): Snake1d()\n",
|
196 |
+
" (1): Conv1d(256, 256, kernel_size=(7,), stride=(1,), padding=(27,), dilation=(9,))\n",
|
197 |
+
" (2): Snake1d()\n",
|
198 |
+
" (3): Conv1d(256, 256, kernel_size=(1,), stride=(1,))\n",
|
199 |
+
" )\n",
|
200 |
+
" )\n",
|
201 |
+
" (3): Snake1d()\n",
|
202 |
+
" (4): Conv1d(256, 512, kernel_size=(16,), stride=(8,), padding=(4,))\n",
|
203 |
+
" )\n",
|
204 |
+
" )\n",
|
205 |
+
" (4): EncoderBlock(\n",
|
206 |
+
" (block): Sequential(\n",
|
207 |
+
" (0): ResidualUnit(\n",
|
208 |
+
" (block): Sequential(\n",
|
209 |
+
" (0): Snake1d()\n",
|
210 |
+
" (1): Conv1d(512, 512, kernel_size=(7,), stride=(1,), padding=(3,))\n",
|
211 |
+
" (2): Snake1d()\n",
|
212 |
+
" (3): Conv1d(512, 512, kernel_size=(1,), stride=(1,))\n",
|
213 |
+
" )\n",
|
214 |
+
" )\n",
|
215 |
+
" (1): ResidualUnit(\n",
|
216 |
+
" (block): Sequential(\n",
|
217 |
+
" (0): Snake1d()\n",
|
218 |
+
" (1): Conv1d(512, 512, kernel_size=(7,), stride=(1,), padding=(9,), dilation=(3,))\n",
|
219 |
+
" (2): Snake1d()\n",
|
220 |
+
" (3): Conv1d(512, 512, kernel_size=(1,), stride=(1,))\n",
|
221 |
+
" )\n",
|
222 |
+
" )\n",
|
223 |
+
" (2): ResidualUnit(\n",
|
224 |
+
" (block): Sequential(\n",
|
225 |
+
" (0): Snake1d()\n",
|
226 |
+
" (1): Conv1d(512, 512, kernel_size=(7,), stride=(1,), padding=(27,), dilation=(9,))\n",
|
227 |
+
" (2): Snake1d()\n",
|
228 |
+
" (3): Conv1d(512, 512, kernel_size=(1,), stride=(1,))\n",
|
229 |
+
" )\n",
|
230 |
+
" )\n",
|
231 |
+
" (3): Snake1d()\n",
|
232 |
+
" (4): Conv1d(512, 1024, kernel_size=(16,), stride=(8,), padding=(4,))\n",
|
233 |
+
" )\n",
|
234 |
+
" )\n",
|
235 |
+
" (5): Snake1d()\n",
|
236 |
+
" (6): Conv1d(1024, 1024, kernel_size=(3,), stride=(1,), padding=(1,))\n",
|
237 |
+
" )\n",
|
238 |
+
" )\n",
|
239 |
+
" (quantizer): ResidualVectorQuantize(\n",
|
240 |
+
" (quantizers): ModuleList(\n",
|
241 |
+
" (0-8): 9 x VectorQuantize(\n",
|
242 |
+
" (in_proj): Conv1d(1024, 8, kernel_size=(1,), stride=(1,))\n",
|
243 |
+
" (out_proj): Conv1d(8, 1024, kernel_size=(1,), stride=(1,))\n",
|
244 |
+
" (codebook): Embedding(1024, 8)\n",
|
245 |
+
" )\n",
|
246 |
+
" )\n",
|
247 |
+
" )\n",
|
248 |
+
" (decoder): Decoder(\n",
|
249 |
+
" (model): Sequential(\n",
|
250 |
+
" (0): Conv1d(1024, 1536, kernel_size=(7,), stride=(1,), padding=(3,))\n",
|
251 |
+
" (1): DecoderBlock(\n",
|
252 |
+
" (block): Sequential(\n",
|
253 |
+
" (0): Snake1d()\n",
|
254 |
+
" (1): ConvTranspose1d(1536, 768, kernel_size=(16,), stride=(8,), padding=(4,))\n",
|
255 |
+
" (2): ResidualUnit(\n",
|
256 |
+
" (block): Sequential(\n",
|
257 |
+
" (0): Snake1d()\n",
|
258 |
+
" (1): Conv1d(768, 768, kernel_size=(7,), stride=(1,), padding=(3,))\n",
|
259 |
+
" (2): Snake1d()\n",
|
260 |
+
" (3): Conv1d(768, 768, kernel_size=(1,), stride=(1,))\n",
|
261 |
+
" )\n",
|
262 |
+
" )\n",
|
263 |
+
" (3): ResidualUnit(\n",
|
264 |
+
" (block): Sequential(\n",
|
265 |
+
" (0): Snake1d()\n",
|
266 |
+
" (1): Conv1d(768, 768, kernel_size=(7,), stride=(1,), padding=(9,), dilation=(3,))\n",
|
267 |
+
" (2): Snake1d()\n",
|
268 |
+
" (3): Conv1d(768, 768, kernel_size=(1,), stride=(1,))\n",
|
269 |
+
" )\n",
|
270 |
+
" )\n",
|
271 |
+
" (4): ResidualUnit(\n",
|
272 |
+
" (block): Sequential(\n",
|
273 |
+
" (0): Snake1d()\n",
|
274 |
+
" (1): Conv1d(768, 768, kernel_size=(7,), stride=(1,), padding=(27,), dilation=(9,))\n",
|
275 |
+
" (2): Snake1d()\n",
|
276 |
+
" (3): Conv1d(768, 768, kernel_size=(1,), stride=(1,))\n",
|
277 |
+
" )\n",
|
278 |
+
" )\n",
|
279 |
+
" )\n",
|
280 |
+
" )\n",
|
281 |
+
" (2): DecoderBlock(\n",
|
282 |
+
" (block): Sequential(\n",
|
283 |
+
" (0): Snake1d()\n",
|
284 |
+
" (1): ConvTranspose1d(768, 384, kernel_size=(16,), stride=(8,), padding=(4,))\n",
|
285 |
+
" (2): ResidualUnit(\n",
|
286 |
+
" (block): Sequential(\n",
|
287 |
+
" (0): Snake1d()\n",
|
288 |
+
" (1): Conv1d(384, 384, kernel_size=(7,), stride=(1,), padding=(3,))\n",
|
289 |
+
" (2): Snake1d()\n",
|
290 |
+
" (3): Conv1d(384, 384, kernel_size=(1,), stride=(1,))\n",
|
291 |
+
" )\n",
|
292 |
+
" )\n",
|
293 |
+
" (3): ResidualUnit(\n",
|
294 |
+
" (block): Sequential(\n",
|
295 |
+
" (0): Snake1d()\n",
|
296 |
+
" (1): Conv1d(384, 384, kernel_size=(7,), stride=(1,), padding=(9,), dilation=(3,))\n",
|
297 |
+
" (2): Snake1d()\n",
|
298 |
+
" (3): Conv1d(384, 384, kernel_size=(1,), stride=(1,))\n",
|
299 |
+
" )\n",
|
300 |
+
" )\n",
|
301 |
+
" (4): ResidualUnit(\n",
|
302 |
+
" (block): Sequential(\n",
|
303 |
+
" (0): Snake1d()\n",
|
304 |
+
" (1): Conv1d(384, 384, kernel_size=(7,), stride=(1,), padding=(27,), dilation=(9,))\n",
|
305 |
+
" (2): Snake1d()\n",
|
306 |
+
" (3): Conv1d(384, 384, kernel_size=(1,), stride=(1,))\n",
|
307 |
+
" )\n",
|
308 |
+
" )\n",
|
309 |
+
" )\n",
|
310 |
+
" )\n",
|
311 |
+
" (3): DecoderBlock(\n",
|
312 |
+
" (block): Sequential(\n",
|
313 |
+
" (0): Snake1d()\n",
|
314 |
+
" (1): ConvTranspose1d(384, 192, kernel_size=(8,), stride=(4,), padding=(2,))\n",
|
315 |
+
" (2): ResidualUnit(\n",
|
316 |
+
" (block): Sequential(\n",
|
317 |
+
" (0): Snake1d()\n",
|
318 |
+
" (1): Conv1d(192, 192, kernel_size=(7,), stride=(1,), padding=(3,))\n",
|
319 |
+
" (2): Snake1d()\n",
|
320 |
+
" (3): Conv1d(192, 192, kernel_size=(1,), stride=(1,))\n",
|
321 |
+
" )\n",
|
322 |
+
" )\n",
|
323 |
+
" (3): ResidualUnit(\n",
|
324 |
+
" (block): Sequential(\n",
|
325 |
+
" (0): Snake1d()\n",
|
326 |
+
" (1): Conv1d(192, 192, kernel_size=(7,), stride=(1,), padding=(9,), dilation=(3,))\n",
|
327 |
+
" (2): Snake1d()\n",
|
328 |
+
" (3): Conv1d(192, 192, kernel_size=(1,), stride=(1,))\n",
|
329 |
+
" )\n",
|
330 |
+
" )\n",
|
331 |
+
" (4): ResidualUnit(\n",
|
332 |
+
" (block): Sequential(\n",
|
333 |
+
" (0): Snake1d()\n",
|
334 |
+
" (1): Conv1d(192, 192, kernel_size=(7,), stride=(1,), padding=(27,), dilation=(9,))\n",
|
335 |
+
" (2): Snake1d()\n",
|
336 |
+
" (3): Conv1d(192, 192, kernel_size=(1,), stride=(1,))\n",
|
337 |
+
" )\n",
|
338 |
+
" )\n",
|
339 |
+
" )\n",
|
340 |
+
" )\n",
|
341 |
+
" (4): DecoderBlock(\n",
|
342 |
+
" (block): Sequential(\n",
|
343 |
+
" (0): Snake1d()\n",
|
344 |
+
" (1): ConvTranspose1d(192, 96, kernel_size=(4,), stride=(2,), padding=(1,))\n",
|
345 |
+
" (2): ResidualUnit(\n",
|
346 |
+
" (block): Sequential(\n",
|
347 |
+
" (0): Snake1d()\n",
|
348 |
+
" (1): Conv1d(96, 96, kernel_size=(7,), stride=(1,), padding=(3,))\n",
|
349 |
+
" (2): Snake1d()\n",
|
350 |
+
" (3): Conv1d(96, 96, kernel_size=(1,), stride=(1,))\n",
|
351 |
+
" )\n",
|
352 |
+
" )\n",
|
353 |
+
" (3): ResidualUnit(\n",
|
354 |
+
" (block): Sequential(\n",
|
355 |
+
" (0): Snake1d()\n",
|
356 |
+
" (1): Conv1d(96, 96, kernel_size=(7,), stride=(1,), padding=(9,), dilation=(3,))\n",
|
357 |
+
" (2): Snake1d()\n",
|
358 |
+
" (3): Conv1d(96, 96, kernel_size=(1,), stride=(1,))\n",
|
359 |
+
" )\n",
|
360 |
+
" )\n",
|
361 |
+
" (4): ResidualUnit(\n",
|
362 |
+
" (block): Sequential(\n",
|
363 |
+
" (0): Snake1d()\n",
|
364 |
+
" (1): Conv1d(96, 96, kernel_size=(7,), stride=(1,), padding=(27,), dilation=(9,))\n",
|
365 |
+
" (2): Snake1d()\n",
|
366 |
+
" (3): Conv1d(96, 96, kernel_size=(1,), stride=(1,))\n",
|
367 |
+
" )\n",
|
368 |
+
" )\n",
|
369 |
+
" )\n",
|
370 |
+
" )\n",
|
371 |
+
" (5): Snake1d()\n",
|
372 |
+
" (6): Conv1d(96, 1, kernel_size=(7,), stride=(1,), padding=(3,))\n",
|
373 |
+
" (7): Tanh()\n",
|
374 |
+
" )\n",
|
375 |
+
" )\n",
|
376 |
+
" )\n",
|
377 |
+
")"
|
378 |
+
]
|
379 |
+
},
|
380 |
+
"execution_count": 7,
|
381 |
+
"metadata": {},
|
382 |
+
"output_type": "execute_result"
|
383 |
}
|
384 |
],
|
385 |
"source": [
|
386 |
"# load the uploaded model\n",
|
387 |
"from transformers import AutoModel\n",
|
388 |
+
"model = AutoModel.from_pretrained('hance-ai/descript-audio-codec', \n",
|
389 |
+
" trust_remote_code=True)\n",
|
390 |
+
"model.to('cpu')"
|
391 |
]
|
392 |
},
|
393 |
{
|
394 |
"cell_type": "code",
|
395 |
+
"execution_count": null,
|
396 |
"metadata": {},
|
397 |
+
"outputs": [],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
398 |
"source": [
|
399 |
+
"model."
|
400 |
]
|
401 |
},
|
402 |
{
|
403 |
"cell_type": "code",
|
404 |
+
"execution_count": 8,
|
405 |
"metadata": {},
|
406 |
"outputs": [
|
407 |
{
|
|
|
423 |
"print('zq.shape:', zq.shape)\n",
|
424 |
"print('s.shape:', s.shape)"
|
425 |
]
|
426 |
+
},
|
427 |
+
{
|
428 |
+
"cell_type": "code",
|
429 |
+
"execution_count": 12,
|
430 |
+
"metadata": {},
|
431 |
+
"outputs": [
|
432 |
+
{
|
433 |
+
"name": "stdout",
|
434 |
+
"output_type": "stream",
|
435 |
+
"text": [
|
436 |
+
"waveform.shape: torch.Size([1, 1, 441344])\n"
|
437 |
+
]
|
438 |
+
}
|
439 |
+
],
|
440 |
+
"source": [
|
441 |
+
"# decoding (from zq -- discrete latent vectors)\n",
|
442 |
+
"waveform = model.decode(zq=zq)\n",
|
443 |
+
"print('waveform.shape:', waveform.shape)"
|
444 |
+
]
|
445 |
}
|
446 |
],
|
447 |
"metadata": {
|
test_DAC.ipynb
CHANGED
@@ -9,41 +9,31 @@
|
|
9 |
},
|
10 |
{
|
11 |
"cell_type": "code",
|
12 |
-
"execution_count":
|
13 |
"metadata": {},
|
14 |
-
"outputs": [
|
15 |
-
{
|
16 |
-
"name": "stderr",
|
17 |
-
"output_type": "stream",
|
18 |
-
"text": [
|
19 |
-
"C:\\Users\\dslee\\AppData\\Roaming\\Python\\Python38\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
|
20 |
-
" from .autonotebook import tqdm as notebook_tqdm\n"
|
21 |
-
]
|
22 |
-
}
|
23 |
-
],
|
24 |
"source": [
|
25 |
"import os\n",
|
26 |
"from pathlib import Path\n",
|
27 |
"\n",
|
28 |
-
"import torch\n",
|
29 |
-
"\n",
|
30 |
"from model import DAC, DACConfig"
|
31 |
]
|
32 |
},
|
33 |
{
|
34 |
"cell_type": "code",
|
35 |
-
"execution_count":
|
36 |
"metadata": {},
|
37 |
"outputs": [],
|
38 |
"source": [
|
39 |
"# settings\n",
|
40 |
"fname = str(Path(os.getcwd()).joinpath('.sample_sound', 'jazz_swing.wav'))\n",
|
41 |
-
"device = 'cpu'"
|
|
|
42 |
]
|
43 |
},
|
44 |
{
|
45 |
"cell_type": "code",
|
46 |
-
"execution_count":
|
47 |
"metadata": {},
|
48 |
"outputs": [
|
49 |
{
|
@@ -59,13 +49,13 @@
|
|
59 |
],
|
60 |
"source": [
|
61 |
"# load the model\n",
|
62 |
-
"config = DACConfig()\n",
|
63 |
"dac = DAC(config).to(device)"
|
64 |
]
|
65 |
},
|
66 |
{
|
67 |
"cell_type": "code",
|
68 |
-
"execution_count":
|
69 |
"metadata": {},
|
70 |
"outputs": [
|
71 |
{
|
|
|
9 |
},
|
10 |
{
|
11 |
"cell_type": "code",
|
12 |
+
"execution_count": 12,
|
13 |
"metadata": {},
|
14 |
+
"outputs": [],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
"source": [
|
16 |
"import os\n",
|
17 |
"from pathlib import Path\n",
|
18 |
"\n",
|
|
|
|
|
19 |
"from model import DAC, DACConfig"
|
20 |
]
|
21 |
},
|
22 |
{
|
23 |
"cell_type": "code",
|
24 |
+
"execution_count": 13,
|
25 |
"metadata": {},
|
26 |
"outputs": [],
|
27 |
"source": [
|
28 |
"# settings\n",
|
29 |
"fname = str(Path(os.getcwd()).joinpath('.sample_sound', 'jazz_swing.wav'))\n",
|
30 |
+
"device = 'cpu'\n",
|
31 |
+
"model_type_by_sampling_freq = '44khz'"
|
32 |
]
|
33 |
},
|
34 |
{
|
35 |
"cell_type": "code",
|
36 |
+
"execution_count": 9,
|
37 |
"metadata": {},
|
38 |
"outputs": [
|
39 |
{
|
|
|
49 |
],
|
50 |
"source": [
|
51 |
"# load the model\n",
|
52 |
+
"config = DACConfig(model_type_by_sampling_freq=model_type_by_sampling_freq)\n",
|
53 |
"dac = DAC(config).to(device)"
|
54 |
]
|
55 |
},
|
56 |
{
|
57 |
"cell_type": "code",
|
58 |
+
"execution_count": 11,
|
59 |
"metadata": {},
|
60 |
"outputs": [
|
61 |
{
|