Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[run]
branch = true
source_pkgs =
fs2
everyvoice.model.feature_prediction.FastSpeech2_lightning.fs2
omit =
*tmp*
*/run_tests.py
*/tests/*
*/__main__.py

Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
cd EveryVoice
CUDA_TAG=cpu pip install -r requirements.torch.txt --find-links https://download.pytorch.org/whl/torch_stable.html
pip install -e .[dev]
pip install coverage

- run: pip freeze

Expand All @@ -47,7 +46,7 @@ jobs:
- name: Run fs2 unit tests
run: |
cd EveryVoice/everyvoice/model/feature_prediction/FastSpeech2_lightning/
coverage run -m unittest discover everyvoice.model.feature_prediction.FastSpeech2_lightning.fs2.tests
coverage run -m pytest
coverage xml

- name: Plain text coverage report
Expand Down
128 changes: 0 additions & 128 deletions fs2/run_tests.py

This file was deleted.

53 changes: 26 additions & 27 deletions fs2/tests/test_chunking.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
from pathlib import Path
from string import ascii_lowercase
from tempfile import TemporaryDirectory
from typing import Callable
from unittest import TestCase

import torch
from everyvoice.config.shared_types import ContactInformation
from everyvoice.config.text_config import TextConfig
from everyvoice.tests.model_stubs import get_stubbed_vocoder
from everyvoice.tests.stubs import silence_c_stderr
from everyvoice.text.text_processor import TextProcessor
from pydub import AudioSegment
from pympi import TextGrid
Expand Down Expand Up @@ -50,21 +50,20 @@ def test_duplicate_filename(self):
tmp_dir = Path(tmp_dir)
vocoder, vocoder_path = get_stubbed_vocoder(tmp_dir)

with silence_c_stderr():
writers = get_synthesis_output_callbacks(
[SynthesizeOutputFormats.wav],
config=FastSpeech2Config(
contact=self.contact,
training=FastSpeech2TrainingConfig(vocoder_path=vocoder_path),
),
device=torch.device("cpu"),
global_step=77,
output_dir=tmp_dir,
output_key=self.output_key,
vocoder_model=vocoder,
vocoder_config=vocoder.config,
vocoder_global_step=10,
)
writers = get_synthesis_output_callbacks(
[SynthesizeOutputFormats.wav],
config=FastSpeech2Config(
contact=self.contact,
training=FastSpeech2TrainingConfig(vocoder_path=vocoder_path),
),
device=torch.device("cpu"),
global_step=77,
output_dir=tmp_dir,
output_key=self.output_key,
vocoder_model=vocoder,
vocoder_config=vocoder.config,
vocoder_global_step=10,
)

# Batch 1
writer = next(iter(writers.values()))
Expand Down Expand Up @@ -93,6 +92,11 @@ def test_duplicate_filename(self):


class ChunkingTestBase(TestCase):
get_test_callback: Callable
outputs: dict
batch1: dict
batch2: dict

@classmethod
def setUpClass(cls):
# Define the function that gets the callbacks, get_test_callback
Expand Down Expand Up @@ -172,8 +176,7 @@ def test_wav_chunks(self):
"""
Tests the correctness of the output of .wavs for chunked text over multiple batches.
"""
with silence_c_stderr():
writers = self.get_test_callback([SynthesizeOutputFormats.wav])
writers = self.get_test_callback([SynthesizeOutputFormats.wav])

# Batch 1
writer = next(iter(writers.values()))
Expand Down Expand Up @@ -233,8 +236,7 @@ def test_spec_chunks(self):
"""
Tests the correctness of the output of spectrograms for chunked text over multiple batches.
"""
with silence_c_stderr():
writers = self.get_test_callback([SynthesizeOutputFormats.spec])
writers = self.get_test_callback([SynthesizeOutputFormats.spec])

# Batch 1
writer = next(iter(writers.values()))
Expand Down Expand Up @@ -289,8 +291,7 @@ def test_textgrid_chunks(self):
"""
Tests the correctness of the output of TextGrid files for chunked text over multiple batches.
"""
with silence_c_stderr():
writers = self.get_test_callback([SynthesizeOutputFormats.textgrid])
writers = self.get_test_callback([SynthesizeOutputFormats.textgrid])

# Batch 1
writer = next(iter(writers.values()))
Expand Down Expand Up @@ -357,8 +358,7 @@ def test_textgrid_chunks(self):

class TestWritingReadAlongXML(ChunkingTestBase):
def test_writing_readalong(self):
with silence_c_stderr():
writers = self.get_test_callback([SynthesizeOutputFormats.readalong_xml])
writers = self.get_test_callback([SynthesizeOutputFormats.readalong_xml])

# Batch 1
writer = next(iter(writers.values()))
Expand Down Expand Up @@ -403,8 +403,7 @@ def test_writing_readalong(self):

class TestWritingReadAlongHTML(ChunkingTestBase):
def test_writing_readalong(self) -> None:
with silence_c_stderr():
writers = self.get_test_callback([SynthesizeOutputFormats.readalong_html])
writers = self.get_test_callback([SynthesizeOutputFormats.readalong_html])

for writer in writers.values():
for batch, idx in ((self.batch1, 1), (self.batch2, 2)):
Expand All @@ -426,7 +425,7 @@ def test_writing_readalong(self) -> None:
"twothreefour--S2--L2--22050-mel-librosa.html",
)
for output_file_basename in output_file_basenames:
output_file = output_dir.parent/"readalongs"/output_file_basename
output_file = output_dir.parent / "readalongs" / output_file_basename
with self.subTest(output_file=output_file):
self.assertTrue(output_file.exists())
with open(output_file, "r", encoding="utf8") as f:
Expand Down
Loading
Loading