Skip to content

Commit

Permalink
Use MP3 for CREMA-D.
Browse files Browse the repository at this point in the history
  • Loading branch information
agkphysics committed Sep 13, 2021
1 parent 5cc4aaf commit ab5c209
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions datasets/CREMA-D/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@
...
"""

import shutil
from pathlib import Path

import click
import pandas as pd
from tqdm import tqdm

from ertk.dataset import write_annotations, write_filelist
from ertk.dataset import resample_audio, write_annotations, write_filelist
from ertk.stats import alpha
from ertk.utils import PathlibPath

Expand All @@ -38,18 +36,18 @@
def main(input_dir: Path, resample: bool):
"""Process CREMA-D dataset at location INPUT_DIR."""

paths = list(input_dir.glob("AudioWAV/*.wav"))
paths = list(input_dir.glob("AudioMP3/*.mp3"))
write_annotations({p.stem: emotion_map[p.stem[9]] for p in paths}, "label")
write_annotations({p.stem: p.stem[:4] for p in paths}, "speaker")
write_annotations({p.stem: "en" for p in paths}, "language")
write_annotations({p.stem: "us" for p in paths}, "country")
# 1076_MTI_SAD_XX has no signal, 1040_ITH_SAD_X is incorrectly named
paths = [p for p in paths if p.stem not in {"1076_MTI_SAD_XX", "1040_ITH_SAD_X"}]
# 1076_MTI_SAD_XX has no signal
paths = [p for p in paths if p.stem != "1076_MTI_SAD_XX"]
resample_dir = Path("resampled")
if resample:
Path("resampled").mkdir(exist_ok=True)
for p in tqdm(paths, desc="Copying audio"):
shutil.copyfile(p, Path("resampled", p.name))
write_filelist(Path("resampled").glob("*.wav"), "files_all")
resample_dir.mkdir(exist_ok=True)
resample_audio(paths, resample_dir)
write_filelist(resample_dir.glob("*.wav"), "files_all")

summaryTable = pd.read_csv(
input_dir / "processedResults" / "summaryTable.csv",
Expand Down

0 comments on commit ab5c209

Please sign in to comment.