Skip to content

Commit

Permalink
Allow overriding base URL from CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
reuben committed Jul 19, 2022
1 parent ef421ae commit a67d576
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
16 changes: 11 additions & 5 deletions coqui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
""" A Python API and CLI to use Coqui services programmatically """
__version__ = "0.0.1"
__version__ = "0.0.2"

import asyncio
from collections import namedtuple
Expand Down Expand Up @@ -47,17 +47,20 @@ def sync_func(self, *args, **kwargs):


class AuthenticationError(Exception):
""" Raised when an authenticated operation is attempted without logging in first. """
"""Raised when an authenticated operation is attempted without logging in first."""

pass


class SynthesisError(Exception):
""" Raised when synthesis fails due to invalid creation parameters. """
"""Raised when synthesis fails due to invalid creation parameters."""

pass


class CloneVoiceError(Exception):
""" Raised when cloning a voice fails due to invalid cloning parameters. """
"""Raised when cloning a voice fails due to invalid cloning parameters."""

pass


Expand Down Expand Up @@ -146,7 +149,10 @@ async def download_async(self, dest_file):


class Coqui(metaclass=SyncReplacer):
def __init__(self, base_url="https://creator-app.prod-coqui.com"):
def __init__(self, base_url=None):
base_url = (
"https://creator-app.prod-coqui.com" if base_url is None else base_url
)
self._base_url = base_url
self._api_token = None
self._logged_in = False
Expand Down
8 changes: 5 additions & 3 deletions coqui/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ def _read(self):
return json.load(fin)


BASE_URL = "http://localhost:8001"
BASE_URL = None
AuthInfo = PersistedConfig("~/.coqui/credentials")


@click.group()
def main():
pass
@click.option("--base-url", default=None)
def main(base_url):
global BASE_URL
BASE_URL = base_url


# TODO: remove, keep token only
Expand Down

0 comments on commit a67d576

Please sign in to comment.