Skip to content

Refactor the preprocess CLI into core, with CLI and API shims - #34

Open
joanise wants to merge 5 commits into
mainfrom
dev.ej/fs2-prepro-v2
Open

joanise wants to merge 5 commits into
mainfrom
dev.ej/fs2-prepro-v2

Conversation

@joanise

@joanise joanise commented Sep 15, 2026

Copy link
Copy Markdown
Member

@joanise
joanise requested a review from roedoejet September 15, 2026 21:31
@joanise
joanise added this pull request to stack #35 September 15, 2026 21:31
Base automatically changed from dev.ej/safe-refactors to main September 17, 2026 20:54
@joanise
joanise force-pushed the dev.ej/fs2-prepro-v2 branch from e7e7928 to bd26291 Compare September 18, 2026 18:46
@joanise
joanise force-pushed the dev.ej/fs2-prepro-v2 branch from de660f1 to 32a9572 Compare September 23, 2026 20:34

@roedoejet roedoejet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great, like the other submodules. the big comment/request for change here though is that we're still importing fns that have sys.exit and I think those need to be systematically changed in core so that only things in the cli shim are causing exits.

Comment thread styletts2/cli/__init__.py
**everyvoice train text-to-wav config/{TEXT_TO_WAV_CONFIG_FILENAME_PREFIX}.yaml --mode first**
""",
)(app_train)
command(app)(preprocess)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 😎


from ..ev_config import StyleTTS2Config

config = load_config_base_command(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the core load_config_base_command still uses sys.exit(1) which is still CLI-centric. I think the base command needs to raise a ValidationError and then the CLI-shim needs to handle it (sys.exit is fine here). But sys.exit in the programmatic/notebook use is not good

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that's a very good point.

All those sys.exit bother me anyway. Even in the CLI that's not what we should do: we should raise typer.BadParameter instead, because Typer handles that and gives better error messages to the user. I've started doing that for synthesize in dev.ej/refactor-synthesize, and I'll do it everywhere.

I agree for the API that it's a critical issue, we cannot have an API function called from a Jupyter notebook or wherever call sys.exit, that's just not cool.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point about just raising typer.BadParameter and let the CLI handle it!

Comment thread styletts2/api.py
Your StyleTTS2 config file is called "config/everyvoice-text-to-wav.yaml" if it
was created using the "everyvoice new-project" wizard.

If you need to override any values, change them in the returned config object.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does changing/overriding values in this way still go through validation?

@joanise joanise Oct 16, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, no. But once we return the object to the user, they're free to use it, no?

We at least partly rely on intellisense guiding the user, but that's not the same.

What would be a better behaviour?

Actually, now I hesitate: I think --config-args on the CLI also bypasses the validation, since it is applied after the object is created and therefore after Pydantic validation has run.

Comment thread styletts2/api.py
overwrite (bool): if false, existing files will be kept and only new files will be generated;
if true, redo all preprocessing, even if files already exist
debug (bool): enable debugging
"""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FS2 has this:

for step in steps:
        if step not in PREPROCESS_CATEGORIES:
            raise ValueError(f"Unknown step '{step}'")

which I think is helpful - could we add it here (and also in the HiFiGAN code?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants