-
Notifications
You must be signed in to change notification settings - Fork 2
/
cli_setup.py
58 lines (49 loc) · 1.31 KB
/
cli_setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import torch
import soundfile as sf
import numpy as np
import os
from asteroid.models import ConvTasNet, save_publishable
from asteroid.data.wham_dataset import wham_noise_license, wsj0_license
def setup_register_sr():
model = ConvTasNet(
n_src=2,
n_repeats=2,
n_blocks=3,
bn_chan=16,
hid_chan=4,
skip_chan=8,
n_filters=32,
)
to_save = model.serialize()
to_save["model_args"].pop("sample_rate")
torch.save(to_save, "tmp.th")
def setup_infer():
sf.write("tmp.wav", np.random.randn(16000), 8000)
sf.write("tmp2.wav", np.random.randn(16000), 8000)
def setup_upload():
train_set_infos = dict(
dataset="WHAM", task="sep_noisy", licenses=[wsj0_license, wham_noise_license]
)
final_results = {"si_sdr": 8.67, "si_sdr_imp": 13.16}
model = ConvTasNet(
n_src=2,
n_repeats=2,
n_blocks=3,
bn_chan=16,
hid_chan=4,
skip_chan=8,
n_filters=32,
)
model_dict = model.serialize()
model_dict.update(train_set_infos)
os.makedirs("publish_dir", exist_ok=True)
save_publishable(
"publish_dir",
model_dict,
metrics=final_results,
train_conf=dict(),
)
if __name__ == "__main__":
setup_register_sr()
setup_infer()
setup_upload()