File size: 1,490 Bytes
1378843
2c01ee6
1378843
7e9f59c
 
1378843
2c01ee6
1378843
 
7e9f59c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bbf5262
1378843
bbf5262
7e9f59c
 
1378843
 
 
 
 
 
 
 
 
 
2c01ee6
 
1378843
2c01ee6
1378843
2c01ee6
 
 
 
1378843
 
7e9f59c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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()