Skip to content
Open
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
25 changes: 14 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,19 @@ jobs:
- name: Install dependencies and EveryVoice itself
run: |
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 -e .
- run: pip freeze
- run: pip list
- name: Make sure the CLI stays fast
run: ./profile-help-ci.sh "${{ github.event.pull_request.head.sha }}"
- name: Report help speed in PR
if: github.event_name == 'pull_request'
uses: mshick/add-pr-comment@7c1a3a3e5a072270dc21c0639df39ca11e860b2b # v3.5.0
with:
preformatted: true
message-path: import-message.txt
- name: Install test dependencies
run: pip install -e .[test]
- name: Run tests
run: |
cd everyvoice
Expand All @@ -56,14 +66,6 @@ jobs:
with:
fail_ci_if_error: false # optional (default = false)
token: ${{ secrets.CODECOV_TOKEN }}
- name: Make sure the CLI stays fast
run: ./profile-help-ci.sh "${{ github.event.pull_request.head.sha }}"
- name: Report help speed in PR
if: github.event_name == 'pull_request'
uses: mshick/add-pr-comment@7c1a3a3e5a072270dc21c0639df39ca11e860b2b # v3.5.0
with:
preformatted: true
message-path: import-message.txt

test-on-windows:
runs-on: windows-latest
Expand Down Expand Up @@ -96,7 +98,7 @@ jobs:
- name: Install dependencies and EveryVoice itself
run: |
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 -e .[test]
- run: pip freeze
- run: pip list
- name: Run tests
Expand Down Expand Up @@ -141,7 +143,8 @@ jobs:
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
sparse-checkout: pyproject.toml
submodules: false
- run: pip install licensecheck --no-warn-conflicts
- name: Run license check overall
run: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This is the Text-to-Speech (TTS) toolkit used by the Small Teams "Speech Generat
- On Ubuntu, `sudo apt-get install ffmpeg` should work.
- Other Linux distros should have an equivalent package.
- With Conda, `conda install ffmpeg` is reliable.
- Or, use the official bundles from https://www.ffmpeg.org/download.html
- Or, use the applicable link under "Get packages & executables files" at https://www.ffmpeg.org/download.html

- Install `torch` and `torchaudio` version 2.1.0 for your platform and CUDA version: follow the instructions at https://pytorch.org/get-started/locally/ but specify `torch==2.1.0 torchaudio==2.1.0` in the install command and remove `torchvision`.

Expand Down
62 changes: 32 additions & 30 deletions everyvoice/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
synthesize as synthesize_hfg,
)
from everyvoice.model.vocoder.HiFiGAN_iSTFT_lightning.hfgl.cli import train as train_hfg
from everyvoice.run_tests import SUITE_NAMES, run_tests
from everyvoice.utils import spinner
from everyvoice.wizard import (
PREPROCESSING_CONFIG_FILENAME_PREFIX,
Expand Down Expand Up @@ -622,28 +621,6 @@ def inspect_checkpoint(model_path: Path):
)


TestSuites = Enum("TestSuites", {name: name for name in SUITE_NAMES}) # type: ignore


@app.command(hidden=True)
def test(suite: TestSuites = typer.Argument("dev")): # pragma: no cover
"""Run a test suite"""
try:
import everyvoice.tests # noqa: F401

run_tests(suite.value)
except ModuleNotFoundError:
print(
"ERROR: hidden command 'everyvoice test' only works when you install EveryVoice from source, with dev dependencies.",
file=sys.stderr,
)
sys.exit(1)


# Deferred full initialization to optimize the CLI, but still exposed for unit testing.
SCHEMAS_TO_OUTPUT: dict[str, Any] = {} # dict[str, type[BaseModel]]


AllowedDemoOutputFormats = Enum( # type: ignore
"AllowedDemoOutputFormats",
[("all", "all")] + [(i.name, i.value) for i in SynthesizeOutputFormats],
Expand Down Expand Up @@ -816,6 +793,10 @@ def demo(
)


# Deferred full initialization to optimize the CLI, but still exposed for unit testing.
SCHEMAS_TO_OUTPUT: dict[str, Any] = {} # dict[str, type[BaseModel]]


@app.command(hidden=True)
def update_schemas(
out_dir: Annotated[
Expand Down Expand Up @@ -852,16 +833,37 @@ def update_schemas(
}
)

all_good = True
for filename, schema in SCHEMAS_TO_OUTPUT.items():
schema_contents = json.dumps(schema.model_json_schema(), indent=2) + "\n"
if (schema_dir_path / filename).exists():
raise FileExistsError(
f"Sorry a schema already exists for version {filename}.\n"
"If it's already been published to the schema store, please bump the EveryVoice minor version number and generate the schemas again.\n"
"If the current minor version is still in development, just delete the schema files and try again."
with open(schema_dir_path / filename) as f:
existing_contents = f.read()
if existing_contents == schema_contents:
print(f"Schema '{filename}' already up to date.")
else:
all_good = False
print(
f"Out of date schema '{filename}' exists in '{schema_dir_path}'."
)
else:
with open(
schema_dir_path / filename, "w", encoding="utf8", newline="\n"
) as f:
f.write(schema_contents)
print(f"Schema '{filename}' created.")

if not all_good:
sys.exit(
dedent(
"""
ERROR: out-of-date schemas exist.
If the current schemas were already published to the schema store, please
bump the EveryVoice minor version number and run update-schemas again.
If the current minor version is still in development, delete the out-of-date
schemas and try again."""
)
with open(schema_dir_path / filename, "w", encoding="utf8", newline="\n") as f:
json.dump(schema.model_json_schema(), f, indent=2)
f.write("\n")
)


@app.command()
Expand Down
33 changes: 21 additions & 12 deletions everyvoice/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,17 @@ def test_command_help_messages(self):
result = self.runner.invoke(app, [command, "-h"])
assert result.exit_code == 0

def test_update_schema(self):
def test_update_schemas(self):
dummy_contact = ContactInformation(
contact_name="Test Runner", contact_email="info@everyvoice.ca"
)
with tempfile.TemporaryDirectory() as tmpdir:
with tempfile.TemporaryDirectory() as tmpdir_s:
tmpdir = Path(tmpdir_s)
# Validate that schema generation works correctly.
_ = self.runner.invoke(app, ["update-schemas", "-o", tmpdir])
_ = self.runner.invoke(app, ["update-schemas", "-o", tmpdir_s])
for filename, obj in SCHEMAS_TO_OUTPUT.items():
with self.subTest(filename=filename, type=obj):
with open(Path(tmpdir) / filename, encoding="utf8") as f:
with open(tmpdir / filename, encoding="utf8") as f:
schema = json.load(f)
# serialize the model to json and then validate against the schema
# Some objects will require a contact key
Expand All @@ -297,10 +298,8 @@ def test_update_schema(self):
# i.e., that we didn't change the models but forget to update the schemas.
for filename in SCHEMAS_TO_OUTPUT:
with self.subTest(filename=filename):
with open(Path(tmpdir) / filename, encoding="utf8") as f:
new_schema = f.read().replace(
"\\\\", "/"
) # force paths to posix
with open(tmpdir / filename, encoding="utf8") as f:
new_schema = f.read()
try:
with open(EV_DIR / ".schema" / filename, encoding="utf8") as f:
saved_schema = f.read()
Expand All @@ -314,11 +313,21 @@ def test_update_schema(self):
'Schemas are out of date, please run "everyvoice update-schemas".',
)

# Next, but only if everything above passed, we make sure we can't overwrite
# existing schemas by accident.
# Make sure we can't overwrite existing but out-of-date schemas by accident.
with open(tmpdir / next(iter(SCHEMAS_TO_OUTPUT)), "w") as f:
# Make one of the schemas forcefully out of date
f.write("asdf")
result = self.runner.invoke(app, ["update-schemas", "-o", tmpdir_s])
assert result.exit_code != 0
assert "ERROR" in result.output
assert "Out of date" in result.output

# If everything above passed, running update-schemas should say schemas are up to date
result = self.runner.invoke(app, ["update-schemas"])
assert result.exit_code != 0
assert "FileExistsError" in str(result)
assert result.exit_code == 0
assert "already up to date" in result.output
assert "Out of date" not in result.output
assert "ERROR" not in result.output

def test_evaluate(self):
result = self.runner.invoke(
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ torch = [
]
dev = [
"black~=24.3",
"coverage",
"chardet<6", # requests<=2.32.5 not compat with chardet>=6, remove this on next requests release
"diff-cover",
"flake8>=4.0.1",
"gitlint-core>=0.19.0",
Expand All @@ -109,6 +107,7 @@ dev = [
"everyvoice[test]",
]
test = [
"coverage",
"jsonschema>=4.17.3",
"pep440>=0.1.2",
"playwright>=1.52.0",
Expand Down
Loading