Skip to content

Commit dcea06e

Browse files
committed
addressing comments
1 parent c2cf97b commit dcea06e

20 files changed

Lines changed: 461 additions & 8458 deletions

recipes/WSJ-2mix/experiment.py

Lines changed: 14 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
#!/usr/bin/python
2+
3+
"""
4+
Recipe to train CONV-TASNET model on the WSJ0 dataset
5+
6+
Author:
7+
* Cem Subakan 2020
8+
"""
9+
210
import os
311
import speechbrain as sb
412
from speechbrain.utils.train_logger import summarize_average
513
import torch
614
from speechbrain.utils.checkpoints import ckpt_recency
715
from speechbrain.nnet.losses import get_si_snr_with_pitwrapper
16+
from prepare_data import create_wsj_csv, get_wsj_files
817

918
import torch.nn.functional as F
10-
import csv
1119

1220
experiment_dir = os.path.dirname(os.path.realpath(__file__))
1321
params_file = os.path.join(experiment_dir, "params.yaml")
@@ -16,64 +24,19 @@
1624
params = sb.yaml.load_extended_yaml(fin)
1725

1826
# this points to the folder which holds the wsj0-mix dataset folder
19-
datapath = params.datapath
27+
wsj0root = params.wsj0path
28+
data_save_dir = params.datapath
2029

30+
if os.path.exists(data_save_dir):
31+
get_wsj_files(wsj0root, data_save_dir)
2132

2233
# load or create the csv files for the data
2334
if not (
2435
os.path.exists("wsj_tr.csv")
2536
and os.path.exists("wsj_cv.csv")
2637
and os.path.exists("wsj_tt.csv")
2738
):
28-
for set_type in ["tr", "cv", "tt"]:
29-
mix_path = (
30-
datapath + "wsj0-mix/2speakers/wav8k/min/" + set_type + "/mix/"
31-
)
32-
s1_path = datapath + "wsj0-mix/2speakers/wav8k/min/" + set_type + "/s1/"
33-
s2_path = datapath + "wsj0-mix/2speakers/wav8k/min/" + set_type + "/s2/"
34-
35-
files = os.listdir(mix_path)
36-
37-
mix_fl_paths = [mix_path + fl for fl in files]
38-
s1_fl_paths = [s1_path + fl for fl in files]
39-
s2_fl_paths = [s2_path + fl for fl in files]
40-
41-
csv_columns = [
42-
"ID",
43-
"duration",
44-
"mix_wav",
45-
"mix_wav_format",
46-
"mix_wav_opts",
47-
"s1_wav",
48-
"s1_wav_format",
49-
"s1_wav_opts",
50-
"s2_wav",
51-
"s2_wav_format",
52-
"s2_wav_opts",
53-
]
54-
55-
with open("wsj_" + set_type + ".csv", "w") as csvfile:
56-
writer = csv.DictWriter(csvfile, fieldnames=csv_columns)
57-
writer.writeheader()
58-
for i, (mix_path, s1_path, s2_path) in enumerate(
59-
zip(mix_fl_paths, s1_fl_paths, s2_fl_paths)
60-
):
61-
62-
row = {
63-
"ID": i,
64-
"duration": 1.0,
65-
"mix_wav": mix_path,
66-
"mix_wav_format": "wav",
67-
"mix_wav_opts": None,
68-
"s1_wav": s1_path,
69-
"s1_wav_format": "wav",
70-
"s1_wav_opts": None,
71-
"s2_wav": s2_path,
72-
"s2_wav_format": "wav",
73-
"s2_wav_opts": None,
74-
}
75-
writer.writerow(row)
76-
39+
create_wsj_csv(data_save_dir)
7740

7841
tr_csv = os.path.realpath(os.path.join(experiment_dir, "wsj_tr.csv"))
7942
cv_csv = os.path.realpath(os.path.join(experiment_dir, "wsj_cv.csv"))
@@ -85,13 +48,11 @@
8548
)
8649
# print(params) # if needed this line can be uncommented for logging
8750

88-
8951
if params.use_tensorboard:
9052
from speechbrain.utils.train_logger import TensorboardLogger
9153

9254
train_logger = TensorboardLogger(params.tensorboard_logs)
9355

94-
9556
device = "cuda" if torch.cuda.is_available() else "cpu"
9657

9758

@@ -200,7 +161,6 @@ def on_epoch_end(self, epoch, train_stats, valid_stats):
200161

201162
params.checkpointer.recover_if_possible(lambda c: -c.meta["av_loss"])
202163

203-
# with torch.autograd.detect_anomaly():
204164
ctn.fit(
205165
range(params.N_epochs),
206166
train_set=train_loader,

recipes/WSJ-2mix/get_wsj_csv.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)