Spaces:
Running
Running
Kit-Lemonfoot
commited on
Commit
•
6613f80
1
Parent(s):
c8b0ba8
Fixed deprecation issue, added new EN and Gram Pico.
Browse files- .gitattributes +6 -0
- lib/infer_pack/models.py +1125 -1124
- lib/infer_pack/models_onnx.py +820 -819
- lib/infer_pack/modules.py +524 -522
- weights/hololive-en/Cecilia/Cecilia_KitLemonfoot.pth +3 -0
- weights/hololive-en/Cecilia/added_IVF1477_Flat_nprobe_1_CeciliaImmergreen_Singing_KitLemonfoot_v2_mbkm.index +3 -0
- weights/hololive-en/Cecilia/cover.png +0 -0
- weights/hololive-en/Elizabeth/Elizabeth_Dacoolkid.pth +3 -0
- weights/hololive-en/Elizabeth/added_IVF1418_Flat_nprobe_1_Elizabeth_Rose_Bloodflame_v2.index +3 -0
- weights/hololive-en/Elizabeth/added_IVF1418_Flat_nprobe_1_Elizabeth_Rose_Bloodflame_v2_mbkm.index +3 -0
- weights/hololive-en/Elizabeth/cover.png +0 -0
- weights/hololive-en/Gigi/Gigi_HinaBl.pth +3 -0
- weights/hololive-en/Gigi/added_IVF1648_Flat_nprobe_1_gigi-murin_v2_mbkm.index +3 -0
- weights/hololive-en/Gigi/cover.png +0 -0
- weights/hololive-en/Raora/Raora_00a.pth +3 -0
- weights/hololive-en/Raora/added_IVF2050_Flat_nprobe_1_raora_v2_mbkm.index +3 -0
- weights/hololive-en/Raora/cover.png +0 -0
- weights/hololive-en/model_info.json +161 -129
- weights/phaseconnect/Pico/Pico_Sxndypz.pth +3 -0
- weights/phaseconnect/Pico/added_IVF1132_Flat_nprobe_1_grampico_v2_mbkm.index +3 -0
- weights/phaseconnect/Pico/cover.png +0 -0
- weights/phaseconnect/model_info.json +12 -4
.gitattributes
CHANGED
@@ -385,3 +385,9 @@ weights/holostars/Rikka/added_IVF2819_Flat_nprobe_1_Rikkaroid_Hybrid_KitLemonfoo
|
|
385 |
weights/other/Sakana/added_IVF853_Flat_nprobe_1_h2osakana_v2_mbkm.index filter=lfs diff=lfs merge=lfs -text
|
386 |
weights/phaseconnect/Runie/added_IVF1386_Flat_nprobe_1_runie_v2_mbkm.index filter=lfs diff=lfs merge=lfs -text
|
387 |
weights/phaseconnect/Lumi/added_IVF1260_Flat_nprobe_1_kanekolumi_v2_mbkm.index filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
385 |
weights/other/Sakana/added_IVF853_Flat_nprobe_1_h2osakana_v2_mbkm.index filter=lfs diff=lfs merge=lfs -text
|
386 |
weights/phaseconnect/Runie/added_IVF1386_Flat_nprobe_1_runie_v2_mbkm.index filter=lfs diff=lfs merge=lfs -text
|
387 |
weights/phaseconnect/Lumi/added_IVF1260_Flat_nprobe_1_kanekolumi_v2_mbkm.index filter=lfs diff=lfs merge=lfs -text
|
388 |
+
weights/hololive-en/Cecilia/added_IVF1477_Flat_nprobe_1_CeciliaImmergreen_Singing_KitLemonfoot_v2_mbkm.index filter=lfs diff=lfs merge=lfs -text
|
389 |
+
weights/hololive-en/Elizabeth/added_IVF1418_Flat_nprobe_1_Elizabeth_Rose_Bloodflame_v2_mbkm.index filter=lfs diff=lfs merge=lfs -text
|
390 |
+
weights/hololive-en/Elizabeth/added_IVF1418_Flat_nprobe_1_Elizabeth_Rose_Bloodflame_v2.index filter=lfs diff=lfs merge=lfs -text
|
391 |
+
weights/hololive-en/Gigi/added_IVF1648_Flat_nprobe_1_gigi-murin_v2_mbkm.index filter=lfs diff=lfs merge=lfs -text
|
392 |
+
weights/hololive-en/Raora/added_IVF2050_Flat_nprobe_1_raora_v2_mbkm.index filter=lfs diff=lfs merge=lfs -text
|
393 |
+
weights/phaseconnect/Pico/added_IVF1132_Flat_nprobe_1_grampico_v2_mbkm.index filter=lfs diff=lfs merge=lfs -text
|
lib/infer_pack/models.py
CHANGED
@@ -1,1124 +1,1125 @@
|
|
1 |
-
import math, pdb, os
|
2 |
-
from time import time as ttime
|
3 |
-
import torch
|
4 |
-
from torch import nn
|
5 |
-
from torch.nn import functional as F
|
6 |
-
from lib.infer_pack import modules
|
7 |
-
from lib.infer_pack import attentions
|
8 |
-
from lib.infer_pack import commons
|
9 |
-
from lib.infer_pack.commons import init_weights, get_padding
|
10 |
-
from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d
|
11 |
-
from torch.nn.utils import
|
12 |
-
from
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
self.
|
32 |
-
self.
|
33 |
-
self.
|
34 |
-
self.
|
35 |
-
self.
|
36 |
-
self.
|
37 |
-
self.
|
38 |
-
self.
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
x = self.
|
53 |
-
x =
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
self.
|
79 |
-
self.
|
80 |
-
self.
|
81 |
-
self.
|
82 |
-
self.
|
83 |
-
self.
|
84 |
-
self.
|
85 |
-
self.
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
x = self.
|
100 |
-
x =
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
self.
|
125 |
-
self.
|
126 |
-
self.
|
127 |
-
self.
|
128 |
-
self.
|
129 |
-
self.
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
self.
|
174 |
-
self.
|
175 |
-
self.
|
176 |
-
self.
|
177 |
-
self.
|
178 |
-
self.
|
179 |
-
|
180 |
-
|
181 |
-
self.
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
x = self.
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
self.
|
219 |
-
self.
|
220 |
-
self.
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
upsample_initial_channel // (2
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
self.
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
x =
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
x =
|
270 |
-
x =
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
self.
|
308 |
-
self.
|
309 |
-
self.
|
310 |
-
self.
|
311 |
-
self.
|
312 |
-
self.
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
uv
|
317 |
-
uv =
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
output
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
tmp_over_one
|
344 |
-
tmp_over_one
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
cumsum_shift
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
uv =
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
SourceModule
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
self.
|
404 |
-
self.
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
self.
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
self.
|
438 |
-
self.
|
439 |
-
|
440 |
-
|
441 |
-
self.
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
self.
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
upsample_initial_channel // (2
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
self.
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
har_source =
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
x =
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
x =
|
515 |
-
x =
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
"
|
528 |
-
"
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
self.
|
560 |
-
self.
|
561 |
-
self.
|
562 |
-
self.
|
563 |
-
self.
|
564 |
-
self.
|
565 |
-
self.
|
566 |
-
self.
|
567 |
-
self.
|
568 |
-
self.
|
569 |
-
self.
|
570 |
-
self.
|
571 |
-
self.
|
572 |
-
self.
|
573 |
-
self.
|
574 |
-
|
575 |
-
self.
|
576 |
-
self.
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
self.
|
615 |
-
self.
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
self.
|
671 |
-
self.
|
672 |
-
self.
|
673 |
-
self.
|
674 |
-
self.
|
675 |
-
self.
|
676 |
-
self.
|
677 |
-
self.
|
678 |
-
self.
|
679 |
-
self.
|
680 |
-
self.
|
681 |
-
self.
|
682 |
-
self.
|
683 |
-
self.
|
684 |
-
self.
|
685 |
-
|
686 |
-
self.
|
687 |
-
self.
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
self.
|
726 |
-
self.
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
self.
|
780 |
-
self.
|
781 |
-
self.
|
782 |
-
self.
|
783 |
-
self.
|
784 |
-
self.
|
785 |
-
self.
|
786 |
-
self.
|
787 |
-
self.
|
788 |
-
self.
|
789 |
-
self.
|
790 |
-
self.
|
791 |
-
self.
|
792 |
-
self.
|
793 |
-
self.
|
794 |
-
|
795 |
-
self.
|
796 |
-
self.
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
self.
|
834 |
-
self.
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
self.
|
882 |
-
self.
|
883 |
-
self.
|
884 |
-
self.
|
885 |
-
self.
|
886 |
-
self.
|
887 |
-
self.
|
888 |
-
self.
|
889 |
-
self.
|
890 |
-
self.
|
891 |
-
self.
|
892 |
-
self.
|
893 |
-
self.
|
894 |
-
self.
|
895 |
-
self.
|
896 |
-
|
897 |
-
self.
|
898 |
-
self.
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
self.
|
936 |
-
self.
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
discs =
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
#
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
periods = [2, 3, 5, 7, 11, 17
|
993 |
-
|
994 |
-
|
995 |
-
discs =
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
#
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
norm_f(Conv1d(
|
1026 |
-
norm_f(Conv1d(
|
1027 |
-
norm_f(Conv1d(
|
1028 |
-
norm_f(Conv1d(
|
1029 |
-
norm_f(Conv1d(1024, 1024,
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
x =
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
self.
|
1052 |
-
self.
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
(
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
(
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
(
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
(
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
1024,
|
1096 |
-
|
1097 |
-
1,
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
x =
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
|
|
|
1 |
+
import math, pdb, os
|
2 |
+
from time import time as ttime
|
3 |
+
import torch
|
4 |
+
from torch import nn
|
5 |
+
from torch.nn import functional as F
|
6 |
+
from lib.infer_pack import modules
|
7 |
+
from lib.infer_pack import attentions
|
8 |
+
from lib.infer_pack import commons
|
9 |
+
from lib.infer_pack.commons import init_weights, get_padding
|
10 |
+
from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d
|
11 |
+
from torch.nn.utils import remove_weight_norm
|
12 |
+
from torch.nn.utils.parametrizations import spectral_norm, weight_norm
|
13 |
+
from lib.infer_pack.commons import init_weights
|
14 |
+
import numpy as np
|
15 |
+
from lib.infer_pack import commons
|
16 |
+
|
17 |
+
|
18 |
+
class TextEncoder256(nn.Module):
|
19 |
+
def __init__(
|
20 |
+
self,
|
21 |
+
out_channels,
|
22 |
+
hidden_channels,
|
23 |
+
filter_channels,
|
24 |
+
n_heads,
|
25 |
+
n_layers,
|
26 |
+
kernel_size,
|
27 |
+
p_dropout,
|
28 |
+
f0=True,
|
29 |
+
):
|
30 |
+
super().__init__()
|
31 |
+
self.out_channels = out_channels
|
32 |
+
self.hidden_channels = hidden_channels
|
33 |
+
self.filter_channels = filter_channels
|
34 |
+
self.n_heads = n_heads
|
35 |
+
self.n_layers = n_layers
|
36 |
+
self.kernel_size = kernel_size
|
37 |
+
self.p_dropout = p_dropout
|
38 |
+
self.emb_phone = nn.Linear(256, hidden_channels)
|
39 |
+
self.lrelu = nn.LeakyReLU(0.1, inplace=True)
|
40 |
+
if f0 == True:
|
41 |
+
self.emb_pitch = nn.Embedding(256, hidden_channels) # pitch 256
|
42 |
+
self.encoder = attentions.Encoder(
|
43 |
+
hidden_channels, filter_channels, n_heads, n_layers, kernel_size, p_dropout
|
44 |
+
)
|
45 |
+
self.proj = nn.Conv1d(hidden_channels, out_channels * 2, 1)
|
46 |
+
|
47 |
+
def forward(self, phone, pitch, lengths):
|
48 |
+
if pitch == None:
|
49 |
+
x = self.emb_phone(phone)
|
50 |
+
else:
|
51 |
+
x = self.emb_phone(phone) + self.emb_pitch(pitch)
|
52 |
+
x = x * math.sqrt(self.hidden_channels) # [b, t, h]
|
53 |
+
x = self.lrelu(x)
|
54 |
+
x = torch.transpose(x, 1, -1) # [b, h, t]
|
55 |
+
x_mask = torch.unsqueeze(commons.sequence_mask(lengths, x.size(2)), 1).to(
|
56 |
+
x.dtype
|
57 |
+
)
|
58 |
+
x = self.encoder(x * x_mask, x_mask)
|
59 |
+
stats = self.proj(x) * x_mask
|
60 |
+
|
61 |
+
m, logs = torch.split(stats, self.out_channels, dim=1)
|
62 |
+
return m, logs, x_mask
|
63 |
+
|
64 |
+
|
65 |
+
class TextEncoder768(nn.Module):
|
66 |
+
def __init__(
|
67 |
+
self,
|
68 |
+
out_channels,
|
69 |
+
hidden_channels,
|
70 |
+
filter_channels,
|
71 |
+
n_heads,
|
72 |
+
n_layers,
|
73 |
+
kernel_size,
|
74 |
+
p_dropout,
|
75 |
+
f0=True,
|
76 |
+
):
|
77 |
+
super().__init__()
|
78 |
+
self.out_channels = out_channels
|
79 |
+
self.hidden_channels = hidden_channels
|
80 |
+
self.filter_channels = filter_channels
|
81 |
+
self.n_heads = n_heads
|
82 |
+
self.n_layers = n_layers
|
83 |
+
self.kernel_size = kernel_size
|
84 |
+
self.p_dropout = p_dropout
|
85 |
+
self.emb_phone = nn.Linear(768, hidden_channels)
|
86 |
+
self.lrelu = nn.LeakyReLU(0.1, inplace=True)
|
87 |
+
if f0 == True:
|
88 |
+
self.emb_pitch = nn.Embedding(256, hidden_channels) # pitch 256
|
89 |
+
self.encoder = attentions.Encoder(
|
90 |
+
hidden_channels, filter_channels, n_heads, n_layers, kernel_size, p_dropout
|
91 |
+
)
|
92 |
+
self.proj = nn.Conv1d(hidden_channels, out_channels * 2, 1)
|
93 |
+
|
94 |
+
def forward(self, phone, pitch, lengths):
|
95 |
+
if pitch == None:
|
96 |
+
x = self.emb_phone(phone)
|
97 |
+
else:
|
98 |
+
x = self.emb_phone(phone) + self.emb_pitch(pitch)
|
99 |
+
x = x * math.sqrt(self.hidden_channels) # [b, t, h]
|
100 |
+
x = self.lrelu(x)
|
101 |
+
x = torch.transpose(x, 1, -1) # [b, h, t]
|
102 |
+
x_mask = torch.unsqueeze(commons.sequence_mask(lengths, x.size(2)), 1).to(
|
103 |
+
x.dtype
|
104 |
+
)
|
105 |
+
x = self.encoder(x * x_mask, x_mask)
|
106 |
+
stats = self.proj(x) * x_mask
|
107 |
+
|
108 |
+
m, logs = torch.split(stats, self.out_channels, dim=1)
|
109 |
+
return m, logs, x_mask
|
110 |
+
|
111 |
+
|
112 |
+
class ResidualCouplingBlock(nn.Module):
|
113 |
+
def __init__(
|
114 |
+
self,
|
115 |
+
channels,
|
116 |
+
hidden_channels,
|
117 |
+
kernel_size,
|
118 |
+
dilation_rate,
|
119 |
+
n_layers,
|
120 |
+
n_flows=4,
|
121 |
+
gin_channels=0,
|
122 |
+
):
|
123 |
+
super().__init__()
|
124 |
+
self.channels = channels
|
125 |
+
self.hidden_channels = hidden_channels
|
126 |
+
self.kernel_size = kernel_size
|
127 |
+
self.dilation_rate = dilation_rate
|
128 |
+
self.n_layers = n_layers
|
129 |
+
self.n_flows = n_flows
|
130 |
+
self.gin_channels = gin_channels
|
131 |
+
|
132 |
+
self.flows = nn.ModuleList()
|
133 |
+
for i in range(n_flows):
|
134 |
+
self.flows.append(
|
135 |
+
modules.ResidualCouplingLayer(
|
136 |
+
channels,
|
137 |
+
hidden_channels,
|
138 |
+
kernel_size,
|
139 |
+
dilation_rate,
|
140 |
+
n_layers,
|
141 |
+
gin_channels=gin_channels,
|
142 |
+
mean_only=True,
|
143 |
+
)
|
144 |
+
)
|
145 |
+
self.flows.append(modules.Flip())
|
146 |
+
|
147 |
+
def forward(self, x, x_mask, g=None, reverse=False):
|
148 |
+
if not reverse:
|
149 |
+
for flow in self.flows:
|
150 |
+
x, _ = flow(x, x_mask, g=g, reverse=reverse)
|
151 |
+
else:
|
152 |
+
for flow in reversed(self.flows):
|
153 |
+
x = flow(x, x_mask, g=g, reverse=reverse)
|
154 |
+
return x
|
155 |
+
|
156 |
+
def remove_weight_norm(self):
|
157 |
+
for i in range(self.n_flows):
|
158 |
+
self.flows[i * 2].remove_weight_norm()
|
159 |
+
|
160 |
+
|
161 |
+
class PosteriorEncoder(nn.Module):
|
162 |
+
def __init__(
|
163 |
+
self,
|
164 |
+
in_channels,
|
165 |
+
out_channels,
|
166 |
+
hidden_channels,
|
167 |
+
kernel_size,
|
168 |
+
dilation_rate,
|
169 |
+
n_layers,
|
170 |
+
gin_channels=0,
|
171 |
+
):
|
172 |
+
super().__init__()
|
173 |
+
self.in_channels = in_channels
|
174 |
+
self.out_channels = out_channels
|
175 |
+
self.hidden_channels = hidden_channels
|
176 |
+
self.kernel_size = kernel_size
|
177 |
+
self.dilation_rate = dilation_rate
|
178 |
+
self.n_layers = n_layers
|
179 |
+
self.gin_channels = gin_channels
|
180 |
+
|
181 |
+
self.pre = nn.Conv1d(in_channels, hidden_channels, 1)
|
182 |
+
self.enc = modules.WN(
|
183 |
+
hidden_channels,
|
184 |
+
kernel_size,
|
185 |
+
dilation_rate,
|
186 |
+
n_layers,
|
187 |
+
gin_channels=gin_channels,
|
188 |
+
)
|
189 |
+
self.proj = nn.Conv1d(hidden_channels, out_channels * 2, 1)
|
190 |
+
|
191 |
+
def forward(self, x, x_lengths, g=None):
|
192 |
+
x_mask = torch.unsqueeze(commons.sequence_mask(x_lengths, x.size(2)), 1).to(
|
193 |
+
x.dtype
|
194 |
+
)
|
195 |
+
x = self.pre(x) * x_mask
|
196 |
+
x = self.enc(x, x_mask, g=g)
|
197 |
+
stats = self.proj(x) * x_mask
|
198 |
+
m, logs = torch.split(stats, self.out_channels, dim=1)
|
199 |
+
z = (m + torch.randn_like(m) * torch.exp(logs)) * x_mask
|
200 |
+
return z, m, logs, x_mask
|
201 |
+
|
202 |
+
def remove_weight_norm(self):
|
203 |
+
self.enc.remove_weight_norm()
|
204 |
+
|
205 |
+
|
206 |
+
class Generator(torch.nn.Module):
|
207 |
+
def __init__(
|
208 |
+
self,
|
209 |
+
initial_channel,
|
210 |
+
resblock,
|
211 |
+
resblock_kernel_sizes,
|
212 |
+
resblock_dilation_sizes,
|
213 |
+
upsample_rates,
|
214 |
+
upsample_initial_channel,
|
215 |
+
upsample_kernel_sizes,
|
216 |
+
gin_channels=0,
|
217 |
+
):
|
218 |
+
super(Generator, self).__init__()
|
219 |
+
self.num_kernels = len(resblock_kernel_sizes)
|
220 |
+
self.num_upsamples = len(upsample_rates)
|
221 |
+
self.conv_pre = Conv1d(
|
222 |
+
initial_channel, upsample_initial_channel, 7, 1, padding=3
|
223 |
+
)
|
224 |
+
resblock = modules.ResBlock1 if resblock == "1" else modules.ResBlock2
|
225 |
+
|
226 |
+
self.ups = nn.ModuleList()
|
227 |
+
for i, (u, k) in enumerate(zip(upsample_rates, upsample_kernel_sizes)):
|
228 |
+
self.ups.append(
|
229 |
+
weight_norm(
|
230 |
+
ConvTranspose1d(
|
231 |
+
upsample_initial_channel // (2**i),
|
232 |
+
upsample_initial_channel // (2 ** (i + 1)),
|
233 |
+
k,
|
234 |
+
u,
|
235 |
+
padding=(k - u) // 2,
|
236 |
+
)
|
237 |
+
)
|
238 |
+
)
|
239 |
+
|
240 |
+
self.resblocks = nn.ModuleList()
|
241 |
+
for i in range(len(self.ups)):
|
242 |
+
ch = upsample_initial_channel // (2 ** (i + 1))
|
243 |
+
for j, (k, d) in enumerate(
|
244 |
+
zip(resblock_kernel_sizes, resblock_dilation_sizes)
|
245 |
+
):
|
246 |
+
self.resblocks.append(resblock(ch, k, d))
|
247 |
+
|
248 |
+
self.conv_post = Conv1d(ch, 1, 7, 1, padding=3, bias=False)
|
249 |
+
self.ups.apply(init_weights)
|
250 |
+
|
251 |
+
if gin_channels != 0:
|
252 |
+
self.cond = nn.Conv1d(gin_channels, upsample_initial_channel, 1)
|
253 |
+
|
254 |
+
def forward(self, x, g=None):
|
255 |
+
x = self.conv_pre(x)
|
256 |
+
if g is not None:
|
257 |
+
x = x + self.cond(g)
|
258 |
+
|
259 |
+
for i in range(self.num_upsamples):
|
260 |
+
x = F.leaky_relu(x, modules.LRELU_SLOPE)
|
261 |
+
x = self.ups[i](x)
|
262 |
+
xs = None
|
263 |
+
for j in range(self.num_kernels):
|
264 |
+
if xs is None:
|
265 |
+
xs = self.resblocks[i * self.num_kernels + j](x)
|
266 |
+
else:
|
267 |
+
xs += self.resblocks[i * self.num_kernels + j](x)
|
268 |
+
x = xs / self.num_kernels
|
269 |
+
x = F.leaky_relu(x)
|
270 |
+
x = self.conv_post(x)
|
271 |
+
x = torch.tanh(x)
|
272 |
+
|
273 |
+
return x
|
274 |
+
|
275 |
+
def remove_weight_norm(self):
|
276 |
+
for l in self.ups:
|
277 |
+
remove_weight_norm(l)
|
278 |
+
for l in self.resblocks:
|
279 |
+
l.remove_weight_norm()
|
280 |
+
|
281 |
+
|
282 |
+
class SineGen(torch.nn.Module):
|
283 |
+
"""Definition of sine generator
|
284 |
+
SineGen(samp_rate, harmonic_num = 0,
|
285 |
+
sine_amp = 0.1, noise_std = 0.003,
|
286 |
+
voiced_threshold = 0,
|
287 |
+
flag_for_pulse=False)
|
288 |
+
samp_rate: sampling rate in Hz
|
289 |
+
harmonic_num: number of harmonic overtones (default 0)
|
290 |
+
sine_amp: amplitude of sine-wavefrom (default 0.1)
|
291 |
+
noise_std: std of Gaussian noise (default 0.003)
|
292 |
+
voiced_thoreshold: F0 threshold for U/V classification (default 0)
|
293 |
+
flag_for_pulse: this SinGen is used inside PulseGen (default False)
|
294 |
+
Note: when flag_for_pulse is True, the first time step of a voiced
|
295 |
+
segment is always sin(np.pi) or cos(0)
|
296 |
+
"""
|
297 |
+
|
298 |
+
def __init__(
|
299 |
+
self,
|
300 |
+
samp_rate,
|
301 |
+
harmonic_num=0,
|
302 |
+
sine_amp=0.1,
|
303 |
+
noise_std=0.003,
|
304 |
+
voiced_threshold=0,
|
305 |
+
flag_for_pulse=False,
|
306 |
+
):
|
307 |
+
super(SineGen, self).__init__()
|
308 |
+
self.sine_amp = sine_amp
|
309 |
+
self.noise_std = noise_std
|
310 |
+
self.harmonic_num = harmonic_num
|
311 |
+
self.dim = self.harmonic_num + 1
|
312 |
+
self.sampling_rate = samp_rate
|
313 |
+
self.voiced_threshold = voiced_threshold
|
314 |
+
|
315 |
+
def _f02uv(self, f0):
|
316 |
+
# generate uv signal
|
317 |
+
uv = torch.ones_like(f0)
|
318 |
+
uv = uv * (f0 > self.voiced_threshold)
|
319 |
+
return uv
|
320 |
+
|
321 |
+
def forward(self, f0, upp):
|
322 |
+
"""sine_tensor, uv = forward(f0)
|
323 |
+
input F0: tensor(batchsize=1, length, dim=1)
|
324 |
+
f0 for unvoiced steps should be 0
|
325 |
+
output sine_tensor: tensor(batchsize=1, length, dim)
|
326 |
+
output uv: tensor(batchsize=1, length, 1)
|
327 |
+
"""
|
328 |
+
with torch.no_grad():
|
329 |
+
f0 = f0[:, None].transpose(1, 2)
|
330 |
+
f0_buf = torch.zeros(f0.shape[0], f0.shape[1], self.dim, device=f0.device)
|
331 |
+
# fundamental component
|
332 |
+
f0_buf[:, :, 0] = f0[:, :, 0]
|
333 |
+
for idx in np.arange(self.harmonic_num):
|
334 |
+
f0_buf[:, :, idx + 1] = f0_buf[:, :, 0] * (
|
335 |
+
idx + 2
|
336 |
+
) # idx + 2: the (idx+1)-th overtone, (idx+2)-th harmonic
|
337 |
+
rad_values = (f0_buf / self.sampling_rate) % 1 ###%1意味着n_har的乘积无法后处理优化
|
338 |
+
rand_ini = torch.rand(
|
339 |
+
f0_buf.shape[0], f0_buf.shape[2], device=f0_buf.device
|
340 |
+
)
|
341 |
+
rand_ini[:, 0] = 0
|
342 |
+
rad_values[:, 0, :] = rad_values[:, 0, :] + rand_ini
|
343 |
+
tmp_over_one = torch.cumsum(rad_values, 1) # % 1 #####%1意味着后面的cumsum无法再优化
|
344 |
+
tmp_over_one *= upp
|
345 |
+
tmp_over_one = F.interpolate(
|
346 |
+
tmp_over_one.transpose(2, 1),
|
347 |
+
scale_factor=upp,
|
348 |
+
mode="linear",
|
349 |
+
align_corners=True,
|
350 |
+
).transpose(2, 1)
|
351 |
+
rad_values = F.interpolate(
|
352 |
+
rad_values.transpose(2, 1), scale_factor=upp, mode="nearest"
|
353 |
+
).transpose(
|
354 |
+
2, 1
|
355 |
+
) #######
|
356 |
+
tmp_over_one %= 1
|
357 |
+
tmp_over_one_idx = (tmp_over_one[:, 1:, :] - tmp_over_one[:, :-1, :]) < 0
|
358 |
+
cumsum_shift = torch.zeros_like(rad_values)
|
359 |
+
cumsum_shift[:, 1:, :] = tmp_over_one_idx * -1.0
|
360 |
+
sine_waves = torch.sin(
|
361 |
+
torch.cumsum(rad_values + cumsum_shift, dim=1) * 2 * np.pi
|
362 |
+
)
|
363 |
+
sine_waves = sine_waves * self.sine_amp
|
364 |
+
uv = self._f02uv(f0)
|
365 |
+
uv = F.interpolate(
|
366 |
+
uv.transpose(2, 1), scale_factor=upp, mode="nearest"
|
367 |
+
).transpose(2, 1)
|
368 |
+
noise_amp = uv * self.noise_std + (1 - uv) * self.sine_amp / 3
|
369 |
+
noise = noise_amp * torch.randn_like(sine_waves)
|
370 |
+
sine_waves = sine_waves * uv + noise
|
371 |
+
return sine_waves, uv, noise
|
372 |
+
|
373 |
+
|
374 |
+
class SourceModuleHnNSF(torch.nn.Module):
|
375 |
+
"""SourceModule for hn-nsf
|
376 |
+
SourceModule(sampling_rate, harmonic_num=0, sine_amp=0.1,
|
377 |
+
add_noise_std=0.003, voiced_threshod=0)
|
378 |
+
sampling_rate: sampling_rate in Hz
|
379 |
+
harmonic_num: number of harmonic above F0 (default: 0)
|
380 |
+
sine_amp: amplitude of sine source signal (default: 0.1)
|
381 |
+
add_noise_std: std of additive Gaussian noise (default: 0.003)
|
382 |
+
note that amplitude of noise in unvoiced is decided
|
383 |
+
by sine_amp
|
384 |
+
voiced_threshold: threhold to set U/V given F0 (default: 0)
|
385 |
+
Sine_source, noise_source = SourceModuleHnNSF(F0_sampled)
|
386 |
+
F0_sampled (batchsize, length, 1)
|
387 |
+
Sine_source (batchsize, length, 1)
|
388 |
+
noise_source (batchsize, length 1)
|
389 |
+
uv (batchsize, length, 1)
|
390 |
+
"""
|
391 |
+
|
392 |
+
def __init__(
|
393 |
+
self,
|
394 |
+
sampling_rate,
|
395 |
+
harmonic_num=0,
|
396 |
+
sine_amp=0.1,
|
397 |
+
add_noise_std=0.003,
|
398 |
+
voiced_threshod=0,
|
399 |
+
is_half=True,
|
400 |
+
):
|
401 |
+
super(SourceModuleHnNSF, self).__init__()
|
402 |
+
|
403 |
+
self.sine_amp = sine_amp
|
404 |
+
self.noise_std = add_noise_std
|
405 |
+
self.is_half = is_half
|
406 |
+
# to produce sine waveforms
|
407 |
+
self.l_sin_gen = SineGen(
|
408 |
+
sampling_rate, harmonic_num, sine_amp, add_noise_std, voiced_threshod
|
409 |
+
)
|
410 |
+
|
411 |
+
# to merge source harmonics into a single excitation
|
412 |
+
self.l_linear = torch.nn.Linear(harmonic_num + 1, 1)
|
413 |
+
self.l_tanh = torch.nn.Tanh()
|
414 |
+
|
415 |
+
def forward(self, x, upp=None):
|
416 |
+
sine_wavs, uv, _ = self.l_sin_gen(x, upp)
|
417 |
+
if self.is_half:
|
418 |
+
sine_wavs = sine_wavs.half()
|
419 |
+
sine_merge = self.l_tanh(self.l_linear(sine_wavs))
|
420 |
+
return sine_merge, None, None # noise, uv
|
421 |
+
|
422 |
+
|
423 |
+
class GeneratorNSF(torch.nn.Module):
|
424 |
+
def __init__(
|
425 |
+
self,
|
426 |
+
initial_channel,
|
427 |
+
resblock,
|
428 |
+
resblock_kernel_sizes,
|
429 |
+
resblock_dilation_sizes,
|
430 |
+
upsample_rates,
|
431 |
+
upsample_initial_channel,
|
432 |
+
upsample_kernel_sizes,
|
433 |
+
gin_channels,
|
434 |
+
sr,
|
435 |
+
is_half=False,
|
436 |
+
):
|
437 |
+
super(GeneratorNSF, self).__init__()
|
438 |
+
self.num_kernels = len(resblock_kernel_sizes)
|
439 |
+
self.num_upsamples = len(upsample_rates)
|
440 |
+
|
441 |
+
self.f0_upsamp = torch.nn.Upsample(scale_factor=np.prod(upsample_rates))
|
442 |
+
self.m_source = SourceModuleHnNSF(
|
443 |
+
sampling_rate=sr, harmonic_num=0, is_half=is_half
|
444 |
+
)
|
445 |
+
self.noise_convs = nn.ModuleList()
|
446 |
+
self.conv_pre = Conv1d(
|
447 |
+
initial_channel, upsample_initial_channel, 7, 1, padding=3
|
448 |
+
)
|
449 |
+
resblock = modules.ResBlock1 if resblock == "1" else modules.ResBlock2
|
450 |
+
|
451 |
+
self.ups = nn.ModuleList()
|
452 |
+
for i, (u, k) in enumerate(zip(upsample_rates, upsample_kernel_sizes)):
|
453 |
+
c_cur = upsample_initial_channel // (2 ** (i + 1))
|
454 |
+
self.ups.append(
|
455 |
+
weight_norm(
|
456 |
+
ConvTranspose1d(
|
457 |
+
upsample_initial_channel // (2**i),
|
458 |
+
upsample_initial_channel // (2 ** (i + 1)),
|
459 |
+
k,
|
460 |
+
u,
|
461 |
+
padding=(k - u) // 2,
|
462 |
+
)
|
463 |
+
)
|
464 |
+
)
|
465 |
+
if i + 1 < len(upsample_rates):
|
466 |
+
stride_f0 = np.prod(upsample_rates[i + 1 :])
|
467 |
+
self.noise_convs.append(
|
468 |
+
Conv1d(
|
469 |
+
1,
|
470 |
+
c_cur,
|
471 |
+
kernel_size=stride_f0 * 2,
|
472 |
+
stride=stride_f0,
|
473 |
+
padding=stride_f0 // 2,
|
474 |
+
)
|
475 |
+
)
|
476 |
+
else:
|
477 |
+
self.noise_convs.append(Conv1d(1, c_cur, kernel_size=1))
|
478 |
+
|
479 |
+
self.resblocks = nn.ModuleList()
|
480 |
+
for i in range(len(self.ups)):
|
481 |
+
ch = upsample_initial_channel // (2 ** (i + 1))
|
482 |
+
for j, (k, d) in enumerate(
|
483 |
+
zip(resblock_kernel_sizes, resblock_dilation_sizes)
|
484 |
+
):
|
485 |
+
self.resblocks.append(resblock(ch, k, d))
|
486 |
+
|
487 |
+
self.conv_post = Conv1d(ch, 1, 7, 1, padding=3, bias=False)
|
488 |
+
self.ups.apply(init_weights)
|
489 |
+
|
490 |
+
if gin_channels != 0:
|
491 |
+
self.cond = nn.Conv1d(gin_channels, upsample_initial_channel, 1)
|
492 |
+
|
493 |
+
self.upp = np.prod(upsample_rates)
|
494 |
+
|
495 |
+
def forward(self, x, f0, g=None):
|
496 |
+
har_source, noi_source, uv = self.m_source(f0, self.upp)
|
497 |
+
har_source = har_source.transpose(1, 2)
|
498 |
+
x = self.conv_pre(x)
|
499 |
+
if g is not None:
|
500 |
+
x = x + self.cond(g)
|
501 |
+
|
502 |
+
for i in range(self.num_upsamples):
|
503 |
+
x = F.leaky_relu(x, modules.LRELU_SLOPE)
|
504 |
+
x = self.ups[i](x)
|
505 |
+
x_source = self.noise_convs[i](har_source)
|
506 |
+
x = x + x_source
|
507 |
+
xs = None
|
508 |
+
for j in range(self.num_kernels):
|
509 |
+
if xs is None:
|
510 |
+
xs = self.resblocks[i * self.num_kernels + j](x)
|
511 |
+
else:
|
512 |
+
xs += self.resblocks[i * self.num_kernels + j](x)
|
513 |
+
x = xs / self.num_kernels
|
514 |
+
x = F.leaky_relu(x)
|
515 |
+
x = self.conv_post(x)
|
516 |
+
x = torch.tanh(x)
|
517 |
+
return x
|
518 |
+
|
519 |
+
def remove_weight_norm(self):
|
520 |
+
for l in self.ups:
|
521 |
+
remove_weight_norm(l)
|
522 |
+
for l in self.resblocks:
|
523 |
+
l.remove_weight_norm()
|
524 |
+
|
525 |
+
|
526 |
+
sr2sr = {
|
527 |
+
"32k": 32000,
|
528 |
+
"40k": 40000,
|
529 |
+
"48k": 48000,
|
530 |
+
}
|
531 |
+
|
532 |
+
|
533 |
+
class SynthesizerTrnMs256NSFsid(nn.Module):
|
534 |
+
def __init__(
|
535 |
+
self,
|
536 |
+
spec_channels,
|
537 |
+
segment_size,
|
538 |
+
inter_channels,
|
539 |
+
hidden_channels,
|
540 |
+
filter_channels,
|
541 |
+
n_heads,
|
542 |
+
n_layers,
|
543 |
+
kernel_size,
|
544 |
+
p_dropout,
|
545 |
+
resblock,
|
546 |
+
resblock_kernel_sizes,
|
547 |
+
resblock_dilation_sizes,
|
548 |
+
upsample_rates,
|
549 |
+
upsample_initial_channel,
|
550 |
+
upsample_kernel_sizes,
|
551 |
+
spk_embed_dim,
|
552 |
+
gin_channels,
|
553 |
+
sr,
|
554 |
+
**kwargs
|
555 |
+
):
|
556 |
+
super().__init__()
|
557 |
+
if type(sr) == type("strr"):
|
558 |
+
sr = sr2sr[sr]
|
559 |
+
self.spec_channels = spec_channels
|
560 |
+
self.inter_channels = inter_channels
|
561 |
+
self.hidden_channels = hidden_channels
|
562 |
+
self.filter_channels = filter_channels
|
563 |
+
self.n_heads = n_heads
|
564 |
+
self.n_layers = n_layers
|
565 |
+
self.kernel_size = kernel_size
|
566 |
+
self.p_dropout = p_dropout
|
567 |
+
self.resblock = resblock
|
568 |
+
self.resblock_kernel_sizes = resblock_kernel_sizes
|
569 |
+
self.resblock_dilation_sizes = resblock_dilation_sizes
|
570 |
+
self.upsample_rates = upsample_rates
|
571 |
+
self.upsample_initial_channel = upsample_initial_channel
|
572 |
+
self.upsample_kernel_sizes = upsample_kernel_sizes
|
573 |
+
self.segment_size = segment_size
|
574 |
+
self.gin_channels = gin_channels
|
575 |
+
# self.hop_length = hop_length#
|
576 |
+
self.spk_embed_dim = spk_embed_dim
|
577 |
+
self.enc_p = TextEncoder256(
|
578 |
+
inter_channels,
|
579 |
+
hidden_channels,
|
580 |
+
filter_channels,
|
581 |
+
n_heads,
|
582 |
+
n_layers,
|
583 |
+
kernel_size,
|
584 |
+
p_dropout,
|
585 |
+
)
|
586 |
+
self.dec = GeneratorNSF(
|
587 |
+
inter_channels,
|
588 |
+
resblock,
|
589 |
+
resblock_kernel_sizes,
|
590 |
+
resblock_dilation_sizes,
|
591 |
+
upsample_rates,
|
592 |
+
upsample_initial_channel,
|
593 |
+
upsample_kernel_sizes,
|
594 |
+
gin_channels=gin_channels,
|
595 |
+
sr=sr,
|
596 |
+
is_half=kwargs["is_half"],
|
597 |
+
)
|
598 |
+
self.enc_q = PosteriorEncoder(
|
599 |
+
spec_channels,
|
600 |
+
inter_channels,
|
601 |
+
hidden_channels,
|
602 |
+
5,
|
603 |
+
1,
|
604 |
+
16,
|
605 |
+
gin_channels=gin_channels,
|
606 |
+
)
|
607 |
+
self.flow = ResidualCouplingBlock(
|
608 |
+
inter_channels, hidden_channels, 5, 1, 3, gin_channels=gin_channels
|
609 |
+
)
|
610 |
+
self.emb_g = nn.Embedding(self.spk_embed_dim, gin_channels)
|
611 |
+
print("gin_channels:", gin_channels, "self.spk_embed_dim:", self.spk_embed_dim)
|
612 |
+
|
613 |
+
def remove_weight_norm(self):
|
614 |
+
self.dec.remove_weight_norm()
|
615 |
+
self.flow.remove_weight_norm()
|
616 |
+
self.enc_q.remove_weight_norm()
|
617 |
+
|
618 |
+
def forward(
|
619 |
+
self, phone, phone_lengths, pitch, pitchf, y, y_lengths, ds
|
620 |
+
): # 这里ds是id,[bs,1]
|
621 |
+
# print(1,pitch.shape)#[bs,t]
|
622 |
+
g = self.emb_g(ds).unsqueeze(-1) # [b, 256, 1]##1是t,广播的
|
623 |
+
m_p, logs_p, x_mask = self.enc_p(phone, pitch, phone_lengths)
|
624 |
+
z, m_q, logs_q, y_mask = self.enc_q(y, y_lengths, g=g)
|
625 |
+
z_p = self.flow(z, y_mask, g=g)
|
626 |
+
z_slice, ids_slice = commons.rand_slice_segments(
|
627 |
+
z, y_lengths, self.segment_size
|
628 |
+
)
|
629 |
+
# print(-1,pitchf.shape,ids_slice,self.segment_size,self.hop_length,self.segment_size//self.hop_length)
|
630 |
+
pitchf = commons.slice_segments2(pitchf, ids_slice, self.segment_size)
|
631 |
+
# print(-2,pitchf.shape,z_slice.shape)
|
632 |
+
o = self.dec(z_slice, pitchf, g=g)
|
633 |
+
return o, ids_slice, x_mask, y_mask, (z, z_p, m_p, logs_p, m_q, logs_q)
|
634 |
+
|
635 |
+
def infer(self, phone, phone_lengths, pitch, nsff0, sid, max_len=None):
|
636 |
+
g = self.emb_g(sid).unsqueeze(-1)
|
637 |
+
m_p, logs_p, x_mask = self.enc_p(phone, pitch, phone_lengths)
|
638 |
+
z_p = (m_p + torch.exp(logs_p) * torch.randn_like(m_p) * 0.66666) * x_mask
|
639 |
+
z = self.flow(z_p, x_mask, g=g, reverse=True)
|
640 |
+
o = self.dec((z * x_mask)[:, :, :max_len], nsff0, g=g)
|
641 |
+
return o, x_mask, (z, z_p, m_p, logs_p)
|
642 |
+
|
643 |
+
|
644 |
+
class SynthesizerTrnMs768NSFsid(nn.Module):
|
645 |
+
def __init__(
|
646 |
+
self,
|
647 |
+
spec_channels,
|
648 |
+
segment_size,
|
649 |
+
inter_channels,
|
650 |
+
hidden_channels,
|
651 |
+
filter_channels,
|
652 |
+
n_heads,
|
653 |
+
n_layers,
|
654 |
+
kernel_size,
|
655 |
+
p_dropout,
|
656 |
+
resblock,
|
657 |
+
resblock_kernel_sizes,
|
658 |
+
resblock_dilation_sizes,
|
659 |
+
upsample_rates,
|
660 |
+
upsample_initial_channel,
|
661 |
+
upsample_kernel_sizes,
|
662 |
+
spk_embed_dim,
|
663 |
+
gin_channels,
|
664 |
+
sr,
|
665 |
+
**kwargs
|
666 |
+
):
|
667 |
+
super().__init__()
|
668 |
+
if type(sr) == type("strr"):
|
669 |
+
sr = sr2sr[sr]
|
670 |
+
self.spec_channels = spec_channels
|
671 |
+
self.inter_channels = inter_channels
|
672 |
+
self.hidden_channels = hidden_channels
|
673 |
+
self.filter_channels = filter_channels
|
674 |
+
self.n_heads = n_heads
|
675 |
+
self.n_layers = n_layers
|
676 |
+
self.kernel_size = kernel_size
|
677 |
+
self.p_dropout = p_dropout
|
678 |
+
self.resblock = resblock
|
679 |
+
self.resblock_kernel_sizes = resblock_kernel_sizes
|
680 |
+
self.resblock_dilation_sizes = resblock_dilation_sizes
|
681 |
+
self.upsample_rates = upsample_rates
|
682 |
+
self.upsample_initial_channel = upsample_initial_channel
|
683 |
+
self.upsample_kernel_sizes = upsample_kernel_sizes
|
684 |
+
self.segment_size = segment_size
|
685 |
+
self.gin_channels = gin_channels
|
686 |
+
# self.hop_length = hop_length#
|
687 |
+
self.spk_embed_dim = spk_embed_dim
|
688 |
+
self.enc_p = TextEncoder768(
|
689 |
+
inter_channels,
|
690 |
+
hidden_channels,
|
691 |
+
filter_channels,
|
692 |
+
n_heads,
|
693 |
+
n_layers,
|
694 |
+
kernel_size,
|
695 |
+
p_dropout,
|
696 |
+
)
|
697 |
+
self.dec = GeneratorNSF(
|
698 |
+
inter_channels,
|
699 |
+
resblock,
|
700 |
+
resblock_kernel_sizes,
|
701 |
+
resblock_dilation_sizes,
|
702 |
+
upsample_rates,
|
703 |
+
upsample_initial_channel,
|
704 |
+
upsample_kernel_sizes,
|
705 |
+
gin_channels=gin_channels,
|
706 |
+
sr=sr,
|
707 |
+
is_half=kwargs["is_half"],
|
708 |
+
)
|
709 |
+
self.enc_q = PosteriorEncoder(
|
710 |
+
spec_channels,
|
711 |
+
inter_channels,
|
712 |
+
hidden_channels,
|
713 |
+
5,
|
714 |
+
1,
|
715 |
+
16,
|
716 |
+
gin_channels=gin_channels,
|
717 |
+
)
|
718 |
+
self.flow = ResidualCouplingBlock(
|
719 |
+
inter_channels, hidden_channels, 5, 1, 3, gin_channels=gin_channels
|
720 |
+
)
|
721 |
+
self.emb_g = nn.Embedding(self.spk_embed_dim, gin_channels)
|
722 |
+
print("gin_channels:", gin_channels, "self.spk_embed_dim:", self.spk_embed_dim)
|
723 |
+
|
724 |
+
def remove_weight_norm(self):
|
725 |
+
self.dec.remove_weight_norm()
|
726 |
+
self.flow.remove_weight_norm()
|
727 |
+
self.enc_q.remove_weight_norm()
|
728 |
+
|
729 |
+
def forward(
|
730 |
+
self, phone, phone_lengths, pitch, pitchf, y, y_lengths, ds
|
731 |
+
): # 这里ds是id,[bs,1]
|
732 |
+
# print(1,pitch.shape)#[bs,t]
|
733 |
+
g = self.emb_g(ds).unsqueeze(-1) # [b, 256, 1]##1是t,广播的
|
734 |
+
m_p, logs_p, x_mask = self.enc_p(phone, pitch, phone_lengths)
|
735 |
+
z, m_q, logs_q, y_mask = self.enc_q(y, y_lengths, g=g)
|
736 |
+
z_p = self.flow(z, y_mask, g=g)
|
737 |
+
z_slice, ids_slice = commons.rand_slice_segments(
|
738 |
+
z, y_lengths, self.segment_size
|
739 |
+
)
|
740 |
+
# print(-1,pitchf.shape,ids_slice,self.segment_size,self.hop_length,self.segment_size//self.hop_length)
|
741 |
+
pitchf = commons.slice_segments2(pitchf, ids_slice, self.segment_size)
|
742 |
+
# print(-2,pitchf.shape,z_slice.shape)
|
743 |
+
o = self.dec(z_slice, pitchf, g=g)
|
744 |
+
return o, ids_slice, x_mask, y_mask, (z, z_p, m_p, logs_p, m_q, logs_q)
|
745 |
+
|
746 |
+
def infer(self, phone, phone_lengths, pitch, nsff0, sid, max_len=None):
|
747 |
+
g = self.emb_g(sid).unsqueeze(-1)
|
748 |
+
m_p, logs_p, x_mask = self.enc_p(phone, pitch, phone_lengths)
|
749 |
+
z_p = (m_p + torch.exp(logs_p) * torch.randn_like(m_p) * 0.66666) * x_mask
|
750 |
+
z = self.flow(z_p, x_mask, g=g, reverse=True)
|
751 |
+
o = self.dec((z * x_mask)[:, :, :max_len], nsff0, g=g)
|
752 |
+
return o, x_mask, (z, z_p, m_p, logs_p)
|
753 |
+
|
754 |
+
|
755 |
+
class SynthesizerTrnMs256NSFsid_nono(nn.Module):
|
756 |
+
def __init__(
|
757 |
+
self,
|
758 |
+
spec_channels,
|
759 |
+
segment_size,
|
760 |
+
inter_channels,
|
761 |
+
hidden_channels,
|
762 |
+
filter_channels,
|
763 |
+
n_heads,
|
764 |
+
n_layers,
|
765 |
+
kernel_size,
|
766 |
+
p_dropout,
|
767 |
+
resblock,
|
768 |
+
resblock_kernel_sizes,
|
769 |
+
resblock_dilation_sizes,
|
770 |
+
upsample_rates,
|
771 |
+
upsample_initial_channel,
|
772 |
+
upsample_kernel_sizes,
|
773 |
+
spk_embed_dim,
|
774 |
+
gin_channels,
|
775 |
+
sr=None,
|
776 |
+
**kwargs
|
777 |
+
):
|
778 |
+
super().__init__()
|
779 |
+
self.spec_channels = spec_channels
|
780 |
+
self.inter_channels = inter_channels
|
781 |
+
self.hidden_channels = hidden_channels
|
782 |
+
self.filter_channels = filter_channels
|
783 |
+
self.n_heads = n_heads
|
784 |
+
self.n_layers = n_layers
|
785 |
+
self.kernel_size = kernel_size
|
786 |
+
self.p_dropout = p_dropout
|
787 |
+
self.resblock = resblock
|
788 |
+
self.resblock_kernel_sizes = resblock_kernel_sizes
|
789 |
+
self.resblock_dilation_sizes = resblock_dilation_sizes
|
790 |
+
self.upsample_rates = upsample_rates
|
791 |
+
self.upsample_initial_channel = upsample_initial_channel
|
792 |
+
self.upsample_kernel_sizes = upsample_kernel_sizes
|
793 |
+
self.segment_size = segment_size
|
794 |
+
self.gin_channels = gin_channels
|
795 |
+
# self.hop_length = hop_length#
|
796 |
+
self.spk_embed_dim = spk_embed_dim
|
797 |
+
self.enc_p = TextEncoder256(
|
798 |
+
inter_channels,
|
799 |
+
hidden_channels,
|
800 |
+
filter_channels,
|
801 |
+
n_heads,
|
802 |
+
n_layers,
|
803 |
+
kernel_size,
|
804 |
+
p_dropout,
|
805 |
+
f0=False,
|
806 |
+
)
|
807 |
+
self.dec = Generator(
|
808 |
+
inter_channels,
|
809 |
+
resblock,
|
810 |
+
resblock_kernel_sizes,
|
811 |
+
resblock_dilation_sizes,
|
812 |
+
upsample_rates,
|
813 |
+
upsample_initial_channel,
|
814 |
+
upsample_kernel_sizes,
|
815 |
+
gin_channels=gin_channels,
|
816 |
+
)
|
817 |
+
self.enc_q = PosteriorEncoder(
|
818 |
+
spec_channels,
|
819 |
+
inter_channels,
|
820 |
+
hidden_channels,
|
821 |
+
5,
|
822 |
+
1,
|
823 |
+
16,
|
824 |
+
gin_channels=gin_channels,
|
825 |
+
)
|
826 |
+
self.flow = ResidualCouplingBlock(
|
827 |
+
inter_channels, hidden_channels, 5, 1, 3, gin_channels=gin_channels
|
828 |
+
)
|
829 |
+
self.emb_g = nn.Embedding(self.spk_embed_dim, gin_channels)
|
830 |
+
print("gin_channels:", gin_channels, "self.spk_embed_dim:", self.spk_embed_dim)
|
831 |
+
|
832 |
+
def remove_weight_norm(self):
|
833 |
+
self.dec.remove_weight_norm()
|
834 |
+
self.flow.remove_weight_norm()
|
835 |
+
self.enc_q.remove_weight_norm()
|
836 |
+
|
837 |
+
def forward(self, phone, phone_lengths, y, y_lengths, ds): # 这里ds是id,[bs,1]
|
838 |
+
g = self.emb_g(ds).unsqueeze(-1) # [b, 256, 1]##1是t,广播的
|
839 |
+
m_p, logs_p, x_mask = self.enc_p(phone, None, phone_lengths)
|
840 |
+
z, m_q, logs_q, y_mask = self.enc_q(y, y_lengths, g=g)
|
841 |
+
z_p = self.flow(z, y_mask, g=g)
|
842 |
+
z_slice, ids_slice = commons.rand_slice_segments(
|
843 |
+
z, y_lengths, self.segment_size
|
844 |
+
)
|
845 |
+
o = self.dec(z_slice, g=g)
|
846 |
+
return o, ids_slice, x_mask, y_mask, (z, z_p, m_p, logs_p, m_q, logs_q)
|
847 |
+
|
848 |
+
def infer(self, phone, phone_lengths, sid, max_len=None):
|
849 |
+
g = self.emb_g(sid).unsqueeze(-1)
|
850 |
+
m_p, logs_p, x_mask = self.enc_p(phone, None, phone_lengths)
|
851 |
+
z_p = (m_p + torch.exp(logs_p) * torch.randn_like(m_p) * 0.66666) * x_mask
|
852 |
+
z = self.flow(z_p, x_mask, g=g, reverse=True)
|
853 |
+
o = self.dec((z * x_mask)[:, :, :max_len], g=g)
|
854 |
+
return o, x_mask, (z, z_p, m_p, logs_p)
|
855 |
+
|
856 |
+
|
857 |
+
class SynthesizerTrnMs768NSFsid_nono(nn.Module):
|
858 |
+
def __init__(
|
859 |
+
self,
|
860 |
+
spec_channels,
|
861 |
+
segment_size,
|
862 |
+
inter_channels,
|
863 |
+
hidden_channels,
|
864 |
+
filter_channels,
|
865 |
+
n_heads,
|
866 |
+
n_layers,
|
867 |
+
kernel_size,
|
868 |
+
p_dropout,
|
869 |
+
resblock,
|
870 |
+
resblock_kernel_sizes,
|
871 |
+
resblock_dilation_sizes,
|
872 |
+
upsample_rates,
|
873 |
+
upsample_initial_channel,
|
874 |
+
upsample_kernel_sizes,
|
875 |
+
spk_embed_dim,
|
876 |
+
gin_channels,
|
877 |
+
sr=None,
|
878 |
+
**kwargs
|
879 |
+
):
|
880 |
+
super().__init__()
|
881 |
+
self.spec_channels = spec_channels
|
882 |
+
self.inter_channels = inter_channels
|
883 |
+
self.hidden_channels = hidden_channels
|
884 |
+
self.filter_channels = filter_channels
|
885 |
+
self.n_heads = n_heads
|
886 |
+
self.n_layers = n_layers
|
887 |
+
self.kernel_size = kernel_size
|
888 |
+
self.p_dropout = p_dropout
|
889 |
+
self.resblock = resblock
|
890 |
+
self.resblock_kernel_sizes = resblock_kernel_sizes
|
891 |
+
self.resblock_dilation_sizes = resblock_dilation_sizes
|
892 |
+
self.upsample_rates = upsample_rates
|
893 |
+
self.upsample_initial_channel = upsample_initial_channel
|
894 |
+
self.upsample_kernel_sizes = upsample_kernel_sizes
|
895 |
+
self.segment_size = segment_size
|
896 |
+
self.gin_channels = gin_channels
|
897 |
+
# self.hop_length = hop_length#
|
898 |
+
self.spk_embed_dim = spk_embed_dim
|
899 |
+
self.enc_p = TextEncoder768(
|
900 |
+
inter_channels,
|
901 |
+
hidden_channels,
|
902 |
+
filter_channels,
|
903 |
+
n_heads,
|
904 |
+
n_layers,
|
905 |
+
kernel_size,
|
906 |
+
p_dropout,
|
907 |
+
f0=False,
|
908 |
+
)
|
909 |
+
self.dec = Generator(
|
910 |
+
inter_channels,
|
911 |
+
resblock,
|
912 |
+
resblock_kernel_sizes,
|
913 |
+
resblock_dilation_sizes,
|
914 |
+
upsample_rates,
|
915 |
+
upsample_initial_channel,
|
916 |
+
upsample_kernel_sizes,
|
917 |
+
gin_channels=gin_channels,
|
918 |
+
)
|
919 |
+
self.enc_q = PosteriorEncoder(
|
920 |
+
spec_channels,
|
921 |
+
inter_channels,
|
922 |
+
hidden_channels,
|
923 |
+
5,
|
924 |
+
1,
|
925 |
+
16,
|
926 |
+
gin_channels=gin_channels,
|
927 |
+
)
|
928 |
+
self.flow = ResidualCouplingBlock(
|
929 |
+
inter_channels, hidden_channels, 5, 1, 3, gin_channels=gin_channels
|
930 |
+
)
|
931 |
+
self.emb_g = nn.Embedding(self.spk_embed_dim, gin_channels)
|
932 |
+
print("gin_channels:", gin_channels, "self.spk_embed_dim:", self.spk_embed_dim)
|
933 |
+
|
934 |
+
def remove_weight_norm(self):
|
935 |
+
self.dec.remove_weight_norm()
|
936 |
+
self.flow.remove_weight_norm()
|
937 |
+
self.enc_q.remove_weight_norm()
|
938 |
+
|
939 |
+
def forward(self, phone, phone_lengths, y, y_lengths, ds): # 这里ds是id,[bs,1]
|
940 |
+
g = self.emb_g(ds).unsqueeze(-1) # [b, 256, 1]##1是t,广播的
|
941 |
+
m_p, logs_p, x_mask = self.enc_p(phone, None, phone_lengths)
|
942 |
+
z, m_q, logs_q, y_mask = self.enc_q(y, y_lengths, g=g)
|
943 |
+
z_p = self.flow(z, y_mask, g=g)
|
944 |
+
z_slice, ids_slice = commons.rand_slice_segments(
|
945 |
+
z, y_lengths, self.segment_size
|
946 |
+
)
|
947 |
+
o = self.dec(z_slice, g=g)
|
948 |
+
return o, ids_slice, x_mask, y_mask, (z, z_p, m_p, logs_p, m_q, logs_q)
|
949 |
+
|
950 |
+
def infer(self, phone, phone_lengths, sid, max_len=None):
|
951 |
+
g = self.emb_g(sid).unsqueeze(-1)
|
952 |
+
m_p, logs_p, x_mask = self.enc_p(phone, None, phone_lengths)
|
953 |
+
z_p = (m_p + torch.exp(logs_p) * torch.randn_like(m_p) * 0.66666) * x_mask
|
954 |
+
z = self.flow(z_p, x_mask, g=g, reverse=True)
|
955 |
+
o = self.dec((z * x_mask)[:, :, :max_len], g=g)
|
956 |
+
return o, x_mask, (z, z_p, m_p, logs_p)
|
957 |
+
|
958 |
+
|
959 |
+
class MultiPeriodDiscriminator(torch.nn.Module):
|
960 |
+
def __init__(self, use_spectral_norm=False):
|
961 |
+
super(MultiPeriodDiscriminator, self).__init__()
|
962 |
+
periods = [2, 3, 5, 7, 11, 17]
|
963 |
+
# periods = [3, 5, 7, 11, 17, 23, 37]
|
964 |
+
|
965 |
+
discs = [DiscriminatorS(use_spectral_norm=use_spectral_norm)]
|
966 |
+
discs = discs + [
|
967 |
+
DiscriminatorP(i, use_spectral_norm=use_spectral_norm) for i in periods
|
968 |
+
]
|
969 |
+
self.discriminators = nn.ModuleList(discs)
|
970 |
+
|
971 |
+
def forward(self, y, y_hat):
|
972 |
+
y_d_rs = [] #
|
973 |
+
y_d_gs = []
|
974 |
+
fmap_rs = []
|
975 |
+
fmap_gs = []
|
976 |
+
for i, d in enumerate(self.discriminators):
|
977 |
+
y_d_r, fmap_r = d(y)
|
978 |
+
y_d_g, fmap_g = d(y_hat)
|
979 |
+
# for j in range(len(fmap_r)):
|
980 |
+
# print(i,j,y.shape,y_hat.shape,fmap_r[j].shape,fmap_g[j].shape)
|
981 |
+
y_d_rs.append(y_d_r)
|
982 |
+
y_d_gs.append(y_d_g)
|
983 |
+
fmap_rs.append(fmap_r)
|
984 |
+
fmap_gs.append(fmap_g)
|
985 |
+
|
986 |
+
return y_d_rs, y_d_gs, fmap_rs, fmap_gs
|
987 |
+
|
988 |
+
|
989 |
+
class MultiPeriodDiscriminatorV2(torch.nn.Module):
|
990 |
+
def __init__(self, use_spectral_norm=False):
|
991 |
+
super(MultiPeriodDiscriminatorV2, self).__init__()
|
992 |
+
# periods = [2, 3, 5, 7, 11, 17]
|
993 |
+
periods = [2, 3, 5, 7, 11, 17, 23, 37]
|
994 |
+
|
995 |
+
discs = [DiscriminatorS(use_spectral_norm=use_spectral_norm)]
|
996 |
+
discs = discs + [
|
997 |
+
DiscriminatorP(i, use_spectral_norm=use_spectral_norm) for i in periods
|
998 |
+
]
|
999 |
+
self.discriminators = nn.ModuleList(discs)
|
1000 |
+
|
1001 |
+
def forward(self, y, y_hat):
|
1002 |
+
y_d_rs = [] #
|
1003 |
+
y_d_gs = []
|
1004 |
+
fmap_rs = []
|
1005 |
+
fmap_gs = []
|
1006 |
+
for i, d in enumerate(self.discriminators):
|
1007 |
+
y_d_r, fmap_r = d(y)
|
1008 |
+
y_d_g, fmap_g = d(y_hat)
|
1009 |
+
# for j in range(len(fmap_r)):
|
1010 |
+
# print(i,j,y.shape,y_hat.shape,fmap_r[j].shape,fmap_g[j].shape)
|
1011 |
+
y_d_rs.append(y_d_r)
|
1012 |
+
y_d_gs.append(y_d_g)
|
1013 |
+
fmap_rs.append(fmap_r)
|
1014 |
+
fmap_gs.append(fmap_g)
|
1015 |
+
|
1016 |
+
return y_d_rs, y_d_gs, fmap_rs, fmap_gs
|
1017 |
+
|
1018 |
+
|
1019 |
+
class DiscriminatorS(torch.nn.Module):
|
1020 |
+
def __init__(self, use_spectral_norm=False):
|
1021 |
+
super(DiscriminatorS, self).__init__()
|
1022 |
+
norm_f = weight_norm if use_spectral_norm == False else spectral_norm
|
1023 |
+
self.convs = nn.ModuleList(
|
1024 |
+
[
|
1025 |
+
norm_f(Conv1d(1, 16, 15, 1, padding=7)),
|
1026 |
+
norm_f(Conv1d(16, 64, 41, 4, groups=4, padding=20)),
|
1027 |
+
norm_f(Conv1d(64, 256, 41, 4, groups=16, padding=20)),
|
1028 |
+
norm_f(Conv1d(256, 1024, 41, 4, groups=64, padding=20)),
|
1029 |
+
norm_f(Conv1d(1024, 1024, 41, 4, groups=256, padding=20)),
|
1030 |
+
norm_f(Conv1d(1024, 1024, 5, 1, padding=2)),
|
1031 |
+
]
|
1032 |
+
)
|
1033 |
+
self.conv_post = norm_f(Conv1d(1024, 1, 3, 1, padding=1))
|
1034 |
+
|
1035 |
+
def forward(self, x):
|
1036 |
+
fmap = []
|
1037 |
+
|
1038 |
+
for l in self.convs:
|
1039 |
+
x = l(x)
|
1040 |
+
x = F.leaky_relu(x, modules.LRELU_SLOPE)
|
1041 |
+
fmap.append(x)
|
1042 |
+
x = self.conv_post(x)
|
1043 |
+
fmap.append(x)
|
1044 |
+
x = torch.flatten(x, 1, -1)
|
1045 |
+
|
1046 |
+
return x, fmap
|
1047 |
+
|
1048 |
+
|
1049 |
+
class DiscriminatorP(torch.nn.Module):
|
1050 |
+
def __init__(self, period, kernel_size=5, stride=3, use_spectral_norm=False):
|
1051 |
+
super(DiscriminatorP, self).__init__()
|
1052 |
+
self.period = period
|
1053 |
+
self.use_spectral_norm = use_spectral_norm
|
1054 |
+
norm_f = weight_norm if use_spectral_norm == False else spectral_norm
|
1055 |
+
self.convs = nn.ModuleList(
|
1056 |
+
[
|
1057 |
+
norm_f(
|
1058 |
+
Conv2d(
|
1059 |
+
1,
|
1060 |
+
32,
|
1061 |
+
(kernel_size, 1),
|
1062 |
+
(stride, 1),
|
1063 |
+
padding=(get_padding(kernel_size, 1), 0),
|
1064 |
+
)
|
1065 |
+
),
|
1066 |
+
norm_f(
|
1067 |
+
Conv2d(
|
1068 |
+
32,
|
1069 |
+
128,
|
1070 |
+
(kernel_size, 1),
|
1071 |
+
(stride, 1),
|
1072 |
+
padding=(get_padding(kernel_size, 1), 0),
|
1073 |
+
)
|
1074 |
+
),
|
1075 |
+
norm_f(
|
1076 |
+
Conv2d(
|
1077 |
+
128,
|
1078 |
+
512,
|
1079 |
+
(kernel_size, 1),
|
1080 |
+
(stride, 1),
|
1081 |
+
padding=(get_padding(kernel_size, 1), 0),
|
1082 |
+
)
|
1083 |
+
),
|
1084 |
+
norm_f(
|
1085 |
+
Conv2d(
|
1086 |
+
512,
|
1087 |
+
1024,
|
1088 |
+
(kernel_size, 1),
|
1089 |
+
(stride, 1),
|
1090 |
+
padding=(get_padding(kernel_size, 1), 0),
|
1091 |
+
)
|
1092 |
+
),
|
1093 |
+
norm_f(
|
1094 |
+
Conv2d(
|
1095 |
+
1024,
|
1096 |
+
1024,
|
1097 |
+
(kernel_size, 1),
|
1098 |
+
1,
|
1099 |
+
padding=(get_padding(kernel_size, 1), 0),
|
1100 |
+
)
|
1101 |
+
),
|
1102 |
+
]
|
1103 |
+
)
|
1104 |
+
self.conv_post = norm_f(Conv2d(1024, 1, (3, 1), 1, padding=(1, 0)))
|
1105 |
+
|
1106 |
+
def forward(self, x):
|
1107 |
+
fmap = []
|
1108 |
+
|
1109 |
+
# 1d to 2d
|
1110 |
+
b, c, t = x.shape
|
1111 |
+
if t % self.period != 0: # pad first
|
1112 |
+
n_pad = self.period - (t % self.period)
|
1113 |
+
x = F.pad(x, (0, n_pad), "reflect")
|
1114 |
+
t = t + n_pad
|
1115 |
+
x = x.view(b, c, t // self.period, self.period)
|
1116 |
+
|
1117 |
+
for l in self.convs:
|
1118 |
+
x = l(x)
|
1119 |
+
x = F.leaky_relu(x, modules.LRELU_SLOPE)
|
1120 |
+
fmap.append(x)
|
1121 |
+
x = self.conv_post(x)
|
1122 |
+
fmap.append(x)
|
1123 |
+
x = torch.flatten(x, 1, -1)
|
1124 |
+
|
1125 |
+
return x, fmap
|
lib/infer_pack/models_onnx.py
CHANGED
@@ -1,819 +1,820 @@
|
|
1 |
-
import math, pdb, os
|
2 |
-
from time import time as ttime
|
3 |
-
import torch
|
4 |
-
from torch import nn
|
5 |
-
from torch.nn import functional as F
|
6 |
-
from lib.infer_pack import modules
|
7 |
-
from lib.infer_pack import attentions
|
8 |
-
from lib.infer_pack import commons
|
9 |
-
from lib.infer_pack.commons import init_weights, get_padding
|
10 |
-
from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d
|
11 |
-
from torch.nn.utils import
|
12 |
-
from
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
self.
|
32 |
-
self.
|
33 |
-
self.
|
34 |
-
self.
|
35 |
-
self.
|
36 |
-
self.
|
37 |
-
self.
|
38 |
-
self.
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
x = self.
|
53 |
-
x =
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
self.
|
79 |
-
self.
|
80 |
-
self.
|
81 |
-
self.
|
82 |
-
self.
|
83 |
-
self.
|
84 |
-
self.
|
85 |
-
self.
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
x = self.
|
100 |
-
x =
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
self.
|
125 |
-
self.
|
126 |
-
self.
|
127 |
-
self.
|
128 |
-
self.
|
129 |
-
self.
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
self.
|
174 |
-
self.
|
175 |
-
self.
|
176 |
-
self.
|
177 |
-
self.
|
178 |
-
self.
|
179 |
-
|
180 |
-
|
181 |
-
self.
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
x = self.
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
self.
|
219 |
-
self.
|
220 |
-
self.
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
upsample_initial_channel // (2
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
self.
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
x =
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
x =
|
270 |
-
x =
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
self.
|
308 |
-
self.
|
309 |
-
self.
|
310 |
-
self.
|
311 |
-
self.
|
312 |
-
self.
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
uv
|
317 |
-
uv =
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
output
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
tmp_over_one
|
344 |
-
tmp_over_one
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
cumsum_shift
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
uv =
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
SourceModule
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
self.
|
404 |
-
self.
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
self.
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
self.
|
438 |
-
self.
|
439 |
-
|
440 |
-
|
441 |
-
self.
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
self.
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
upsample_initial_channel // (2
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
self.
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
har_source =
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
x =
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
x =
|
515 |
-
x =
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
"
|
528 |
-
"
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
self.
|
561 |
-
self.
|
562 |
-
self.
|
563 |
-
self.
|
564 |
-
self.
|
565 |
-
self.
|
566 |
-
self.
|
567 |
-
self.
|
568 |
-
self.
|
569 |
-
self.
|
570 |
-
self.
|
571 |
-
self.
|
572 |
-
self.
|
573 |
-
self.
|
574 |
-
self.
|
575 |
-
|
576 |
-
self.
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
self.
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
self.
|
628 |
-
self.
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
g = g
|
640 |
-
g =
|
641 |
-
g =
|
642 |
-
|
643 |
-
|
644 |
-
g =
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
discs =
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
#
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
periods = [2, 3, 5, 7, 11, 17
|
688 |
-
|
689 |
-
|
690 |
-
discs =
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
#
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
norm_f(Conv1d(
|
721 |
-
norm_f(Conv1d(
|
722 |
-
norm_f(Conv1d(
|
723 |
-
norm_f(Conv1d(
|
724 |
-
norm_f(Conv1d(1024, 1024,
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
x =
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
self.
|
747 |
-
self.
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
(
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
(
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
(
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
(
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
1024,
|
791 |
-
|
792 |
-
1,
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
x =
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
|
|
|
1 |
+
import math, pdb, os
|
2 |
+
from time import time as ttime
|
3 |
+
import torch
|
4 |
+
from torch import nn
|
5 |
+
from torch.nn import functional as F
|
6 |
+
from lib.infer_pack import modules
|
7 |
+
from lib.infer_pack import attentions
|
8 |
+
from lib.infer_pack import commons
|
9 |
+
from lib.infer_pack.commons import init_weights, get_padding
|
10 |
+
from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d
|
11 |
+
from torch.nn.utils import remove_weight_norm
|
12 |
+
from torch.nn.utils.parametrizations import spectral_norm, weight_norm
|
13 |
+
from lib.infer_pack.commons import init_weights
|
14 |
+
import numpy as np
|
15 |
+
from lib.infer_pack import commons
|
16 |
+
|
17 |
+
|
18 |
+
class TextEncoder256(nn.Module):
|
19 |
+
def __init__(
|
20 |
+
self,
|
21 |
+
out_channels,
|
22 |
+
hidden_channels,
|
23 |
+
filter_channels,
|
24 |
+
n_heads,
|
25 |
+
n_layers,
|
26 |
+
kernel_size,
|
27 |
+
p_dropout,
|
28 |
+
f0=True,
|
29 |
+
):
|
30 |
+
super().__init__()
|
31 |
+
self.out_channels = out_channels
|
32 |
+
self.hidden_channels = hidden_channels
|
33 |
+
self.filter_channels = filter_channels
|
34 |
+
self.n_heads = n_heads
|
35 |
+
self.n_layers = n_layers
|
36 |
+
self.kernel_size = kernel_size
|
37 |
+
self.p_dropout = p_dropout
|
38 |
+
self.emb_phone = nn.Linear(256, hidden_channels)
|
39 |
+
self.lrelu = nn.LeakyReLU(0.1, inplace=True)
|
40 |
+
if f0 == True:
|
41 |
+
self.emb_pitch = nn.Embedding(256, hidden_channels) # pitch 256
|
42 |
+
self.encoder = attentions.Encoder(
|
43 |
+
hidden_channels, filter_channels, n_heads, n_layers, kernel_size, p_dropout
|
44 |
+
)
|
45 |
+
self.proj = nn.Conv1d(hidden_channels, out_channels * 2, 1)
|
46 |
+
|
47 |
+
def forward(self, phone, pitch, lengths):
|
48 |
+
if pitch == None:
|
49 |
+
x = self.emb_phone(phone)
|
50 |
+
else:
|
51 |
+
x = self.emb_phone(phone) + self.emb_pitch(pitch)
|
52 |
+
x = x * math.sqrt(self.hidden_channels) # [b, t, h]
|
53 |
+
x = self.lrelu(x)
|
54 |
+
x = torch.transpose(x, 1, -1) # [b, h, t]
|
55 |
+
x_mask = torch.unsqueeze(commons.sequence_mask(lengths, x.size(2)), 1).to(
|
56 |
+
x.dtype
|
57 |
+
)
|
58 |
+
x = self.encoder(x * x_mask, x_mask)
|
59 |
+
stats = self.proj(x) * x_mask
|
60 |
+
|
61 |
+
m, logs = torch.split(stats, self.out_channels, dim=1)
|
62 |
+
return m, logs, x_mask
|
63 |
+
|
64 |
+
|
65 |
+
class TextEncoder768(nn.Module):
|
66 |
+
def __init__(
|
67 |
+
self,
|
68 |
+
out_channels,
|
69 |
+
hidden_channels,
|
70 |
+
filter_channels,
|
71 |
+
n_heads,
|
72 |
+
n_layers,
|
73 |
+
kernel_size,
|
74 |
+
p_dropout,
|
75 |
+
f0=True,
|
76 |
+
):
|
77 |
+
super().__init__()
|
78 |
+
self.out_channels = out_channels
|
79 |
+
self.hidden_channels = hidden_channels
|
80 |
+
self.filter_channels = filter_channels
|
81 |
+
self.n_heads = n_heads
|
82 |
+
self.n_layers = n_layers
|
83 |
+
self.kernel_size = kernel_size
|
84 |
+
self.p_dropout = p_dropout
|
85 |
+
self.emb_phone = nn.Linear(768, hidden_channels)
|
86 |
+
self.lrelu = nn.LeakyReLU(0.1, inplace=True)
|
87 |
+
if f0 == True:
|
88 |
+
self.emb_pitch = nn.Embedding(256, hidden_channels) # pitch 256
|
89 |
+
self.encoder = attentions.Encoder(
|
90 |
+
hidden_channels, filter_channels, n_heads, n_layers, kernel_size, p_dropout
|
91 |
+
)
|
92 |
+
self.proj = nn.Conv1d(hidden_channels, out_channels * 2, 1)
|
93 |
+
|
94 |
+
def forward(self, phone, pitch, lengths):
|
95 |
+
if pitch == None:
|
96 |
+
x = self.emb_phone(phone)
|
97 |
+
else:
|
98 |
+
x = self.emb_phone(phone) + self.emb_pitch(pitch)
|
99 |
+
x = x * math.sqrt(self.hidden_channels) # [b, t, h]
|
100 |
+
x = self.lrelu(x)
|
101 |
+
x = torch.transpose(x, 1, -1) # [b, h, t]
|
102 |
+
x_mask = torch.unsqueeze(commons.sequence_mask(lengths, x.size(2)), 1).to(
|
103 |
+
x.dtype
|
104 |
+
)
|
105 |
+
x = self.encoder(x * x_mask, x_mask)
|
106 |
+
stats = self.proj(x) * x_mask
|
107 |
+
|
108 |
+
m, logs = torch.split(stats, self.out_channels, dim=1)
|
109 |
+
return m, logs, x_mask
|
110 |
+
|
111 |
+
|
112 |
+
class ResidualCouplingBlock(nn.Module):
|
113 |
+
def __init__(
|
114 |
+
self,
|
115 |
+
channels,
|
116 |
+
hidden_channels,
|
117 |
+
kernel_size,
|
118 |
+
dilation_rate,
|
119 |
+
n_layers,
|
120 |
+
n_flows=4,
|
121 |
+
gin_channels=0,
|
122 |
+
):
|
123 |
+
super().__init__()
|
124 |
+
self.channels = channels
|
125 |
+
self.hidden_channels = hidden_channels
|
126 |
+
self.kernel_size = kernel_size
|
127 |
+
self.dilation_rate = dilation_rate
|
128 |
+
self.n_layers = n_layers
|
129 |
+
self.n_flows = n_flows
|
130 |
+
self.gin_channels = gin_channels
|
131 |
+
|
132 |
+
self.flows = nn.ModuleList()
|
133 |
+
for i in range(n_flows):
|
134 |
+
self.flows.append(
|
135 |
+
modules.ResidualCouplingLayer(
|
136 |
+
channels,
|
137 |
+
hidden_channels,
|
138 |
+
kernel_size,
|
139 |
+
dilation_rate,
|
140 |
+
n_layers,
|
141 |
+
gin_channels=gin_channels,
|
142 |
+
mean_only=True,
|
143 |
+
)
|
144 |
+
)
|
145 |
+
self.flows.append(modules.Flip())
|
146 |
+
|
147 |
+
def forward(self, x, x_mask, g=None, reverse=False):
|
148 |
+
if not reverse:
|
149 |
+
for flow in self.flows:
|
150 |
+
x, _ = flow(x, x_mask, g=g, reverse=reverse)
|
151 |
+
else:
|
152 |
+
for flow in reversed(self.flows):
|
153 |
+
x = flow(x, x_mask, g=g, reverse=reverse)
|
154 |
+
return x
|
155 |
+
|
156 |
+
def remove_weight_norm(self):
|
157 |
+
for i in range(self.n_flows):
|
158 |
+
self.flows[i * 2].remove_weight_norm()
|
159 |
+
|
160 |
+
|
161 |
+
class PosteriorEncoder(nn.Module):
|
162 |
+
def __init__(
|
163 |
+
self,
|
164 |
+
in_channels,
|
165 |
+
out_channels,
|
166 |
+
hidden_channels,
|
167 |
+
kernel_size,
|
168 |
+
dilation_rate,
|
169 |
+
n_layers,
|
170 |
+
gin_channels=0,
|
171 |
+
):
|
172 |
+
super().__init__()
|
173 |
+
self.in_channels = in_channels
|
174 |
+
self.out_channels = out_channels
|
175 |
+
self.hidden_channels = hidden_channels
|
176 |
+
self.kernel_size = kernel_size
|
177 |
+
self.dilation_rate = dilation_rate
|
178 |
+
self.n_layers = n_layers
|
179 |
+
self.gin_channels = gin_channels
|
180 |
+
|
181 |
+
self.pre = nn.Conv1d(in_channels, hidden_channels, 1)
|
182 |
+
self.enc = modules.WN(
|
183 |
+
hidden_channels,
|
184 |
+
kernel_size,
|
185 |
+
dilation_rate,
|
186 |
+
n_layers,
|
187 |
+
gin_channels=gin_channels,
|
188 |
+
)
|
189 |
+
self.proj = nn.Conv1d(hidden_channels, out_channels * 2, 1)
|
190 |
+
|
191 |
+
def forward(self, x, x_lengths, g=None):
|
192 |
+
x_mask = torch.unsqueeze(commons.sequence_mask(x_lengths, x.size(2)), 1).to(
|
193 |
+
x.dtype
|
194 |
+
)
|
195 |
+
x = self.pre(x) * x_mask
|
196 |
+
x = self.enc(x, x_mask, g=g)
|
197 |
+
stats = self.proj(x) * x_mask
|
198 |
+
m, logs = torch.split(stats, self.out_channels, dim=1)
|
199 |
+
z = (m + torch.randn_like(m) * torch.exp(logs)) * x_mask
|
200 |
+
return z, m, logs, x_mask
|
201 |
+
|
202 |
+
def remove_weight_norm(self):
|
203 |
+
self.enc.remove_weight_norm()
|
204 |
+
|
205 |
+
|
206 |
+
class Generator(torch.nn.Module):
|
207 |
+
def __init__(
|
208 |
+
self,
|
209 |
+
initial_channel,
|
210 |
+
resblock,
|
211 |
+
resblock_kernel_sizes,
|
212 |
+
resblock_dilation_sizes,
|
213 |
+
upsample_rates,
|
214 |
+
upsample_initial_channel,
|
215 |
+
upsample_kernel_sizes,
|
216 |
+
gin_channels=0,
|
217 |
+
):
|
218 |
+
super(Generator, self).__init__()
|
219 |
+
self.num_kernels = len(resblock_kernel_sizes)
|
220 |
+
self.num_upsamples = len(upsample_rates)
|
221 |
+
self.conv_pre = Conv1d(
|
222 |
+
initial_channel, upsample_initial_channel, 7, 1, padding=3
|
223 |
+
)
|
224 |
+
resblock = modules.ResBlock1 if resblock == "1" else modules.ResBlock2
|
225 |
+
|
226 |
+
self.ups = nn.ModuleList()
|
227 |
+
for i, (u, k) in enumerate(zip(upsample_rates, upsample_kernel_sizes)):
|
228 |
+
self.ups.append(
|
229 |
+
weight_norm(
|
230 |
+
ConvTranspose1d(
|
231 |
+
upsample_initial_channel // (2**i),
|
232 |
+
upsample_initial_channel // (2 ** (i + 1)),
|
233 |
+
k,
|
234 |
+
u,
|
235 |
+
padding=(k - u) // 2,
|
236 |
+
)
|
237 |
+
)
|
238 |
+
)
|
239 |
+
|
240 |
+
self.resblocks = nn.ModuleList()
|
241 |
+
for i in range(len(self.ups)):
|
242 |
+
ch = upsample_initial_channel // (2 ** (i + 1))
|
243 |
+
for j, (k, d) in enumerate(
|
244 |
+
zip(resblock_kernel_sizes, resblock_dilation_sizes)
|
245 |
+
):
|
246 |
+
self.resblocks.append(resblock(ch, k, d))
|
247 |
+
|
248 |
+
self.conv_post = Conv1d(ch, 1, 7, 1, padding=3, bias=False)
|
249 |
+
self.ups.apply(init_weights)
|
250 |
+
|
251 |
+
if gin_channels != 0:
|
252 |
+
self.cond = nn.Conv1d(gin_channels, upsample_initial_channel, 1)
|
253 |
+
|
254 |
+
def forward(self, x, g=None):
|
255 |
+
x = self.conv_pre(x)
|
256 |
+
if g is not None:
|
257 |
+
x = x + self.cond(g)
|
258 |
+
|
259 |
+
for i in range(self.num_upsamples):
|
260 |
+
x = F.leaky_relu(x, modules.LRELU_SLOPE)
|
261 |
+
x = self.ups[i](x)
|
262 |
+
xs = None
|
263 |
+
for j in range(self.num_kernels):
|
264 |
+
if xs is None:
|
265 |
+
xs = self.resblocks[i * self.num_kernels + j](x)
|
266 |
+
else:
|
267 |
+
xs += self.resblocks[i * self.num_kernels + j](x)
|
268 |
+
x = xs / self.num_kernels
|
269 |
+
x = F.leaky_relu(x)
|
270 |
+
x = self.conv_post(x)
|
271 |
+
x = torch.tanh(x)
|
272 |
+
|
273 |
+
return x
|
274 |
+
|
275 |
+
def remove_weight_norm(self):
|
276 |
+
for l in self.ups:
|
277 |
+
remove_weight_norm(l)
|
278 |
+
for l in self.resblocks:
|
279 |
+
l.remove_weight_norm()
|
280 |
+
|
281 |
+
|
282 |
+
class SineGen(torch.nn.Module):
|
283 |
+
"""Definition of sine generator
|
284 |
+
SineGen(samp_rate, harmonic_num = 0,
|
285 |
+
sine_amp = 0.1, noise_std = 0.003,
|
286 |
+
voiced_threshold = 0,
|
287 |
+
flag_for_pulse=False)
|
288 |
+
samp_rate: sampling rate in Hz
|
289 |
+
harmonic_num: number of harmonic overtones (default 0)
|
290 |
+
sine_amp: amplitude of sine-wavefrom (default 0.1)
|
291 |
+
noise_std: std of Gaussian noise (default 0.003)
|
292 |
+
voiced_thoreshold: F0 threshold for U/V classification (default 0)
|
293 |
+
flag_for_pulse: this SinGen is used inside PulseGen (default False)
|
294 |
+
Note: when flag_for_pulse is True, the first time step of a voiced
|
295 |
+
segment is always sin(np.pi) or cos(0)
|
296 |
+
"""
|
297 |
+
|
298 |
+
def __init__(
|
299 |
+
self,
|
300 |
+
samp_rate,
|
301 |
+
harmonic_num=0,
|
302 |
+
sine_amp=0.1,
|
303 |
+
noise_std=0.003,
|
304 |
+
voiced_threshold=0,
|
305 |
+
flag_for_pulse=False,
|
306 |
+
):
|
307 |
+
super(SineGen, self).__init__()
|
308 |
+
self.sine_amp = sine_amp
|
309 |
+
self.noise_std = noise_std
|
310 |
+
self.harmonic_num = harmonic_num
|
311 |
+
self.dim = self.harmonic_num + 1
|
312 |
+
self.sampling_rate = samp_rate
|
313 |
+
self.voiced_threshold = voiced_threshold
|
314 |
+
|
315 |
+
def _f02uv(self, f0):
|
316 |
+
# generate uv signal
|
317 |
+
uv = torch.ones_like(f0)
|
318 |
+
uv = uv * (f0 > self.voiced_threshold)
|
319 |
+
return uv
|
320 |
+
|
321 |
+
def forward(self, f0, upp):
|
322 |
+
"""sine_tensor, uv = forward(f0)
|
323 |
+
input F0: tensor(batchsize=1, length, dim=1)
|
324 |
+
f0 for unvoiced steps should be 0
|
325 |
+
output sine_tensor: tensor(batchsize=1, length, dim)
|
326 |
+
output uv: tensor(batchsize=1, length, 1)
|
327 |
+
"""
|
328 |
+
with torch.no_grad():
|
329 |
+
f0 = f0[:, None].transpose(1, 2)
|
330 |
+
f0_buf = torch.zeros(f0.shape[0], f0.shape[1], self.dim, device=f0.device)
|
331 |
+
# fundamental component
|
332 |
+
f0_buf[:, :, 0] = f0[:, :, 0]
|
333 |
+
for idx in np.arange(self.harmonic_num):
|
334 |
+
f0_buf[:, :, idx + 1] = f0_buf[:, :, 0] * (
|
335 |
+
idx + 2
|
336 |
+
) # idx + 2: the (idx+1)-th overtone, (idx+2)-th harmonic
|
337 |
+
rad_values = (f0_buf / self.sampling_rate) % 1 ###%1意味着n_har的乘积无法后处理优化
|
338 |
+
rand_ini = torch.rand(
|
339 |
+
f0_buf.shape[0], f0_buf.shape[2], device=f0_buf.device
|
340 |
+
)
|
341 |
+
rand_ini[:, 0] = 0
|
342 |
+
rad_values[:, 0, :] = rad_values[:, 0, :] + rand_ini
|
343 |
+
tmp_over_one = torch.cumsum(rad_values, 1) # % 1 #####%1意味着后面的cumsum无法再优化
|
344 |
+
tmp_over_one *= upp
|
345 |
+
tmp_over_one = F.interpolate(
|
346 |
+
tmp_over_one.transpose(2, 1),
|
347 |
+
scale_factor=upp,
|
348 |
+
mode="linear",
|
349 |
+
align_corners=True,
|
350 |
+
).transpose(2, 1)
|
351 |
+
rad_values = F.interpolate(
|
352 |
+
rad_values.transpose(2, 1), scale_factor=upp, mode="nearest"
|
353 |
+
).transpose(
|
354 |
+
2, 1
|
355 |
+
) #######
|
356 |
+
tmp_over_one %= 1
|
357 |
+
tmp_over_one_idx = (tmp_over_one[:, 1:, :] - tmp_over_one[:, :-1, :]) < 0
|
358 |
+
cumsum_shift = torch.zeros_like(rad_values)
|
359 |
+
cumsum_shift[:, 1:, :] = tmp_over_one_idx * -1.0
|
360 |
+
sine_waves = torch.sin(
|
361 |
+
torch.cumsum(rad_values + cumsum_shift, dim=1) * 2 * np.pi
|
362 |
+
)
|
363 |
+
sine_waves = sine_waves * self.sine_amp
|
364 |
+
uv = self._f02uv(f0)
|
365 |
+
uv = F.interpolate(
|
366 |
+
uv.transpose(2, 1), scale_factor=upp, mode="nearest"
|
367 |
+
).transpose(2, 1)
|
368 |
+
noise_amp = uv * self.noise_std + (1 - uv) * self.sine_amp / 3
|
369 |
+
noise = noise_amp * torch.randn_like(sine_waves)
|
370 |
+
sine_waves = sine_waves * uv + noise
|
371 |
+
return sine_waves, uv, noise
|
372 |
+
|
373 |
+
|
374 |
+
class SourceModuleHnNSF(torch.nn.Module):
|
375 |
+
"""SourceModule for hn-nsf
|
376 |
+
SourceModule(sampling_rate, harmonic_num=0, sine_amp=0.1,
|
377 |
+
add_noise_std=0.003, voiced_threshod=0)
|
378 |
+
sampling_rate: sampling_rate in Hz
|
379 |
+
harmonic_num: number of harmonic above F0 (default: 0)
|
380 |
+
sine_amp: amplitude of sine source signal (default: 0.1)
|
381 |
+
add_noise_std: std of additive Gaussian noise (default: 0.003)
|
382 |
+
note that amplitude of noise in unvoiced is decided
|
383 |
+
by sine_amp
|
384 |
+
voiced_threshold: threhold to set U/V given F0 (default: 0)
|
385 |
+
Sine_source, noise_source = SourceModuleHnNSF(F0_sampled)
|
386 |
+
F0_sampled (batchsize, length, 1)
|
387 |
+
Sine_source (batchsize, length, 1)
|
388 |
+
noise_source (batchsize, length 1)
|
389 |
+
uv (batchsize, length, 1)
|
390 |
+
"""
|
391 |
+
|
392 |
+
def __init__(
|
393 |
+
self,
|
394 |
+
sampling_rate,
|
395 |
+
harmonic_num=0,
|
396 |
+
sine_amp=0.1,
|
397 |
+
add_noise_std=0.003,
|
398 |
+
voiced_threshod=0,
|
399 |
+
is_half=True,
|
400 |
+
):
|
401 |
+
super(SourceModuleHnNSF, self).__init__()
|
402 |
+
|
403 |
+
self.sine_amp = sine_amp
|
404 |
+
self.noise_std = add_noise_std
|
405 |
+
self.is_half = is_half
|
406 |
+
# to produce sine waveforms
|
407 |
+
self.l_sin_gen = SineGen(
|
408 |
+
sampling_rate, harmonic_num, sine_amp, add_noise_std, voiced_threshod
|
409 |
+
)
|
410 |
+
|
411 |
+
# to merge source harmonics into a single excitation
|
412 |
+
self.l_linear = torch.nn.Linear(harmonic_num + 1, 1)
|
413 |
+
self.l_tanh = torch.nn.Tanh()
|
414 |
+
|
415 |
+
def forward(self, x, upp=None):
|
416 |
+
sine_wavs, uv, _ = self.l_sin_gen(x, upp)
|
417 |
+
if self.is_half:
|
418 |
+
sine_wavs = sine_wavs.half()
|
419 |
+
sine_merge = self.l_tanh(self.l_linear(sine_wavs))
|
420 |
+
return sine_merge, None, None # noise, uv
|
421 |
+
|
422 |
+
|
423 |
+
class GeneratorNSF(torch.nn.Module):
|
424 |
+
def __init__(
|
425 |
+
self,
|
426 |
+
initial_channel,
|
427 |
+
resblock,
|
428 |
+
resblock_kernel_sizes,
|
429 |
+
resblock_dilation_sizes,
|
430 |
+
upsample_rates,
|
431 |
+
upsample_initial_channel,
|
432 |
+
upsample_kernel_sizes,
|
433 |
+
gin_channels,
|
434 |
+
sr,
|
435 |
+
is_half=False,
|
436 |
+
):
|
437 |
+
super(GeneratorNSF, self).__init__()
|
438 |
+
self.num_kernels = len(resblock_kernel_sizes)
|
439 |
+
self.num_upsamples = len(upsample_rates)
|
440 |
+
|
441 |
+
self.f0_upsamp = torch.nn.Upsample(scale_factor=np.prod(upsample_rates))
|
442 |
+
self.m_source = SourceModuleHnNSF(
|
443 |
+
sampling_rate=sr, harmonic_num=0, is_half=is_half
|
444 |
+
)
|
445 |
+
self.noise_convs = nn.ModuleList()
|
446 |
+
self.conv_pre = Conv1d(
|
447 |
+
initial_channel, upsample_initial_channel, 7, 1, padding=3
|
448 |
+
)
|
449 |
+
resblock = modules.ResBlock1 if resblock == "1" else modules.ResBlock2
|
450 |
+
|
451 |
+
self.ups = nn.ModuleList()
|
452 |
+
for i, (u, k) in enumerate(zip(upsample_rates, upsample_kernel_sizes)):
|
453 |
+
c_cur = upsample_initial_channel // (2 ** (i + 1))
|
454 |
+
self.ups.append(
|
455 |
+
weight_norm(
|
456 |
+
ConvTranspose1d(
|
457 |
+
upsample_initial_channel // (2**i),
|
458 |
+
upsample_initial_channel // (2 ** (i + 1)),
|
459 |
+
k,
|
460 |
+
u,
|
461 |
+
padding=(k - u) // 2,
|
462 |
+
)
|
463 |
+
)
|
464 |
+
)
|
465 |
+
if i + 1 < len(upsample_rates):
|
466 |
+
stride_f0 = np.prod(upsample_rates[i + 1 :])
|
467 |
+
self.noise_convs.append(
|
468 |
+
Conv1d(
|
469 |
+
1,
|
470 |
+
c_cur,
|
471 |
+
kernel_size=stride_f0 * 2,
|
472 |
+
stride=stride_f0,
|
473 |
+
padding=stride_f0 // 2,
|
474 |
+
)
|
475 |
+
)
|
476 |
+
else:
|
477 |
+
self.noise_convs.append(Conv1d(1, c_cur, kernel_size=1))
|
478 |
+
|
479 |
+
self.resblocks = nn.ModuleList()
|
480 |
+
for i in range(len(self.ups)):
|
481 |
+
ch = upsample_initial_channel // (2 ** (i + 1))
|
482 |
+
for j, (k, d) in enumerate(
|
483 |
+
zip(resblock_kernel_sizes, resblock_dilation_sizes)
|
484 |
+
):
|
485 |
+
self.resblocks.append(resblock(ch, k, d))
|
486 |
+
|
487 |
+
self.conv_post = Conv1d(ch, 1, 7, 1, padding=3, bias=False)
|
488 |
+
self.ups.apply(init_weights)
|
489 |
+
|
490 |
+
if gin_channels != 0:
|
491 |
+
self.cond = nn.Conv1d(gin_channels, upsample_initial_channel, 1)
|
492 |
+
|
493 |
+
self.upp = np.prod(upsample_rates)
|
494 |
+
|
495 |
+
def forward(self, x, f0, g=None):
|
496 |
+
har_source, noi_source, uv = self.m_source(f0, self.upp)
|
497 |
+
har_source = har_source.transpose(1, 2)
|
498 |
+
x = self.conv_pre(x)
|
499 |
+
if g is not None:
|
500 |
+
x = x + self.cond(g)
|
501 |
+
|
502 |
+
for i in range(self.num_upsamples):
|
503 |
+
x = F.leaky_relu(x, modules.LRELU_SLOPE)
|
504 |
+
x = self.ups[i](x)
|
505 |
+
x_source = self.noise_convs[i](har_source)
|
506 |
+
x = x + x_source
|
507 |
+
xs = None
|
508 |
+
for j in range(self.num_kernels):
|
509 |
+
if xs is None:
|
510 |
+
xs = self.resblocks[i * self.num_kernels + j](x)
|
511 |
+
else:
|
512 |
+
xs += self.resblocks[i * self.num_kernels + j](x)
|
513 |
+
x = xs / self.num_kernels
|
514 |
+
x = F.leaky_relu(x)
|
515 |
+
x = self.conv_post(x)
|
516 |
+
x = torch.tanh(x)
|
517 |
+
return x
|
518 |
+
|
519 |
+
def remove_weight_norm(self):
|
520 |
+
for l in self.ups:
|
521 |
+
remove_weight_norm(l)
|
522 |
+
for l in self.resblocks:
|
523 |
+
l.remove_weight_norm()
|
524 |
+
|
525 |
+
|
526 |
+
sr2sr = {
|
527 |
+
"32k": 32000,
|
528 |
+
"40k": 40000,
|
529 |
+
"48k": 48000,
|
530 |
+
}
|
531 |
+
|
532 |
+
|
533 |
+
class SynthesizerTrnMsNSFsidM(nn.Module):
|
534 |
+
def __init__(
|
535 |
+
self,
|
536 |
+
spec_channels,
|
537 |
+
segment_size,
|
538 |
+
inter_channels,
|
539 |
+
hidden_channels,
|
540 |
+
filter_channels,
|
541 |
+
n_heads,
|
542 |
+
n_layers,
|
543 |
+
kernel_size,
|
544 |
+
p_dropout,
|
545 |
+
resblock,
|
546 |
+
resblock_kernel_sizes,
|
547 |
+
resblock_dilation_sizes,
|
548 |
+
upsample_rates,
|
549 |
+
upsample_initial_channel,
|
550 |
+
upsample_kernel_sizes,
|
551 |
+
spk_embed_dim,
|
552 |
+
gin_channels,
|
553 |
+
sr,
|
554 |
+
version,
|
555 |
+
**kwargs
|
556 |
+
):
|
557 |
+
super().__init__()
|
558 |
+
if type(sr) == type("strr"):
|
559 |
+
sr = sr2sr[sr]
|
560 |
+
self.spec_channels = spec_channels
|
561 |
+
self.inter_channels = inter_channels
|
562 |
+
self.hidden_channels = hidden_channels
|
563 |
+
self.filter_channels = filter_channels
|
564 |
+
self.n_heads = n_heads
|
565 |
+
self.n_layers = n_layers
|
566 |
+
self.kernel_size = kernel_size
|
567 |
+
self.p_dropout = p_dropout
|
568 |
+
self.resblock = resblock
|
569 |
+
self.resblock_kernel_sizes = resblock_kernel_sizes
|
570 |
+
self.resblock_dilation_sizes = resblock_dilation_sizes
|
571 |
+
self.upsample_rates = upsample_rates
|
572 |
+
self.upsample_initial_channel = upsample_initial_channel
|
573 |
+
self.upsample_kernel_sizes = upsample_kernel_sizes
|
574 |
+
self.segment_size = segment_size
|
575 |
+
self.gin_channels = gin_channels
|
576 |
+
# self.hop_length = hop_length#
|
577 |
+
self.spk_embed_dim = spk_embed_dim
|
578 |
+
if version == "v1":
|
579 |
+
self.enc_p = TextEncoder256(
|
580 |
+
inter_channels,
|
581 |
+
hidden_channels,
|
582 |
+
filter_channels,
|
583 |
+
n_heads,
|
584 |
+
n_layers,
|
585 |
+
kernel_size,
|
586 |
+
p_dropout,
|
587 |
+
)
|
588 |
+
else:
|
589 |
+
self.enc_p = TextEncoder768(
|
590 |
+
inter_channels,
|
591 |
+
hidden_channels,
|
592 |
+
filter_channels,
|
593 |
+
n_heads,
|
594 |
+
n_layers,
|
595 |
+
kernel_size,
|
596 |
+
p_dropout,
|
597 |
+
)
|
598 |
+
self.dec = GeneratorNSF(
|
599 |
+
inter_channels,
|
600 |
+
resblock,
|
601 |
+
resblock_kernel_sizes,
|
602 |
+
resblock_dilation_sizes,
|
603 |
+
upsample_rates,
|
604 |
+
upsample_initial_channel,
|
605 |
+
upsample_kernel_sizes,
|
606 |
+
gin_channels=gin_channels,
|
607 |
+
sr=sr,
|
608 |
+
is_half=kwargs["is_half"],
|
609 |
+
)
|
610 |
+
self.enc_q = PosteriorEncoder(
|
611 |
+
spec_channels,
|
612 |
+
inter_channels,
|
613 |
+
hidden_channels,
|
614 |
+
5,
|
615 |
+
1,
|
616 |
+
16,
|
617 |
+
gin_channels=gin_channels,
|
618 |
+
)
|
619 |
+
self.flow = ResidualCouplingBlock(
|
620 |
+
inter_channels, hidden_channels, 5, 1, 3, gin_channels=gin_channels
|
621 |
+
)
|
622 |
+
self.emb_g = nn.Embedding(self.spk_embed_dim, gin_channels)
|
623 |
+
self.speaker_map = None
|
624 |
+
print("gin_channels:", gin_channels, "self.spk_embed_dim:", self.spk_embed_dim)
|
625 |
+
|
626 |
+
def remove_weight_norm(self):
|
627 |
+
self.dec.remove_weight_norm()
|
628 |
+
self.flow.remove_weight_norm()
|
629 |
+
self.enc_q.remove_weight_norm()
|
630 |
+
|
631 |
+
def construct_spkmixmap(self, n_speaker):
|
632 |
+
self.speaker_map = torch.zeros((n_speaker, 1, 1, self.gin_channels))
|
633 |
+
for i in range(n_speaker):
|
634 |
+
self.speaker_map[i] = self.emb_g(torch.LongTensor([[i]]))
|
635 |
+
self.speaker_map = self.speaker_map.unsqueeze(0)
|
636 |
+
|
637 |
+
def forward(self, phone, phone_lengths, pitch, nsff0, g, rnd, max_len=None):
|
638 |
+
if self.speaker_map is not None: # [N, S] * [S, B, 1, H]
|
639 |
+
g = g.reshape((g.shape[0], g.shape[1], 1, 1, 1)) # [N, S, B, 1, 1]
|
640 |
+
g = g * self.speaker_map # [N, S, B, 1, H]
|
641 |
+
g = torch.sum(g, dim=1) # [N, 1, B, 1, H]
|
642 |
+
g = g.transpose(0, -1).transpose(0, -2).squeeze(0) # [B, H, N]
|
643 |
+
else:
|
644 |
+
g = g.unsqueeze(0)
|
645 |
+
g = self.emb_g(g).transpose(1, 2)
|
646 |
+
|
647 |
+
m_p, logs_p, x_mask = self.enc_p(phone, pitch, phone_lengths)
|
648 |
+
z_p = (m_p + torch.exp(logs_p) * rnd) * x_mask
|
649 |
+
z = self.flow(z_p, x_mask, g=g, reverse=True)
|
650 |
+
o = self.dec((z * x_mask)[:, :, :max_len], nsff0, g=g)
|
651 |
+
return o
|
652 |
+
|
653 |
+
|
654 |
+
class MultiPeriodDiscriminator(torch.nn.Module):
|
655 |
+
def __init__(self, use_spectral_norm=False):
|
656 |
+
super(MultiPeriodDiscriminator, self).__init__()
|
657 |
+
periods = [2, 3, 5, 7, 11, 17]
|
658 |
+
# periods = [3, 5, 7, 11, 17, 23, 37]
|
659 |
+
|
660 |
+
discs = [DiscriminatorS(use_spectral_norm=use_spectral_norm)]
|
661 |
+
discs = discs + [
|
662 |
+
DiscriminatorP(i, use_spectral_norm=use_spectral_norm) for i in periods
|
663 |
+
]
|
664 |
+
self.discriminators = nn.ModuleList(discs)
|
665 |
+
|
666 |
+
def forward(self, y, y_hat):
|
667 |
+
y_d_rs = [] #
|
668 |
+
y_d_gs = []
|
669 |
+
fmap_rs = []
|
670 |
+
fmap_gs = []
|
671 |
+
for i, d in enumerate(self.discriminators):
|
672 |
+
y_d_r, fmap_r = d(y)
|
673 |
+
y_d_g, fmap_g = d(y_hat)
|
674 |
+
# for j in range(len(fmap_r)):
|
675 |
+
# print(i,j,y.shape,y_hat.shape,fmap_r[j].shape,fmap_g[j].shape)
|
676 |
+
y_d_rs.append(y_d_r)
|
677 |
+
y_d_gs.append(y_d_g)
|
678 |
+
fmap_rs.append(fmap_r)
|
679 |
+
fmap_gs.append(fmap_g)
|
680 |
+
|
681 |
+
return y_d_rs, y_d_gs, fmap_rs, fmap_gs
|
682 |
+
|
683 |
+
|
684 |
+
class MultiPeriodDiscriminatorV2(torch.nn.Module):
|
685 |
+
def __init__(self, use_spectral_norm=False):
|
686 |
+
super(MultiPeriodDiscriminatorV2, self).__init__()
|
687 |
+
# periods = [2, 3, 5, 7, 11, 17]
|
688 |
+
periods = [2, 3, 5, 7, 11, 17, 23, 37]
|
689 |
+
|
690 |
+
discs = [DiscriminatorS(use_spectral_norm=use_spectral_norm)]
|
691 |
+
discs = discs + [
|
692 |
+
DiscriminatorP(i, use_spectral_norm=use_spectral_norm) for i in periods
|
693 |
+
]
|
694 |
+
self.discriminators = nn.ModuleList(discs)
|
695 |
+
|
696 |
+
def forward(self, y, y_hat):
|
697 |
+
y_d_rs = [] #
|
698 |
+
y_d_gs = []
|
699 |
+
fmap_rs = []
|
700 |
+
fmap_gs = []
|
701 |
+
for i, d in enumerate(self.discriminators):
|
702 |
+
y_d_r, fmap_r = d(y)
|
703 |
+
y_d_g, fmap_g = d(y_hat)
|
704 |
+
# for j in range(len(fmap_r)):
|
705 |
+
# print(i,j,y.shape,y_hat.shape,fmap_r[j].shape,fmap_g[j].shape)
|
706 |
+
y_d_rs.append(y_d_r)
|
707 |
+
y_d_gs.append(y_d_g)
|
708 |
+
fmap_rs.append(fmap_r)
|
709 |
+
fmap_gs.append(fmap_g)
|
710 |
+
|
711 |
+
return y_d_rs, y_d_gs, fmap_rs, fmap_gs
|
712 |
+
|
713 |
+
|
714 |
+
class DiscriminatorS(torch.nn.Module):
|
715 |
+
def __init__(self, use_spectral_norm=False):
|
716 |
+
super(DiscriminatorS, self).__init__()
|
717 |
+
norm_f = weight_norm if use_spectral_norm == False else spectral_norm
|
718 |
+
self.convs = nn.ModuleList(
|
719 |
+
[
|
720 |
+
norm_f(Conv1d(1, 16, 15, 1, padding=7)),
|
721 |
+
norm_f(Conv1d(16, 64, 41, 4, groups=4, padding=20)),
|
722 |
+
norm_f(Conv1d(64, 256, 41, 4, groups=16, padding=20)),
|
723 |
+
norm_f(Conv1d(256, 1024, 41, 4, groups=64, padding=20)),
|
724 |
+
norm_f(Conv1d(1024, 1024, 41, 4, groups=256, padding=20)),
|
725 |
+
norm_f(Conv1d(1024, 1024, 5, 1, padding=2)),
|
726 |
+
]
|
727 |
+
)
|
728 |
+
self.conv_post = norm_f(Conv1d(1024, 1, 3, 1, padding=1))
|
729 |
+
|
730 |
+
def forward(self, x):
|
731 |
+
fmap = []
|
732 |
+
|
733 |
+
for l in self.convs:
|
734 |
+
x = l(x)
|
735 |
+
x = F.leaky_relu(x, modules.LRELU_SLOPE)
|
736 |
+
fmap.append(x)
|
737 |
+
x = self.conv_post(x)
|
738 |
+
fmap.append(x)
|
739 |
+
x = torch.flatten(x, 1, -1)
|
740 |
+
|
741 |
+
return x, fmap
|
742 |
+
|
743 |
+
|
744 |
+
class DiscriminatorP(torch.nn.Module):
|
745 |
+
def __init__(self, period, kernel_size=5, stride=3, use_spectral_norm=False):
|
746 |
+
super(DiscriminatorP, self).__init__()
|
747 |
+
self.period = period
|
748 |
+
self.use_spectral_norm = use_spectral_norm
|
749 |
+
norm_f = weight_norm if use_spectral_norm == False else spectral_norm
|
750 |
+
self.convs = nn.ModuleList(
|
751 |
+
[
|
752 |
+
norm_f(
|
753 |
+
Conv2d(
|
754 |
+
1,
|
755 |
+
32,
|
756 |
+
(kernel_size, 1),
|
757 |
+
(stride, 1),
|
758 |
+
padding=(get_padding(kernel_size, 1), 0),
|
759 |
+
)
|
760 |
+
),
|
761 |
+
norm_f(
|
762 |
+
Conv2d(
|
763 |
+
32,
|
764 |
+
128,
|
765 |
+
(kernel_size, 1),
|
766 |
+
(stride, 1),
|
767 |
+
padding=(get_padding(kernel_size, 1), 0),
|
768 |
+
)
|
769 |
+
),
|
770 |
+
norm_f(
|
771 |
+
Conv2d(
|
772 |
+
128,
|
773 |
+
512,
|
774 |
+
(kernel_size, 1),
|
775 |
+
(stride, 1),
|
776 |
+
padding=(get_padding(kernel_size, 1), 0),
|
777 |
+
)
|
778 |
+
),
|
779 |
+
norm_f(
|
780 |
+
Conv2d(
|
781 |
+
512,
|
782 |
+
1024,
|
783 |
+
(kernel_size, 1),
|
784 |
+
(stride, 1),
|
785 |
+
padding=(get_padding(kernel_size, 1), 0),
|
786 |
+
)
|
787 |
+
),
|
788 |
+
norm_f(
|
789 |
+
Conv2d(
|
790 |
+
1024,
|
791 |
+
1024,
|
792 |
+
(kernel_size, 1),
|
793 |
+
1,
|
794 |
+
padding=(get_padding(kernel_size, 1), 0),
|
795 |
+
)
|
796 |
+
),
|
797 |
+
]
|
798 |
+
)
|
799 |
+
self.conv_post = norm_f(Conv2d(1024, 1, (3, 1), 1, padding=(1, 0)))
|
800 |
+
|
801 |
+
def forward(self, x):
|
802 |
+
fmap = []
|
803 |
+
|
804 |
+
# 1d to 2d
|
805 |
+
b, c, t = x.shape
|
806 |
+
if t % self.period != 0: # pad first
|
807 |
+
n_pad = self.period - (t % self.period)
|
808 |
+
x = F.pad(x, (0, n_pad), "reflect")
|
809 |
+
t = t + n_pad
|
810 |
+
x = x.view(b, c, t // self.period, self.period)
|
811 |
+
|
812 |
+
for l in self.convs:
|
813 |
+
x = l(x)
|
814 |
+
x = F.leaky_relu(x, modules.LRELU_SLOPE)
|
815 |
+
fmap.append(x)
|
816 |
+
x = self.conv_post(x)
|
817 |
+
fmap.append(x)
|
818 |
+
x = torch.flatten(x, 1, -1)
|
819 |
+
|
820 |
+
return x, fmap
|
lib/infer_pack/modules.py
CHANGED
@@ -1,522 +1,524 @@
|
|
1 |
-
import copy
|
2 |
-
import math
|
3 |
-
import numpy as np
|
4 |
-
import scipy
|
5 |
-
import torch
|
6 |
-
from torch import nn
|
7 |
-
from torch.nn import functional as F
|
8 |
-
|
9 |
-
from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d
|
10 |
-
from torch.nn.utils import
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
from lib.infer_pack
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
self.
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
self.
|
49 |
-
self.
|
50 |
-
self.
|
51 |
-
self.
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
self.conv_layers.
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
self.proj.
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
x = self.
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
"""
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
self.
|
97 |
-
self.
|
98 |
-
|
99 |
-
self.
|
100 |
-
|
101 |
-
self.
|
102 |
-
self.
|
103 |
-
self.
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
self.
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
y =
|
128 |
-
y = self.
|
129 |
-
y =
|
130 |
-
y =
|
131 |
-
y = self.
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
self.
|
149 |
-
|
150 |
-
self.
|
151 |
-
self.
|
152 |
-
self.
|
153 |
-
self.
|
154 |
-
|
155 |
-
self.
|
156 |
-
|
157 |
-
self.
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
res_skip_channels = hidden_channels
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
g_l =
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
output = output + res_skip_acts
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
torch.nn.utils.remove_weight_norm(
|
220 |
-
for l in self.
|
221 |
-
torch.nn.utils.remove_weight_norm(l)
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
self.
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
x =
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
for l in self.
|
318 |
-
remove_weight_norm(l)
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
x =
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
return x
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
self.
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
self.
|
422 |
-
self.
|
423 |
-
self.
|
424 |
-
self.
|
425 |
-
self.
|
426 |
-
|
427 |
-
self.
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
self.post.
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
m = stats
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
self.
|
479 |
-
self.
|
480 |
-
self.
|
481 |
-
self.
|
482 |
-
self.
|
483 |
-
|
484 |
-
self.
|
485 |
-
|
486 |
-
self.
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
h = self.
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
return x
|
|
|
|
|
|
1 |
+
import copy
|
2 |
+
import math
|
3 |
+
import numpy as np
|
4 |
+
import scipy
|
5 |
+
import torch
|
6 |
+
from torch import nn
|
7 |
+
from torch.nn import functional as F
|
8 |
+
|
9 |
+
from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d
|
10 |
+
from torch.nn.utils import remove_weight_norm
|
11 |
+
from torch.nn.utils.parametrizations import weight_norm
|
12 |
+
|
13 |
+
|
14 |
+
from lib.infer_pack import commons
|
15 |
+
from lib.infer_pack.commons import init_weights, get_padding
|
16 |
+
from lib.infer_pack.transforms import piecewise_rational_quadratic_transform
|
17 |
+
|
18 |
+
|
19 |
+
LRELU_SLOPE = 0.1
|
20 |
+
|
21 |
+
|
22 |
+
class LayerNorm(nn.Module):
|
23 |
+
def __init__(self, channels, eps=1e-5):
|
24 |
+
super().__init__()
|
25 |
+
self.channels = channels
|
26 |
+
self.eps = eps
|
27 |
+
|
28 |
+
self.gamma = nn.Parameter(torch.ones(channels))
|
29 |
+
self.beta = nn.Parameter(torch.zeros(channels))
|
30 |
+
|
31 |
+
def forward(self, x):
|
32 |
+
x = x.transpose(1, -1)
|
33 |
+
x = F.layer_norm(x, (self.channels,), self.gamma, self.beta, self.eps)
|
34 |
+
return x.transpose(1, -1)
|
35 |
+
|
36 |
+
|
37 |
+
class ConvReluNorm(nn.Module):
|
38 |
+
def __init__(
|
39 |
+
self,
|
40 |
+
in_channels,
|
41 |
+
hidden_channels,
|
42 |
+
out_channels,
|
43 |
+
kernel_size,
|
44 |
+
n_layers,
|
45 |
+
p_dropout,
|
46 |
+
):
|
47 |
+
super().__init__()
|
48 |
+
self.in_channels = in_channels
|
49 |
+
self.hidden_channels = hidden_channels
|
50 |
+
self.out_channels = out_channels
|
51 |
+
self.kernel_size = kernel_size
|
52 |
+
self.n_layers = n_layers
|
53 |
+
self.p_dropout = p_dropout
|
54 |
+
assert n_layers > 1, "Number of layers should be larger than 0."
|
55 |
+
|
56 |
+
self.conv_layers = nn.ModuleList()
|
57 |
+
self.norm_layers = nn.ModuleList()
|
58 |
+
self.conv_layers.append(
|
59 |
+
nn.Conv1d(
|
60 |
+
in_channels, hidden_channels, kernel_size, padding=kernel_size // 2
|
61 |
+
)
|
62 |
+
)
|
63 |
+
self.norm_layers.append(LayerNorm(hidden_channels))
|
64 |
+
self.relu_drop = nn.Sequential(nn.ReLU(), nn.Dropout(p_dropout))
|
65 |
+
for _ in range(n_layers - 1):
|
66 |
+
self.conv_layers.append(
|
67 |
+
nn.Conv1d(
|
68 |
+
hidden_channels,
|
69 |
+
hidden_channels,
|
70 |
+
kernel_size,
|
71 |
+
padding=kernel_size // 2,
|
72 |
+
)
|
73 |
+
)
|
74 |
+
self.norm_layers.append(LayerNorm(hidden_channels))
|
75 |
+
self.proj = nn.Conv1d(hidden_channels, out_channels, 1)
|
76 |
+
self.proj.weight.data.zero_()
|
77 |
+
self.proj.bias.data.zero_()
|
78 |
+
|
79 |
+
def forward(self, x, x_mask):
|
80 |
+
x_org = x
|
81 |
+
for i in range(self.n_layers):
|
82 |
+
x = self.conv_layers[i](x * x_mask)
|
83 |
+
x = self.norm_layers[i](x)
|
84 |
+
x = self.relu_drop(x)
|
85 |
+
x = x_org + self.proj(x)
|
86 |
+
return x * x_mask
|
87 |
+
|
88 |
+
|
89 |
+
class DDSConv(nn.Module):
|
90 |
+
"""
|
91 |
+
Dialted and Depth-Separable Convolution
|
92 |
+
"""
|
93 |
+
|
94 |
+
def __init__(self, channels, kernel_size, n_layers, p_dropout=0.0):
|
95 |
+
super().__init__()
|
96 |
+
self.channels = channels
|
97 |
+
self.kernel_size = kernel_size
|
98 |
+
self.n_layers = n_layers
|
99 |
+
self.p_dropout = p_dropout
|
100 |
+
|
101 |
+
self.drop = nn.Dropout(p_dropout)
|
102 |
+
self.convs_sep = nn.ModuleList()
|
103 |
+
self.convs_1x1 = nn.ModuleList()
|
104 |
+
self.norms_1 = nn.ModuleList()
|
105 |
+
self.norms_2 = nn.ModuleList()
|
106 |
+
for i in range(n_layers):
|
107 |
+
dilation = kernel_size**i
|
108 |
+
padding = (kernel_size * dilation - dilation) // 2
|
109 |
+
self.convs_sep.append(
|
110 |
+
nn.Conv1d(
|
111 |
+
channels,
|
112 |
+
channels,
|
113 |
+
kernel_size,
|
114 |
+
groups=channels,
|
115 |
+
dilation=dilation,
|
116 |
+
padding=padding,
|
117 |
+
)
|
118 |
+
)
|
119 |
+
self.convs_1x1.append(nn.Conv1d(channels, channels, 1))
|
120 |
+
self.norms_1.append(LayerNorm(channels))
|
121 |
+
self.norms_2.append(LayerNorm(channels))
|
122 |
+
|
123 |
+
def forward(self, x, x_mask, g=None):
|
124 |
+
if g is not None:
|
125 |
+
x = x + g
|
126 |
+
for i in range(self.n_layers):
|
127 |
+
y = self.convs_sep[i](x * x_mask)
|
128 |
+
y = self.norms_1[i](y)
|
129 |
+
y = F.gelu(y)
|
130 |
+
y = self.convs_1x1[i](y)
|
131 |
+
y = self.norms_2[i](y)
|
132 |
+
y = F.gelu(y)
|
133 |
+
y = self.drop(y)
|
134 |
+
x = x + y
|
135 |
+
return x * x_mask
|
136 |
+
|
137 |
+
|
138 |
+
class WN(torch.nn.Module):
|
139 |
+
def __init__(
|
140 |
+
self,
|
141 |
+
hidden_channels,
|
142 |
+
kernel_size,
|
143 |
+
dilation_rate,
|
144 |
+
n_layers,
|
145 |
+
gin_channels=0,
|
146 |
+
p_dropout=0,
|
147 |
+
):
|
148 |
+
super(WN, self).__init__()
|
149 |
+
assert kernel_size % 2 == 1
|
150 |
+
self.hidden_channels = hidden_channels
|
151 |
+
self.kernel_size = (kernel_size,)
|
152 |
+
self.dilation_rate = dilation_rate
|
153 |
+
self.n_layers = n_layers
|
154 |
+
self.gin_channels = gin_channels
|
155 |
+
self.p_dropout = p_dropout
|
156 |
+
|
157 |
+
self.in_layers = torch.nn.ModuleList()
|
158 |
+
self.res_skip_layers = torch.nn.ModuleList()
|
159 |
+
self.drop = nn.Dropout(p_dropout)
|
160 |
+
|
161 |
+
if gin_channels != 0:
|
162 |
+
cond_layer = torch.nn.Conv1d(
|
163 |
+
gin_channels, 2 * hidden_channels * n_layers, 1
|
164 |
+
)
|
165 |
+
self.cond_layer = torch.nn.utils.parametrizations.weight_norm(cond_layer, name="weight")
|
166 |
+
|
167 |
+
for i in range(n_layers):
|
168 |
+
dilation = dilation_rate**i
|
169 |
+
padding = int((kernel_size * dilation - dilation) / 2)
|
170 |
+
in_layer = torch.nn.Conv1d(
|
171 |
+
hidden_channels,
|
172 |
+
2 * hidden_channels,
|
173 |
+
kernel_size,
|
174 |
+
dilation=dilation,
|
175 |
+
padding=padding,
|
176 |
+
)
|
177 |
+
in_layer = torch.nn.utils.parametrizations.weight_norm(in_layer, name="weight")
|
178 |
+
self.in_layers.append(in_layer)
|
179 |
+
|
180 |
+
# last one is not necessary
|
181 |
+
if i < n_layers - 1:
|
182 |
+
res_skip_channels = 2 * hidden_channels
|
183 |
+
else:
|
184 |
+
res_skip_channels = hidden_channels
|
185 |
+
|
186 |
+
res_skip_layer = torch.nn.Conv1d(hidden_channels, res_skip_channels, 1)
|
187 |
+
res_skip_layer = torch.nn.utils.parametrizations.weight_norm(res_skip_layer, name="weight")
|
188 |
+
self.res_skip_layers.append(res_skip_layer)
|
189 |
+
|
190 |
+
def forward(self, x, x_mask, g=None, **kwargs):
|
191 |
+
output = torch.zeros_like(x)
|
192 |
+
n_channels_tensor = torch.IntTensor([self.hidden_channels])
|
193 |
+
|
194 |
+
if g is not None:
|
195 |
+
g = self.cond_layer(g)
|
196 |
+
|
197 |
+
for i in range(self.n_layers):
|
198 |
+
x_in = self.in_layers[i](x)
|
199 |
+
if g is not None:
|
200 |
+
cond_offset = i * 2 * self.hidden_channels
|
201 |
+
g_l = g[:, cond_offset : cond_offset + 2 * self.hidden_channels, :]
|
202 |
+
else:
|
203 |
+
g_l = torch.zeros_like(x_in)
|
204 |
+
|
205 |
+
acts = commons.fused_add_tanh_sigmoid_multiply(x_in, g_l, n_channels_tensor)
|
206 |
+
acts = self.drop(acts)
|
207 |
+
|
208 |
+
res_skip_acts = self.res_skip_layers[i](acts)
|
209 |
+
if i < self.n_layers - 1:
|
210 |
+
res_acts = res_skip_acts[:, : self.hidden_channels, :]
|
211 |
+
x = (x + res_acts) * x_mask
|
212 |
+
output = output + res_skip_acts[:, self.hidden_channels :, :]
|
213 |
+
else:
|
214 |
+
output = output + res_skip_acts
|
215 |
+
return output * x_mask
|
216 |
+
|
217 |
+
def remove_weight_norm(self):
|
218 |
+
if self.gin_channels != 0:
|
219 |
+
torch.nn.utils.remove_weight_norm(self.cond_layer)
|
220 |
+
for l in self.in_layers:
|
221 |
+
torch.nn.utils.remove_weight_norm(l)
|
222 |
+
for l in self.res_skip_layers:
|
223 |
+
torch.nn.utils.remove_weight_norm(l)
|
224 |
+
|
225 |
+
|
226 |
+
class ResBlock1(torch.nn.Module):
|
227 |
+
def __init__(self, channels, kernel_size=3, dilation=(1, 3, 5)):
|
228 |
+
super(ResBlock1, self).__init__()
|
229 |
+
self.convs1 = nn.ModuleList(
|
230 |
+
[
|
231 |
+
weight_norm(
|
232 |
+
Conv1d(
|
233 |
+
channels,
|
234 |
+
channels,
|
235 |
+
kernel_size,
|
236 |
+
1,
|
237 |
+
dilation=dilation[0],
|
238 |
+
padding=get_padding(kernel_size, dilation[0]),
|
239 |
+
)
|
240 |
+
),
|
241 |
+
weight_norm(
|
242 |
+
Conv1d(
|
243 |
+
channels,
|
244 |
+
channels,
|
245 |
+
kernel_size,
|
246 |
+
1,
|
247 |
+
dilation=dilation[1],
|
248 |
+
padding=get_padding(kernel_size, dilation[1]),
|
249 |
+
)
|
250 |
+
),
|
251 |
+
weight_norm(
|
252 |
+
Conv1d(
|
253 |
+
channels,
|
254 |
+
channels,
|
255 |
+
kernel_size,
|
256 |
+
1,
|
257 |
+
dilation=dilation[2],
|
258 |
+
padding=get_padding(kernel_size, dilation[2]),
|
259 |
+
)
|
260 |
+
),
|
261 |
+
]
|
262 |
+
)
|
263 |
+
self.convs1.apply(init_weights)
|
264 |
+
|
265 |
+
self.convs2 = nn.ModuleList(
|
266 |
+
[
|
267 |
+
weight_norm(
|
268 |
+
Conv1d(
|
269 |
+
channels,
|
270 |
+
channels,
|
271 |
+
kernel_size,
|
272 |
+
1,
|
273 |
+
dilation=1,
|
274 |
+
padding=get_padding(kernel_size, 1),
|
275 |
+
)
|
276 |
+
),
|
277 |
+
weight_norm(
|
278 |
+
Conv1d(
|
279 |
+
channels,
|
280 |
+
channels,
|
281 |
+
kernel_size,
|
282 |
+
1,
|
283 |
+
dilation=1,
|
284 |
+
padding=get_padding(kernel_size, 1),
|
285 |
+
)
|
286 |
+
),
|
287 |
+
weight_norm(
|
288 |
+
Conv1d(
|
289 |
+
channels,
|
290 |
+
channels,
|
291 |
+
kernel_size,
|
292 |
+
1,
|
293 |
+
dilation=1,
|
294 |
+
padding=get_padding(kernel_size, 1),
|
295 |
+
)
|
296 |
+
),
|
297 |
+
]
|
298 |
+
)
|
299 |
+
self.convs2.apply(init_weights)
|
300 |
+
|
301 |
+
def forward(self, x, x_mask=None):
|
302 |
+
for c1, c2 in zip(self.convs1, self.convs2):
|
303 |
+
xt = F.leaky_relu(x, LRELU_SLOPE)
|
304 |
+
if x_mask is not None:
|
305 |
+
xt = xt * x_mask
|
306 |
+
xt = c1(xt)
|
307 |
+
xt = F.leaky_relu(xt, LRELU_SLOPE)
|
308 |
+
if x_mask is not None:
|
309 |
+
xt = xt * x_mask
|
310 |
+
xt = c2(xt)
|
311 |
+
x = xt + x
|
312 |
+
if x_mask is not None:
|
313 |
+
x = x * x_mask
|
314 |
+
return x
|
315 |
+
|
316 |
+
def remove_weight_norm(self):
|
317 |
+
for l in self.convs1:
|
318 |
+
remove_weight_norm(l)
|
319 |
+
for l in self.convs2:
|
320 |
+
remove_weight_norm(l)
|
321 |
+
|
322 |
+
|
323 |
+
class ResBlock2(torch.nn.Module):
|
324 |
+
def __init__(self, channels, kernel_size=3, dilation=(1, 3)):
|
325 |
+
super(ResBlock2, self).__init__()
|
326 |
+
self.convs = nn.ModuleList(
|
327 |
+
[
|
328 |
+
weight_norm(
|
329 |
+
Conv1d(
|
330 |
+
channels,
|
331 |
+
channels,
|
332 |
+
kernel_size,
|
333 |
+
1,
|
334 |
+
dilation=dilation[0],
|
335 |
+
padding=get_padding(kernel_size, dilation[0]),
|
336 |
+
)
|
337 |
+
),
|
338 |
+
weight_norm(
|
339 |
+
Conv1d(
|
340 |
+
channels,
|
341 |
+
channels,
|
342 |
+
kernel_size,
|
343 |
+
1,
|
344 |
+
dilation=dilation[1],
|
345 |
+
padding=get_padding(kernel_size, dilation[1]),
|
346 |
+
)
|
347 |
+
),
|
348 |
+
]
|
349 |
+
)
|
350 |
+
self.convs.apply(init_weights)
|
351 |
+
|
352 |
+
def forward(self, x, x_mask=None):
|
353 |
+
for c in self.convs:
|
354 |
+
xt = F.leaky_relu(x, LRELU_SLOPE)
|
355 |
+
if x_mask is not None:
|
356 |
+
xt = xt * x_mask
|
357 |
+
xt = c(xt)
|
358 |
+
x = xt + x
|
359 |
+
if x_mask is not None:
|
360 |
+
x = x * x_mask
|
361 |
+
return x
|
362 |
+
|
363 |
+
def remove_weight_norm(self):
|
364 |
+
for l in self.convs:
|
365 |
+
remove_weight_norm(l)
|
366 |
+
|
367 |
+
|
368 |
+
class Log(nn.Module):
|
369 |
+
def forward(self, x, x_mask, reverse=False, **kwargs):
|
370 |
+
if not reverse:
|
371 |
+
y = torch.log(torch.clamp_min(x, 1e-5)) * x_mask
|
372 |
+
logdet = torch.sum(-y, [1, 2])
|
373 |
+
return y, logdet
|
374 |
+
else:
|
375 |
+
x = torch.exp(x) * x_mask
|
376 |
+
return x
|
377 |
+
|
378 |
+
|
379 |
+
class Flip(nn.Module):
|
380 |
+
def forward(self, x, *args, reverse=False, **kwargs):
|
381 |
+
x = torch.flip(x, [1])
|
382 |
+
if not reverse:
|
383 |
+
logdet = torch.zeros(x.size(0)).to(dtype=x.dtype, device=x.device)
|
384 |
+
return x, logdet
|
385 |
+
else:
|
386 |
+
return x
|
387 |
+
|
388 |
+
|
389 |
+
class ElementwiseAffine(nn.Module):
|
390 |
+
def __init__(self, channels):
|
391 |
+
super().__init__()
|
392 |
+
self.channels = channels
|
393 |
+
self.m = nn.Parameter(torch.zeros(channels, 1))
|
394 |
+
self.logs = nn.Parameter(torch.zeros(channels, 1))
|
395 |
+
|
396 |
+
def forward(self, x, x_mask, reverse=False, **kwargs):
|
397 |
+
if not reverse:
|
398 |
+
y = self.m + torch.exp(self.logs) * x
|
399 |
+
y = y * x_mask
|
400 |
+
logdet = torch.sum(self.logs * x_mask, [1, 2])
|
401 |
+
return y, logdet
|
402 |
+
else:
|
403 |
+
x = (x - self.m) * torch.exp(-self.logs) * x_mask
|
404 |
+
return x
|
405 |
+
|
406 |
+
|
407 |
+
class ResidualCouplingLayer(nn.Module):
|
408 |
+
def __init__(
|
409 |
+
self,
|
410 |
+
channels,
|
411 |
+
hidden_channels,
|
412 |
+
kernel_size,
|
413 |
+
dilation_rate,
|
414 |
+
n_layers,
|
415 |
+
p_dropout=0,
|
416 |
+
gin_channels=0,
|
417 |
+
mean_only=False,
|
418 |
+
):
|
419 |
+
assert channels % 2 == 0, "channels should be divisible by 2"
|
420 |
+
super().__init__()
|
421 |
+
self.channels = channels
|
422 |
+
self.hidden_channels = hidden_channels
|
423 |
+
self.kernel_size = kernel_size
|
424 |
+
self.dilation_rate = dilation_rate
|
425 |
+
self.n_layers = n_layers
|
426 |
+
self.half_channels = channels // 2
|
427 |
+
self.mean_only = mean_only
|
428 |
+
|
429 |
+
self.pre = nn.Conv1d(self.half_channels, hidden_channels, 1)
|
430 |
+
self.enc = WN(
|
431 |
+
hidden_channels,
|
432 |
+
kernel_size,
|
433 |
+
dilation_rate,
|
434 |
+
n_layers,
|
435 |
+
p_dropout=p_dropout,
|
436 |
+
gin_channels=gin_channels,
|
437 |
+
)
|
438 |
+
self.post = nn.Conv1d(hidden_channels, self.half_channels * (2 - mean_only), 1)
|
439 |
+
self.post.weight.data.zero_()
|
440 |
+
self.post.bias.data.zero_()
|
441 |
+
|
442 |
+
def forward(self, x, x_mask, g=None, reverse=False):
|
443 |
+
x0, x1 = torch.split(x, [self.half_channels] * 2, 1)
|
444 |
+
h = self.pre(x0) * x_mask
|
445 |
+
h = self.enc(h, x_mask, g=g)
|
446 |
+
stats = self.post(h) * x_mask
|
447 |
+
if not self.mean_only:
|
448 |
+
m, logs = torch.split(stats, [self.half_channels] * 2, 1)
|
449 |
+
else:
|
450 |
+
m = stats
|
451 |
+
logs = torch.zeros_like(m)
|
452 |
+
|
453 |
+
if not reverse:
|
454 |
+
x1 = m + x1 * torch.exp(logs) * x_mask
|
455 |
+
x = torch.cat([x0, x1], 1)
|
456 |
+
logdet = torch.sum(logs, [1, 2])
|
457 |
+
return x, logdet
|
458 |
+
else:
|
459 |
+
x1 = (x1 - m) * torch.exp(-logs) * x_mask
|
460 |
+
x = torch.cat([x0, x1], 1)
|
461 |
+
return x
|
462 |
+
|
463 |
+
def remove_weight_norm(self):
|
464 |
+
self.enc.remove_weight_norm()
|
465 |
+
|
466 |
+
|
467 |
+
class ConvFlow(nn.Module):
|
468 |
+
def __init__(
|
469 |
+
self,
|
470 |
+
in_channels,
|
471 |
+
filter_channels,
|
472 |
+
kernel_size,
|
473 |
+
n_layers,
|
474 |
+
num_bins=10,
|
475 |
+
tail_bound=5.0,
|
476 |
+
):
|
477 |
+
super().__init__()
|
478 |
+
self.in_channels = in_channels
|
479 |
+
self.filter_channels = filter_channels
|
480 |
+
self.kernel_size = kernel_size
|
481 |
+
self.n_layers = n_layers
|
482 |
+
self.num_bins = num_bins
|
483 |
+
self.tail_bound = tail_bound
|
484 |
+
self.half_channels = in_channels // 2
|
485 |
+
|
486 |
+
self.pre = nn.Conv1d(self.half_channels, filter_channels, 1)
|
487 |
+
self.convs = DDSConv(filter_channels, kernel_size, n_layers, p_dropout=0.0)
|
488 |
+
self.proj = nn.Conv1d(
|
489 |
+
filter_channels, self.half_channels * (num_bins * 3 - 1), 1
|
490 |
+
)
|
491 |
+
self.proj.weight.data.zero_()
|
492 |
+
self.proj.bias.data.zero_()
|
493 |
+
|
494 |
+
def forward(self, x, x_mask, g=None, reverse=False):
|
495 |
+
x0, x1 = torch.split(x, [self.half_channels] * 2, 1)
|
496 |
+
h = self.pre(x0)
|
497 |
+
h = self.convs(h, x_mask, g=g)
|
498 |
+
h = self.proj(h) * x_mask
|
499 |
+
|
500 |
+
b, c, t = x0.shape
|
501 |
+
h = h.reshape(b, c, -1, t).permute(0, 1, 3, 2) # [b, cx?, t] -> [b, c, t, ?]
|
502 |
+
|
503 |
+
unnormalized_widths = h[..., : self.num_bins] / math.sqrt(self.filter_channels)
|
504 |
+
unnormalized_heights = h[..., self.num_bins : 2 * self.num_bins] / math.sqrt(
|
505 |
+
self.filter_channels
|
506 |
+
)
|
507 |
+
unnormalized_derivatives = h[..., 2 * self.num_bins :]
|
508 |
+
|
509 |
+
x1, logabsdet = piecewise_rational_quadratic_transform(
|
510 |
+
x1,
|
511 |
+
unnormalized_widths,
|
512 |
+
unnormalized_heights,
|
513 |
+
unnormalized_derivatives,
|
514 |
+
inverse=reverse,
|
515 |
+
tails="linear",
|
516 |
+
tail_bound=self.tail_bound,
|
517 |
+
)
|
518 |
+
|
519 |
+
x = torch.cat([x0, x1], 1) * x_mask
|
520 |
+
logdet = torch.sum(logabsdet * x_mask, [1, 2])
|
521 |
+
if not reverse:
|
522 |
+
return x, logdet
|
523 |
+
else:
|
524 |
+
return x
|
weights/hololive-en/Cecilia/Cecilia_KitLemonfoot.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:49cf63e1d99b137f1c5734545c590c5f1175927368e473c132baa5d65b351e76
|
3 |
+
size 55225160
|
weights/hololive-en/Cecilia/added_IVF1477_Flat_nprobe_1_CeciliaImmergreen_Singing_KitLemonfoot_v2_mbkm.index
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:292ea4eb3224095fe0560dfab73999094c117353bfd0abc84258bccbf69a02cd
|
3 |
+
size 31588619
|
weights/hololive-en/Cecilia/cover.png
ADDED
weights/hololive-en/Elizabeth/Elizabeth_Dacoolkid.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bd31bb108cbf968b6a98098c3037e733dc36b5ef532055d89b8d3ce3b427b351
|
3 |
+
size 55232074
|
weights/hololive-en/Elizabeth/added_IVF1418_Flat_nprobe_1_Elizabeth_Rose_Bloodflame_v2.index
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c310911110fa2e875c3ea7e065a4173b276f0694a52e4f508fd6f1d27380637f
|
3 |
+
size 174793219
|
weights/hololive-en/Elizabeth/added_IVF1418_Flat_nprobe_1_Elizabeth_Rose_Bloodflame_v2_mbkm.index
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:27826f42edf3b7ef4f0b4345fb4bbf59a4c414bed4e3703e81ec53353cd4af96
|
3 |
+
size 31588619
|
weights/hololive-en/Elizabeth/cover.png
ADDED
weights/hololive-en/Gigi/Gigi_HinaBl.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c6043992dc8e12ef42ff44955f44cc45bc7c328e9c19012e5836e76d095591e8
|
3 |
+
size 56255925
|
weights/hololive-en/Gigi/added_IVF1648_Flat_nprobe_1_gigi-murin_v2_mbkm.index
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:74e8b3ecf60ac95168e5a1c3efc579f62d4503e6ca805f4c64d408408eb8a25e
|
3 |
+
size 31588619
|
weights/hololive-en/Gigi/cover.png
ADDED
weights/hololive-en/Raora/Raora_00a.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f3908f2f5946b33a4c980a2fca210613209e72446afc9287a24d4818e49d5730
|
3 |
+
size 55222703
|
weights/hololive-en/Raora/added_IVF2050_Flat_nprobe_1_raora_v2_mbkm.index
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ee4410f5264cac705c4a9722cb568c8d09de1ad1990795e191432a9d05c83cad
|
3 |
+
size 31588619
|
weights/hololive-en/Raora/cover.png
ADDED
weights/hololive-en/model_info.json
CHANGED
@@ -1,130 +1,162 @@
|
|
1 |
-
{
|
2 |
-
"Kiara": {
|
3 |
-
"enable": true,
|
4 |
-
"model_path": "Kiara_Dacoolkid.pth",
|
5 |
-
"title": "Takanashi Kiara",
|
6 |
-
"cover": "cover.png",
|
7 |
-
"feature_retrieval_library": "added_IVF4961_Flat_nprobe_1_mbkm.index",
|
8 |
-
"author": "dacoolkid44 & Hijack"
|
9 |
-
},
|
10 |
-
"Calliope": {
|
11 |
-
"enable": true,
|
12 |
-
"model_path": "Calli_RigidSpinner.pth",
|
13 |
-
"title": "Mori Calliope",
|
14 |
-
"cover": "cover.png",
|
15 |
-
"feature_retrieval_library": "added_IVF4173_Flat_nprobe_1_CalliopeMori_v2_mbkm.index",
|
16 |
-
"author": "RigidSpinner"
|
17 |
-
},
|
18 |
-
"Ina": {
|
19 |
-
"enable": true,
|
20 |
-
"model_path": "Ina_Dacoolkid.pth",
|
21 |
-
"title": "Ninomae Ina'nis",
|
22 |
-
"cover": "cover.png",
|
23 |
-
"feature_retrieval_library": "added_IVF1754_Flat_nprobe_1_Inatalk2_v2_mbkm.index",
|
24 |
-
"author": "dacoolkid44 & Hijack"
|
25 |
-
},
|
26 |
-
"Gura": {
|
27 |
-
"enable": true,
|
28 |
-
"model_path": "Gura_Mustar.pth",
|
29 |
-
"title": "Gawr Gura",
|
30 |
-
"cover": "cover.png",
|
31 |
-
"feature_retrieval_library": "added_IVF256_Flat_nprobe_1_Gura_v2.index",
|
32 |
-
"author": "MUSTAR"
|
33 |
-
},
|
34 |
-
"Amelia": {
|
35 |
-
"enable": true,
|
36 |
-
"model_path": "Amelia_Dacoolkid.pth",
|
37 |
-
"title": "Amelia Watson",
|
38 |
-
"cover": "cover.png",
|
39 |
-
"feature_retrieval_library": "added_IVF4964_Flat_nprobe_1_Amelia_v2_mbkm.index",
|
40 |
-
"author": "dacoolkid44 & Hijack"
|
41 |
-
},
|
42 |
-
"IRyS": {
|
43 |
-
"enable": true,
|
44 |
-
"model_path": "Irys_Mimizukari.pth",
|
45 |
-
"title": "IRyS",
|
46 |
-
"cover": "cover.png",
|
47 |
-
"feature_retrieval_library": "added_IVF3197_Flat_nprobe_1_Irys_v2_mbkm.index",
|
48 |
-
"author": "Mimizukari"
|
49 |
-
},
|
50 |
-
"Sana": {
|
51 |
-
"enable": true,
|
52 |
-
"model_path": "Sana_KitLemonfoot.pth",
|
53 |
-
"title": "Tsukumo Sana",
|
54 |
-
"cover": "cover.png",
|
55 |
-
"feature_retrieval_library": "added_IVF3032_Flat_nprobe_1_v2_mbkm.index",
|
56 |
-
"author": "Kit Lemonfoot / NSHFB"
|
57 |
-
},
|
58 |
-
"Fauna": {
|
59 |
-
"enable": true,
|
60 |
-
"model_path": "Fauna_TataSoto.pth",
|
61 |
-
"title": "Ceres Fauna",
|
62 |
-
"cover": "cover.png",
|
63 |
-
"feature_retrieval_library": "fauna_mbkm.index",
|
64 |
-
"author": "TataSoto"
|
65 |
-
},
|
66 |
-
"Kronii": {
|
67 |
-
"enable": true,
|
68 |
-
"model_path": "Kronii_Dacoolkid.pth",
|
69 |
-
"title": "Ouro Kronii",
|
70 |
-
"cover": "cover.png",
|
71 |
-
"feature_retrieval_library": "added_IVF1728_Flat_nprobe_1_kronii_v2_mbkm.index",
|
72 |
-
"author": "dacoolkid44 & Hijack"
|
73 |
-
},
|
74 |
-
"Mumei": {
|
75 |
-
"enable": true,
|
76 |
-
"model_path": "Mumei_Dacoolkid.pth",
|
77 |
-
"title": "Nanashi Mumei",
|
78 |
-
"cover": "cover.png",
|
79 |
-
"feature_retrieval_library": "added_IVF1020_Flat_nprobe_1_MUMEI_v2_mbkm.index",
|
80 |
-
"author": "dacoolkid44 & Hijack"
|
81 |
-
},
|
82 |
-
"Baelz": {
|
83 |
-
"enable": true,
|
84 |
-
"model_path": "Baelz_Dacoolkid.pth",
|
85 |
-
"title": "Hakos Baelz",
|
86 |
-
"cover": "cover.png",
|
87 |
-
"feature_retrieval_library": "added_IVF2170_Flat_nprobe_1_baetalk_v2_mbkm.index",
|
88 |
-
"author": "dacoolkid44 & Hijack"
|
89 |
-
},
|
90 |
-
"Shiori": {
|
91 |
-
"enable": true,
|
92 |
-
"model_path": "Shiori_MahdeenSky.pth",
|
93 |
-
"title": "Shiori Novella",
|
94 |
-
"cover": "cover.png",
|
95 |
-
"feature_retrieval_library": "added_IVF647_Flat_nprobe_1_ShioriNovella_v2.index",
|
96 |
-
"author": "MahdeenSky"
|
97 |
-
},
|
98 |
-
"Bijou": {
|
99 |
-
"enable": true,
|
100 |
-
"model_path": "Bijou_RigidSpinner.pth",
|
101 |
-
"title": "Koseki Bijou",
|
102 |
-
"cover": "cover.png",
|
103 |
-
"feature_retrieval_library": "added_IVF4915_Flat_nprobe_1_KosekiBijou_v2_mbkm.index",
|
104 |
-
"author": "RigidSpinner"
|
105 |
-
},
|
106 |
-
"Nerissa": {
|
107 |
-
"enable": true,
|
108 |
-
"model_path": "Nerissa_RigidSpinner.pth",
|
109 |
-
"title": "Nerissa Ravencroft",
|
110 |
-
"cover": "cover.png",
|
111 |
-
"feature_retrieval_library": "added_IVF4968_Flat_nprobe_1_NerissaRavencroft_v2_mbkm.index",
|
112 |
-
"author": "RigidSpinner"
|
113 |
-
},
|
114 |
-
"Fuwawa": {
|
115 |
-
"enable": true,
|
116 |
-
"model_path": "Fuwawa_Listra92.pth",
|
117 |
-
"title": "Fuwawa Abyssgard",
|
118 |
-
"cover": "cover.png",
|
119 |
-
"feature_retrieval_library": "added_IVF2671_Flat_nprobe_1_fuwawa_v2_mbkm.index",
|
120 |
-
"author": "Listra92"
|
121 |
-
},
|
122 |
-
"Mococo": {
|
123 |
-
"enable": true,
|
124 |
-
"model_path": "Mococo_LeoFrixi.pth",
|
125 |
-
"title": "Mococo Abyssgard",
|
126 |
-
"cover": "cover.png",
|
127 |
-
"feature_retrieval_library": "added_IVF950_Flat_nprobe_1_Mococo_AbyssgardV2_v2_mbkm.index",
|
128 |
-
"author": "Leo_Frixi"
|
129 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
}
|
|
|
1 |
+
{
|
2 |
+
"Kiara": {
|
3 |
+
"enable": true,
|
4 |
+
"model_path": "Kiara_Dacoolkid.pth",
|
5 |
+
"title": "Takanashi Kiara",
|
6 |
+
"cover": "cover.png",
|
7 |
+
"feature_retrieval_library": "added_IVF4961_Flat_nprobe_1_mbkm.index",
|
8 |
+
"author": "dacoolkid44 & Hijack"
|
9 |
+
},
|
10 |
+
"Calliope": {
|
11 |
+
"enable": true,
|
12 |
+
"model_path": "Calli_RigidSpinner.pth",
|
13 |
+
"title": "Mori Calliope",
|
14 |
+
"cover": "cover.png",
|
15 |
+
"feature_retrieval_library": "added_IVF4173_Flat_nprobe_1_CalliopeMori_v2_mbkm.index",
|
16 |
+
"author": "RigidSpinner"
|
17 |
+
},
|
18 |
+
"Ina": {
|
19 |
+
"enable": true,
|
20 |
+
"model_path": "Ina_Dacoolkid.pth",
|
21 |
+
"title": "Ninomae Ina'nis",
|
22 |
+
"cover": "cover.png",
|
23 |
+
"feature_retrieval_library": "added_IVF1754_Flat_nprobe_1_Inatalk2_v2_mbkm.index",
|
24 |
+
"author": "dacoolkid44 & Hijack"
|
25 |
+
},
|
26 |
+
"Gura": {
|
27 |
+
"enable": true,
|
28 |
+
"model_path": "Gura_Mustar.pth",
|
29 |
+
"title": "Gawr Gura",
|
30 |
+
"cover": "cover.png",
|
31 |
+
"feature_retrieval_library": "added_IVF256_Flat_nprobe_1_Gura_v2.index",
|
32 |
+
"author": "MUSTAR"
|
33 |
+
},
|
34 |
+
"Amelia": {
|
35 |
+
"enable": true,
|
36 |
+
"model_path": "Amelia_Dacoolkid.pth",
|
37 |
+
"title": "Amelia Watson",
|
38 |
+
"cover": "cover.png",
|
39 |
+
"feature_retrieval_library": "added_IVF4964_Flat_nprobe_1_Amelia_v2_mbkm.index",
|
40 |
+
"author": "dacoolkid44 & Hijack"
|
41 |
+
},
|
42 |
+
"IRyS": {
|
43 |
+
"enable": true,
|
44 |
+
"model_path": "Irys_Mimizukari.pth",
|
45 |
+
"title": "IRyS",
|
46 |
+
"cover": "cover.png",
|
47 |
+
"feature_retrieval_library": "added_IVF3197_Flat_nprobe_1_Irys_v2_mbkm.index",
|
48 |
+
"author": "Mimizukari"
|
49 |
+
},
|
50 |
+
"Sana": {
|
51 |
+
"enable": true,
|
52 |
+
"model_path": "Sana_KitLemonfoot.pth",
|
53 |
+
"title": "Tsukumo Sana",
|
54 |
+
"cover": "cover.png",
|
55 |
+
"feature_retrieval_library": "added_IVF3032_Flat_nprobe_1_v2_mbkm.index",
|
56 |
+
"author": "Kit Lemonfoot / NSHFB"
|
57 |
+
},
|
58 |
+
"Fauna": {
|
59 |
+
"enable": true,
|
60 |
+
"model_path": "Fauna_TataSoto.pth",
|
61 |
+
"title": "Ceres Fauna",
|
62 |
+
"cover": "cover.png",
|
63 |
+
"feature_retrieval_library": "fauna_mbkm.index",
|
64 |
+
"author": "TataSoto"
|
65 |
+
},
|
66 |
+
"Kronii": {
|
67 |
+
"enable": true,
|
68 |
+
"model_path": "Kronii_Dacoolkid.pth",
|
69 |
+
"title": "Ouro Kronii",
|
70 |
+
"cover": "cover.png",
|
71 |
+
"feature_retrieval_library": "added_IVF1728_Flat_nprobe_1_kronii_v2_mbkm.index",
|
72 |
+
"author": "dacoolkid44 & Hijack"
|
73 |
+
},
|
74 |
+
"Mumei": {
|
75 |
+
"enable": true,
|
76 |
+
"model_path": "Mumei_Dacoolkid.pth",
|
77 |
+
"title": "Nanashi Mumei",
|
78 |
+
"cover": "cover.png",
|
79 |
+
"feature_retrieval_library": "added_IVF1020_Flat_nprobe_1_MUMEI_v2_mbkm.index",
|
80 |
+
"author": "dacoolkid44 & Hijack"
|
81 |
+
},
|
82 |
+
"Baelz": {
|
83 |
+
"enable": true,
|
84 |
+
"model_path": "Baelz_Dacoolkid.pth",
|
85 |
+
"title": "Hakos Baelz",
|
86 |
+
"cover": "cover.png",
|
87 |
+
"feature_retrieval_library": "added_IVF2170_Flat_nprobe_1_baetalk_v2_mbkm.index",
|
88 |
+
"author": "dacoolkid44 & Hijack"
|
89 |
+
},
|
90 |
+
"Shiori": {
|
91 |
+
"enable": true,
|
92 |
+
"model_path": "Shiori_MahdeenSky.pth",
|
93 |
+
"title": "Shiori Novella",
|
94 |
+
"cover": "cover.png",
|
95 |
+
"feature_retrieval_library": "added_IVF647_Flat_nprobe_1_ShioriNovella_v2.index",
|
96 |
+
"author": "MahdeenSky"
|
97 |
+
},
|
98 |
+
"Bijou": {
|
99 |
+
"enable": true,
|
100 |
+
"model_path": "Bijou_RigidSpinner.pth",
|
101 |
+
"title": "Koseki Bijou",
|
102 |
+
"cover": "cover.png",
|
103 |
+
"feature_retrieval_library": "added_IVF4915_Flat_nprobe_1_KosekiBijou_v2_mbkm.index",
|
104 |
+
"author": "RigidSpinner"
|
105 |
+
},
|
106 |
+
"Nerissa": {
|
107 |
+
"enable": true,
|
108 |
+
"model_path": "Nerissa_RigidSpinner.pth",
|
109 |
+
"title": "Nerissa Ravencroft",
|
110 |
+
"cover": "cover.png",
|
111 |
+
"feature_retrieval_library": "added_IVF4968_Flat_nprobe_1_NerissaRavencroft_v2_mbkm.index",
|
112 |
+
"author": "RigidSpinner"
|
113 |
+
},
|
114 |
+
"Fuwawa": {
|
115 |
+
"enable": true,
|
116 |
+
"model_path": "Fuwawa_Listra92.pth",
|
117 |
+
"title": "Fuwawa Abyssgard",
|
118 |
+
"cover": "cover.png",
|
119 |
+
"feature_retrieval_library": "added_IVF2671_Flat_nprobe_1_fuwawa_v2_mbkm.index",
|
120 |
+
"author": "Listra92"
|
121 |
+
},
|
122 |
+
"Mococo": {
|
123 |
+
"enable": true,
|
124 |
+
"model_path": "Mococo_LeoFrixi.pth",
|
125 |
+
"title": "Mococo Abyssgard",
|
126 |
+
"cover": "cover.png",
|
127 |
+
"feature_retrieval_library": "added_IVF950_Flat_nprobe_1_Mococo_AbyssgardV2_v2_mbkm.index",
|
128 |
+
"author": "Leo_Frixi"
|
129 |
+
},
|
130 |
+
"Elizabeth": {
|
131 |
+
"enable": true,
|
132 |
+
"model_path": "Elizabeth_Dacoolkid.pth",
|
133 |
+
"title": "Elizabeth Rose Bloodflame",
|
134 |
+
"cover": "cover.png",
|
135 |
+
"feature_retrieval_library": "added_IVF1418_Flat_nprobe_1_Elizabeth_Rose_Bloodflame_v2_mbkm.index",
|
136 |
+
"author": "dacoolkid44"
|
137 |
+
},
|
138 |
+
"Gigi": {
|
139 |
+
"enable": true,
|
140 |
+
"model_path": "Gigi_HinaBl.pth",
|
141 |
+
"title": "Gigi Murin",
|
142 |
+
"cover": "cover.png",
|
143 |
+
"feature_retrieval_library": "added_IVF1648_Flat_nprobe_1_gigi-murin_v2_mbkm.index",
|
144 |
+
"author": "HinaBl"
|
145 |
+
},
|
146 |
+
"Cecilia": {
|
147 |
+
"enable": true,
|
148 |
+
"model_path": "Cecilia_KitLemonfoot.pth",
|
149 |
+
"title": "Cecilia Immergreen",
|
150 |
+
"cover": "cover.png",
|
151 |
+
"feature_retrieval_library": "added_IVF1477_Flat_nprobe_1_CeciliaImmergreen_Singing_KitLemonfoot_v2_mbkm.index",
|
152 |
+
"author": "Kit Lemonfoot / NSHFB"
|
153 |
+
},
|
154 |
+
"Raora": {
|
155 |
+
"enable": true,
|
156 |
+
"model_path": "Raora_00a.pth",
|
157 |
+
"title": "Raora Panthera",
|
158 |
+
"cover": "cover.png",
|
159 |
+
"feature_retrieval_library": "added_IVF2050_Flat_nprobe_1_raora_v2_mbkm.index",
|
160 |
+
"author": "00a"
|
161 |
+
}
|
162 |
}
|
weights/phaseconnect/Pico/Pico_Sxndypz.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7c7d9128cffb2663c4f7cf4df188eef969a66eab87a9bafedd6c9bd424976876
|
3 |
+
size 56264557
|
weights/phaseconnect/Pico/added_IVF1132_Flat_nprobe_1_grampico_v2_mbkm.index
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6750b29caf83d81bfb85eeb1c3d720002b7acad4fdfdf7a18afeeaac899cc2ff
|
3 |
+
size 31588619
|
weights/phaseconnect/Pico/cover.png
ADDED
weights/phaseconnect/model_info.json
CHANGED
@@ -151,6 +151,14 @@
|
|
151 |
"feature_retrieval_library": "added_IVF725_Flat_nprobe_1_eimi_v2.index",
|
152 |
"author": "Sxndypz"
|
153 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
"Memory": {
|
155 |
"enable": true,
|
156 |
"model_path": "Memory_Sxndypz.pth",
|
@@ -159,12 +167,12 @@
|
|
159 |
"feature_retrieval_library": "added_IVF930_Flat_nprobe_1_memory_v2_mbkm.index",
|
160 |
"author": "Sxndypz"
|
161 |
},
|
162 |
-
"
|
163 |
"enable": true,
|
164 |
-
"model_path": "
|
165 |
-
"title": "
|
166 |
"cover": "cover.png",
|
167 |
-
"feature_retrieval_library": "
|
168 |
"author": "Sxndypz"
|
169 |
}
|
170 |
}
|
|
|
151 |
"feature_retrieval_library": "added_IVF725_Flat_nprobe_1_eimi_v2.index",
|
152 |
"author": "Sxndypz"
|
153 |
},
|
154 |
+
"Clara": {
|
155 |
+
"enable": true,
|
156 |
+
"model_path": "Clara_Sxndypz.pth",
|
157 |
+
"title": "Kaminari Clara",
|
158 |
+
"cover": "cover.png",
|
159 |
+
"feature_retrieval_library": "added_IVF1080_Flat_nprobe_1_clara_v2_mbkm.index",
|
160 |
+
"author": "Sxndypz"
|
161 |
+
},
|
162 |
"Memory": {
|
163 |
"enable": true,
|
164 |
"model_path": "Memory_Sxndypz.pth",
|
|
|
167 |
"feature_retrieval_library": "added_IVF930_Flat_nprobe_1_memory_v2_mbkm.index",
|
168 |
"author": "Sxndypz"
|
169 |
},
|
170 |
+
"Pico": {
|
171 |
"enable": true,
|
172 |
+
"model_path": "Pico_Sxndypz.pth",
|
173 |
+
"title": "Gram Pico",
|
174 |
"cover": "cover.png",
|
175 |
+
"feature_retrieval_library": "added_IVF1132_Flat_nprobe_1_grampico_v2_mbkm.index",
|
176 |
"author": "Sxndypz"
|
177 |
}
|
178 |
}
|