Skip to content

Commit

Permalink
feat: renamed PreprocessedInputFixture to PreprocessedAudioFixture
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelLarkin committed Apr 16, 2024
1 parent 339e105 commit 6416c6e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from everyvoice.tests.basic_test_case import BasicTestCase


class PreprocessedInputFixture:
class PreprocessedAudioFixture:
"""
Preprocess the audio files.
A unittest fixture to preprocess the audio files.
"""

_tempdir = tempfile.TemporaryDirectory(prefix="tmpdir_PreprocessedInputFixture_")
Expand Down Expand Up @@ -61,16 +61,16 @@ class PreprocessedInputFixture:
def setUpClass(cls):
"""Generate a preprocessed test set that can be used in various test cases."""
# We only need to actually run this once
if not PreprocessedInputFixture._preprocess_ran:
PreprocessedInputFixture.preprocessor.preprocess(
output_path=str(PreprocessedInputFixture.lj_filelist),
if not PreprocessedAudioFixture._preprocess_ran:
PreprocessedAudioFixture.preprocessor.preprocess(
output_path=str(PreprocessedAudioFixture.lj_filelist),
cpus=1,
overwrite=False,
to_process=("audio", "energy", "pitch", "text", "spec"),
)
PreprocessedInputFixture.lj_preprocessed.mkdir(parents=True, exist_ok=True)
(PreprocessedInputFixture.lj_preprocessed / "duration").symlink_to(
PreprocessedInputFixture.data_dir / "lj" / "preprocessed" / "duration",
PreprocessedAudioFixture.lj_preprocessed.mkdir(parents=True, exist_ok=True)
(PreprocessedAudioFixture.lj_preprocessed / "duration").symlink_to(
PreprocessedAudioFixture.data_dir / "lj" / "preprocessed" / "duration",
)

PreprocessedInputFixture._preprocess_ran = True
PreprocessedAudioFixture._preprocess_ran = True
12 changes: 6 additions & 6 deletions everyvoice/tests/test_dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
SpecDataset,
)
from everyvoice.tests.basic_test_case import BasicTestCase
from everyvoice.tests.preprocessed_input_fixture import PreprocessedInputFixture
from everyvoice.tests.preprocessed_audio_fixture import PreprocessedAudioFixture
from everyvoice.utils import filter_dataset_based_on_target_text_representation_level


class DataLoaderTest(PreprocessedInputFixture, BasicTestCase):
class DataLoaderTest(PreprocessedAudioFixture, BasicTestCase):
"""Basic test for dataloaders"""

# FIXME: Shouldn't this be done only one for this class and not for every test?
Expand All @@ -34,18 +34,18 @@ def setUp(self) -> None:
vocoder=VocoderConfig(
contact=self.contact,
training=HiFiGANTrainingConfig(
training_filelist=PreprocessedInputFixture.lj_preprocessed
training_filelist=PreprocessedAudioFixture.lj_preprocessed
/ "training_preprocessed_filelist.psv",
validation_filelist=PreprocessedInputFixture.lj_preprocessed
validation_filelist=PreprocessedAudioFixture.lj_preprocessed
/ "validation_preprocessed_filelist.psv",
),
),
)
self.config.vocoder.preprocessing.save_dir = (
PreprocessedInputFixture.lj_preprocessed
PreprocessedAudioFixture.lj_preprocessed
)
self.config.vocoder.training.training_filelist = (
PreprocessedInputFixture.lj_preprocessed / "preprocessed_filelist.psv"
PreprocessedAudioFixture.lj_preprocessed / "preprocessed_filelist.psv"
)

def test_base_data_loader(self):
Expand Down
4 changes: 2 additions & 2 deletions everyvoice/tests/test_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
from everyvoice.model.vocoder.config import VocoderConfig
from everyvoice.preprocessor import Preprocessor
from everyvoice.tests.basic_test_case import BasicTestCase
from everyvoice.tests.preprocessed_input_fixture import PreprocessedInputFixture
from everyvoice.tests.preprocessed_audio_fixture import PreprocessedAudioFixture
from everyvoice.tests.stubs import capture_stdout, mute_logger
from everyvoice.utils import generic_psv_filelist_reader


class PreprocessingTest(PreprocessedInputFixture, BasicTestCase):
class PreprocessingTest(PreprocessedAudioFixture, BasicTestCase):
"""Unit tests for preprocessing steps"""

def setUp(self) -> None:
Expand Down

0 comments on commit 6416c6e

Please sign in to comment.