From f829ca6b2945286ad358a52f344a689e9e3fac51 Mon Sep 17 00:00:00 2001 From: Adrien Delessert Date: Fri, 11 Oct 2024 13:57:39 -0400 Subject: [PATCH] Ensure cli options are lowercased --- joinery/cli.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/joinery/cli.py b/joinery/cli.py index 8f48470..05051c4 100644 --- a/joinery/cli.py +++ b/joinery/cli.py @@ -14,6 +14,11 @@ load_dotenv() +def _force_lowercase(ctx, param, value): + if value is not None: + return value.lower() + + @click.group(invoke_without_command=True) @click.pass_context @click.option( @@ -29,12 +34,23 @@ type=click.File("wb+"), ) @click.option( - "--model", default="tts-1", help="Slug of the text-to-speech model to be used" + "--model", + default="tts-1", + help="Slug of the text-to-speech model to be used", + callback=_force_lowercase, +) +@click.option( + "--service", + default="openai", + help="API service (currently only supports openai)", + callback=_force_lowercase, ) @click.option( - "--service", default="openai", help="API service (currently only supports openai)" + "--voice", + default="alloy", + help="Slug of the voice to be used", + callback=_force_lowercase, ) -@click.option("--voice", default="alloy", help="Slug of the voice to be used") @click.option("--no-cache", is_flag=True, default=False, help="Disable caching") def run_tts(ctx, input_file, output_file, model, service, voice, no_cache): if ctx.invoked_subcommand: