typecast-python 0.3.2__py3-none-any.whl → 0.3.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- typecast/async_client.py +2 -0
- typecast/client.py +6 -3
- typecast/conf.py +13 -4
- {typecast_python-0.3.2.dist-info → typecast_python-0.3.3.dist-info}/METADATA +1 -1
- {typecast_python-0.3.2.dist-info → typecast_python-0.3.3.dist-info}/RECORD +7 -7
- {typecast_python-0.3.2.dist-info → typecast_python-0.3.3.dist-info}/WHEEL +0 -0
- {typecast_python-0.3.2.dist-info → typecast_python-0.3.3.dist-info}/licenses/LICENSE +0 -0
typecast/async_client.py
CHANGED
|
@@ -68,6 +68,8 @@ class AsyncTypecast:
|
|
|
68
68
|
"""
|
|
69
69
|
self.host = conf.get_host(host)
|
|
70
70
|
self.api_key = conf.get_api_key(api_key)
|
|
71
|
+
if not self.api_key and conf.is_default_host(self.host):
|
|
72
|
+
raise ValueError("API key is required for the default Typecast API host")
|
|
71
73
|
self.session: Optional[aiohttp.ClientSession] = None
|
|
72
74
|
|
|
73
75
|
async def __aenter__(self):
|
typecast/client.py
CHANGED
|
@@ -77,10 +77,13 @@ class Typecast:
|
|
|
77
77
|
"""
|
|
78
78
|
self.host = conf.get_host(host)
|
|
79
79
|
self.api_key = conf.get_api_key(api_key)
|
|
80
|
+
if not self.api_key and conf.is_default_host(self.host):
|
|
81
|
+
raise ValueError("API key is required for the default Typecast API host")
|
|
80
82
|
self.session = requests.Session()
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
headers = {"Content-Type": "application/json"}
|
|
84
|
+
if self.api_key:
|
|
85
|
+
headers["X-API-KEY"] = self.api_key
|
|
86
|
+
self.session.headers.update(headers)
|
|
84
87
|
|
|
85
88
|
def _handle_error(self, status_code: int, response_text: str):
|
|
86
89
|
"""Handle HTTP error responses with specific exception types."""
|
typecast/conf.py
CHANGED
|
@@ -5,12 +5,21 @@ TYPECAST_API_HOST = "https://api.typecast.ai"
|
|
|
5
5
|
|
|
6
6
|
def get_host(host=None):
|
|
7
7
|
if host: # Parameter takes priority
|
|
8
|
-
return host
|
|
8
|
+
return normalize_host(host)
|
|
9
9
|
env_host = os.getenv("TYPECAST_API_HOST") # Check environment variable
|
|
10
|
-
return env_host if env_host else TYPECAST_API_HOST # Use default if not set
|
|
10
|
+
return normalize_host(env_host) if env_host else TYPECAST_API_HOST # Use default if not set
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def get_api_key(api_key=None):
|
|
14
14
|
if api_key: # Parameter takes priority
|
|
15
|
-
return api_key
|
|
16
|
-
|
|
15
|
+
return api_key.strip()
|
|
16
|
+
env_key = os.getenv("TYPECAST_API_KEY") # Return from environment variable
|
|
17
|
+
return env_key.strip() if env_key else None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def normalize_host(host):
|
|
21
|
+
return host.strip().rstrip("/")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def is_default_host(host):
|
|
25
|
+
return normalize_host(host).lower() == TYPECAST_API_HOST
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: typecast-python
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Official Typecast Python SDK - Convert text to lifelike speech using AI-powered voices
|
|
5
5
|
Project-URL: Homepage, https://typecast.ai
|
|
6
6
|
Project-URL: Documentation, https://typecast.ai/docs/overview
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
typecast/__init__.py,sha256=3pdJqNkXCZ7svzqab4sBR_qwyoM5E2sPjfuci1g1Ub8,1047
|
|
2
2
|
typecast/_voice_clone.py,sha256=TN2tbB3b5lC5uFCBnbERhz37bNJlbv6VZ-vj70EfTs4,3464
|
|
3
|
-
typecast/async_client.py,sha256=
|
|
4
|
-
typecast/client.py,sha256=
|
|
5
|
-
typecast/conf.py,sha256=
|
|
3
|
+
typecast/async_client.py,sha256=ctttygbdJWZV-cAlfYSX-PBeg3e7uMHgnPFK1uao4aw,17438
|
|
4
|
+
typecast/client.py,sha256=_YsMmt9Foe8HxkADyiEjFejsQdvmwDOpf4ydqy85Kn0,15413
|
|
5
|
+
typecast/conf.py,sha256=yfOHYZDvIshWWMriN5wE0GFPR8AX3zv4Rg2655OvA9Q,724
|
|
6
6
|
typecast/exceptions.py,sha256=Y0ZzYebe8zOSOSAHbXfKR0G_RJgdmZXxi15Z7ZxPLIk,1568
|
|
7
7
|
typecast/utils.py,sha256=XuNuX7gW8_CGKqZ-cv_tKlPVMPBluAYJBw2clwmjIMI,708
|
|
8
8
|
typecast/models/__init__.py,sha256=UEPUjg86fpCMXUvAzcNgxSPPhuPwCY9aQbzK3w90Fj0,1203
|
|
@@ -10,7 +10,7 @@ typecast/models/error.py,sha256=XomIjx7jvlCjItqzJuCAT4mXC9jwTjxR8lLDUk6P8KA,152
|
|
|
10
10
|
typecast/models/subscription.py,sha256=EIaAAo3cCRw8LYT_O6D9AVwxqIHrWCijzl4UTx7FZB8,894
|
|
11
11
|
typecast/models/tts.py,sha256=IDz4IN2d4MCkATB_rVlaEoMS7EgWlQsW0tIP8k67LHo,16001
|
|
12
12
|
typecast/models/voices.py,sha256=-EXP35jDy7_G30k5bDnVrFJHp6svEDTA5jJ8oHAgXNQ,2310
|
|
13
|
-
typecast_python-0.3.
|
|
14
|
-
typecast_python-0.3.
|
|
15
|
-
typecast_python-0.3.
|
|
16
|
-
typecast_python-0.3.
|
|
13
|
+
typecast_python-0.3.3.dist-info/METADATA,sha256=-FDDF0giScZ4XJPbqkV5cOUutwNA-9j-4CrsQP_rRYU,25530
|
|
14
|
+
typecast_python-0.3.3.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
15
|
+
typecast_python-0.3.3.dist-info/licenses/LICENSE,sha256=HvtJ-S89uUkuYmt-OvVk4MRxmzwtbn84__qJtSrGU2Q,11348
|
|
16
|
+
typecast_python-0.3.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|