jlopez00's picture
Upload folder using huggingface_hub
2c01ee6 verified
raw
history blame
1.49 kB
import os
import sys
import click
from click_help_colors import HelpColorsGroup
from dotenv import load_dotenv
from sh import aws
load_dotenv()
@click.group(
cls=HelpColorsGroup,
help_headers_color="yellow",
help_options_color="green",
)
def main() -> None:
"""TTS Service CLI"""
@main.command()
@click.option("--share", is_flag=True, help="Share the service")
def serve(share: bool) -> None:
"""Start the TTS Service"""
from tts_service.app import app
app.launch(share=share)
@main.group()
def service() -> None:
"""Manages the deployed service."""
@service.command()
@click.option("--bucket", "-b", default=lambda: os.environ["BUCKET"], help="the bucket to upload voices to")
@click.option("--prefix", "-p", default=lambda: os.environ["VOICES_KEY_PREFIX"], help="the prefix to use for the keys")
@click.option("--delete", is_flag=True, help="delete extraneous files from dest")
@click.option("--dry-run", "-n", is_flag=True, help="perform a trial run with no changes made")
@click.argument("directory", type=click.Path(exists=True, file_okay=False), nargs=1)
def upload_voices(bucket: str, prefix: str, delete: bool, dry_run: bool, directory: str) -> None:
"""Upload voices to the service"""
args = [directory, f"s3://{bucket}/{prefix}/"]
if delete:
args.insert(0, "--delete")
if dry_run:
args.insert(0, "--dryrun")
aws.s3.sync(*args, _out=sys.stdout, _err=sys.stderr)
if __name__ == "__main__":
main()