Skip to content

Commit

Permalink
fix other recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
mravanelli committed Jun 17, 2022
1 parent 507b69b commit a812c9b
Show file tree
Hide file tree
Showing 18 changed files with 114 additions and 48 deletions.
9 changes: 7 additions & 2 deletions recipes/IEMOCAP/emotion_recognition/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,14 @@ def label_pipeline(emo):
# Define datasets. We also connect the dataset with the data processing
# functions defined above.
datasets = {}
for dataset in ["train", "valid", "test"]:
data_info = {
"train": hparams["train_annotation"],
"valid": hparams["valid_annotation"],
"test": hparams["test_annotation"],
}
for dataset in data_info:
datasets[dataset] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams[f"{dataset}_annotation"],
json_path=data_info[dataset],
replacements={"data_root": hparams["data_folder"]},
dynamic_items=[audio_pipeline, label_pipeline],
output_keys=["id", "sig", "emo_encoded"],
Expand Down
9 changes: 7 additions & 2 deletions recipes/IEMOCAP/emotion_recognition/train_with_wav2vec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,14 @@ def label_pipeline(emo):
# Define datasets. We also connect the dataset with the data processing
# functions defined above.
datasets = {}
for dataset in ["train", "valid", "test"]:
data_info = {
"train": hparams["train_annotation"],
"valid": hparams["valid_annotation"],
"test": hparams["test_annotation"],
}
for dataset in data_info:
datasets[dataset] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams[f"{dataset}_annotation"],
json_path=data_info[dataset],
replacements={"data_root": hparams["data_folder"]},
dynamic_items=[audio_pipeline, label_pipeline],
output_keys=["id", "sig", "emo_encoded"],
Expand Down
11 changes: 8 additions & 3 deletions recipes/UrbanSound8k/SoundClassification/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def on_stage_start(self, stage, epoch=None):
"""
# Set up statistics trackers for this stage
self.loss_metric = sb.utils.metric_stats.MetricStats(
metric=sb.nnet.losses.nll_loss # TODO put in yaml hparams?
metric=sb.nnet.losses.nll_loss
)

# Compute Accuracy using MetricStats
Expand Down Expand Up @@ -347,9 +347,14 @@ def label_pipeline(class_string):
# Define datasets. We also connect the dataset with the data processing
# functions defined above.
datasets = {}
for dataset in ["train", "valid", "test"]:
data_info = {
"train": hparams["train_annotation"],
"valid": hparams["valid_annotation"],
"test": hparams["test_annotation"],
}
for dataset in data_info:
datasets[dataset] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams[f"{dataset}_annotation"],
json_path=data_info[dataset],
replacements={"data_root": hparams["data_folder"]},
dynamic_items=[audio_pipeline, label_pipeline],
output_keys=["id", "sig", "class_string_encoded"],
Expand Down
9 changes: 7 additions & 2 deletions recipes/Voicebank/ASR/CTC/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,14 @@ def text_pipeline(phones):

# 3. Create datasets
data = {}
for dataset in ["train", "valid", "test"]:
data_info = {
"train": hparams["train_annotation"],
"valid": hparams["valid_annotation"],
"test": hparams["test_annotation"],
}
for dataset in data_info:
data[dataset] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams[f"{dataset}_annotation"],
json_path=data_info[dataset],
replacements={"data_root": hparams["data_folder"]},
dynamic_items=[audio_pipeline, text_pipeline],
output_keys=["id", "sig", "phn_encoded"],
Expand Down
9 changes: 7 additions & 2 deletions recipes/Voicebank/MTL/ASR_enhance/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,14 @@ def target_pipeline(target):

# Create datasets
data = {}
for dataset in ["train", "valid", "test"]:
data_info = {
"train": hparams["train_annotation"],
"valid": hparams["valid_annotation"],
"test": hparams["test_annotation"],
}
for dataset in data_info:
data[dataset] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams[f"{dataset}_annotation"],
json_path=data_info[dataset],
replacements={"data_root": hparams["data_folder"]},
dynamic_items=[audio_pipeline, target_pipeline],
output_keys=["id", "noisy_sig", "clean_sig"] + token_keys,
Expand Down
9 changes: 7 additions & 2 deletions recipes/Voicebank/MTL/CoopNet/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,14 @@ def target_pipeline(target):

# 4. Create datasets
data = {}
for dataset in ["train", "valid", "test"]:
data_info = {
"train": hparams["train_annotation"],
"valid": hparams["valid_annotation"],
"test": hparams["test_annotation"],
}
for dataset in data_info:
data[dataset] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams[f"{dataset}_annotation"],
json_path=data_info[dataset],
replacements={"data_root": hparams["data_folder"]},
dynamic_items=[noisy_pipeline, clean_pipeline, target_pipeline],
output_keys=["id", "noisy_sig", "clean_sig", "phn_encoded"],
Expand Down
25 changes: 14 additions & 11 deletions recipes/Voicebank/dereverb/MetricGAN-U/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,21 +678,24 @@ def dataio_prep(hparams):

# Define datasets
datasets = {}

dataset = "train"
datasets[dataset] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams[f"{dataset}_annotation"],
datasets["train"] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams["train_annotation"],
replacements={"data_root": hparams["data_folder"]},
dynamic_items=[audio_pipeline_train],
output_keys=["id", "noisy_sig"],
)
for dataset in ["valid", "test"]:
datasets[dataset] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams[f"{dataset}_annotation"],
replacements={"data_root": hparams["data_folder"]},
dynamic_items=[audio_pipeline_valid],
output_keys=["id", "noisy_sig", "clean_sig"],
)
datasets["valid"] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams["valid_annotation"],
replacements={"data_root": hparams["data_folder"]},
dynamic_items=[audio_pipeline_valid],
output_keys=["id", "noisy_sig", "clean_sig"],
)
datasets["test"] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams["test_annotation"],
replacements={"data_root": hparams["data_folder"]},
dynamic_items=[audio_pipeline_valid],
output_keys=["id", "noisy_sig", "clean_sig"],
)

return datasets

Expand Down
6 changes: 3 additions & 3 deletions recipes/Voicebank/dereverb/spectral_mask/hparams/train.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ N_fft: 512
window_fn: !name:torch.hamming_window

# Data files
train_annotation: !ref <data_folder>/train_revb.json
valid_annotation: !ref <data_folder>/valid_revb.json
test_annotation: !ref <data_folder>/test_revb.json
train_annotation: !ref <output_folder>/train_revb.json
valid_annotation: !ref <output_folder>/valid_revb.json
test_annotation: !ref <output_folder>/test_revb.json
skip_prep: False

# Training Parameters
Expand Down
9 changes: 7 additions & 2 deletions recipes/Voicebank/dereverb/spectral_mask/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,14 @@ def clean_pipeline(clean_wav):

# Define datasets
datasets = {}
for dataset in ["train", "valid", "test"]:
data_info = {
"train": hparams["train_annotation"],
"valid": hparams["valid_annotation"],
"test": hparams["test_annotation"],
}
for dataset in data_info:
datasets[dataset] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams[f"{dataset}_annotation"],
json_path=data_info[dataset],
replacements={"data_root": hparams["data_folder"]},
dynamic_items=[noisy_pipeline, clean_pipeline],
output_keys=["id", "noisy_sig", "clean_sig"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ def prepare_voicebank(
>>> save_folder = 'exp/Voicebank_exp'
>>> prepare_voicebank(data_folder, save_folder)
"""

if skip_prep:
return

Expand Down
1 change: 1 addition & 0 deletions recipes/Voicebank/enhance/MetricGAN-U/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Use the `download_vctk` function in `voicebank_prepare.py` to download the datas
and resample it to 16000 Hz. To run an experiment, execute the following command in
the current folder:


```bash
python train.py hparams/train_dnsmos.yaml --data_folder /path/to/data_folder
```
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git+https://github.com/jfsantos/SRMRpy
25 changes: 15 additions & 10 deletions recipes/Voicebank/enhance/MetricGAN-U/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,20 +669,25 @@ def dataio_prep(hparams):
# Define datasets
datasets = {}

dataset = "train"
datasets[dataset] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams[f"{dataset}_annotation"],
datasets["train"] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams["train_annotation"],
replacements={"data_root": hparams["data_folder"]},
dynamic_items=[audio_pipeline_train],
output_keys=["id", "noisy_sig"],
)
for dataset in ["valid", "test"]:
datasets[dataset] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams[f"{dataset}_annotation"],
replacements={"data_root": hparams["data_folder"]},
dynamic_items=[audio_pipeline_valid],
output_keys=["id", "noisy_sig", "clean_sig"],
)
datasets["valid"] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams["valid_annotation"],
replacements={"data_root": hparams["data_folder"]},
dynamic_items=[audio_pipeline_valid],
output_keys=["id", "noisy_sig", "clean_sig"],
)

datasets["test"] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams["test_annotation"],
replacements={"data_root": hparams["data_folder"]},
dynamic_items=[audio_pipeline_valid],
output_keys=["id", "noisy_sig", "clean_sig"],
)

return datasets

Expand Down
2 changes: 2 additions & 0 deletions recipes/Voicebank/enhance/MetricGAN/extra_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pesq

9 changes: 7 additions & 2 deletions recipes/Voicebank/enhance/MetricGAN/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,14 @@ def dataio_prep(hparams):

# Define datasets
datasets = {}
for dataset in ["train", "valid", "test"]:
data_info = {
"train": hparams["train_annotation"],
"valid": hparams["valid_annotation"],
"test": hparams["test_annotation"],
}
for dataset in data_info:
datasets[dataset] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams[f"{dataset}_annotation"],
json_path=data_info[dataset],
replacements={"data_root": hparams["data_folder"]},
dynamic_items=[audio_pipeline],
output_keys=["id", "noisy_sig", "clean_sig"],
Expand Down
9 changes: 7 additions & 2 deletions recipes/Voicebank/enhance/SEGAN/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,14 @@ def clean_pipeline(clean_wav):

# Define datasets
datasets = {}
for dataset in ["train", "valid", "test"]:
data_info = {
"train": hparams["train_annotation"],
"valid": hparams["valid_annotation"],
"test": hparams["test_annotation"],
}
for dataset in data_info:
datasets[dataset] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams[f"{dataset}_annotation"],
json_path=data_info[dataset],
replacements={"data_root": hparams["data_folder"]},
dynamic_items=[noisy_pipeline, clean_pipeline],
output_keys=["id", "noisy_sig", "clean_sig"],
Expand Down
9 changes: 7 additions & 2 deletions recipes/Voicebank/enhance/spectral_mask/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,14 @@ def clean_pipeline(clean_wav):

# Define datasets
datasets = {}
for dataset in ["train", "valid", "test"]:
data_info = {
"train": hparams["train_annotation"],
"valid": hparams["valid_annotation"],
"test": hparams["test_annotation"],
}
for dataset in data_info:
datasets[dataset] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams[f"{dataset}_annotation"],
json_path=data_info[dataset],
replacements={"data_root": hparams["data_folder"]},
dynamic_items=[noisy_pipeline, clean_pipeline],
output_keys=["id", "noisy_sig", "clean_sig"],
Expand Down
9 changes: 7 additions & 2 deletions recipes/Voicebank/enhance/waveform_map/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,14 @@ def clean_pipeline(clean_wav):

# Define datasets
datasets = {}
for dataset in ["train", "valid", "test"]:
data_info = {
"train": hparams["train_annotation"],
"valid": hparams["valid_annotation"],
"test": hparams["test_annotation"],
}
for dataset in data_info:
datasets[dataset] = sb.dataio.dataset.DynamicItemDataset.from_json(
json_path=hparams[f"{dataset}_annotation"],
json_path=data_info[dataset],
replacements={"data_root": hparams["data_folder"]},
dynamic_items=[noisy_pipeline, clean_pipeline],
output_keys=["id", "noisy_sig", "clean_sig"],
Expand Down

0 comments on commit a812c9b

Please sign in to comment.