audio_helper.cli_click module

Audio Helper — click-based command-line interface.

Twin of audio_helper.cli_argparse: same public surface (identical subcommand names, identical flag semantics), but implemented with click so users who already have a click-native shell setup (bash / zsh completion via click.shell_completion, colored –help, nested command groups) can plug it in without friction. Installed as the audio-helper-click entry point in pyproject.toml.

Design notes

  • Subcommands mirror audio-helper (the argparse twin) so both CLIs can be introspected identically by higher layers (FastAPI).

  • Flags reuse the argparse names (--input / --output / …) rather than the more idiomatic click positional style — consistency across the two CLIs beats micro-idiomaticity here.

  • Errors from the library propagate unchanged; click handles the formatting.

Usage Example

>>> #   audio-helper-click convert    --input in.mp3 --output out.wav --freq 44100
>>> #   audio-helper-click duration   --input in.mp3
>>> #   audio-helper-click split      --input in.mp3 --output-dir chunks/ --seconds 30
>>> #   audio-helper-click resemblance --a a.mp3 --b b.mp3

Author

Warith Harchaoui, Ph.D. — https://linkedin.com/in/warith-harchaoui/

audio_helper.cli_click.console_entry()[source]

Console entry point (audio-helper-click).

Click’s own error handling only special-cases ClickException/ Abort (and a broken pipe); a plain library exception (e.g. an AssertionError from an invalid audio file, or an ffmpeg.Error) would otherwise propagate as a raw Python traceback instead of a clean CLI error. This wraps the whole invocation and translates that last case into a one-line stderr message + exit 1 — click’s own control flow (usage errors, --help, an explicit sys.exit in a subcommand, e.g. separate’s missing-torch guard above) already raises SystemExit, a BaseException this does not catch, so it passes through untouched.

Return type:

None