tontaube 0.1.0__tar.gz

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.
tontaube-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Cremer & Cremer Technologies UG (haftungsbeschränkt)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.4
2
+ Name: tontaube
3
+ Version: 0.1.0
4
+ Summary: Python SDK for the Tontaube text-to-speech API
5
+ License: MIT
6
+ Project-URL: Homepage, https://tontaube.ai
7
+ Project-URL: API Reference, https://tontaube.ai/api-reference
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: httpx>=0.24
12
+ Requires-Dist: packaging>=21.0
13
+ Requires-Dist: pydantic>=2.0
14
+ Dynamic: license-file
15
+
16
+ # tontaube
17
+
18
+ Python SDK for the [Tontaube](https://tontaube.ai) text-to-speech API.
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ pip install tontaube
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ```python
29
+ import tontaube
30
+
31
+ with tontaube.Client(api_key="your-api-key") as client:
32
+ speakers = client.list_speakers()
33
+ response = client.generate_speech(
34
+ text="Tell me what we are building today, and I will get right to work.",
35
+ speaker_id=speakers[0].id,
36
+ )
37
+
38
+ with open("speech.wav", "wb") as f:
39
+ f.write(response.content)
40
+ ```
41
+
42
+ Async client is also available via `tontaube.AsyncClient`. See the [examples/](examples/) folder for more usage patterns.
43
+
44
+ For full API reference see [tontaube.ai/api-reference](https://tontaube.ai/api-reference).
@@ -0,0 +1,29 @@
1
+ # tontaube
2
+
3
+ Python SDK for the [Tontaube](https://tontaube.ai) text-to-speech API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install tontaube
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ import tontaube
15
+
16
+ with tontaube.Client(api_key="your-api-key") as client:
17
+ speakers = client.list_speakers()
18
+ response = client.generate_speech(
19
+ text="Tell me what we are building today, and I will get right to work.",
20
+ speaker_id=speakers[0].id,
21
+ )
22
+
23
+ with open("speech.wav", "wb") as f:
24
+ f.write(response.content)
25
+ ```
26
+
27
+ Async client is also available via `tontaube.AsyncClient`. See the [examples/](examples/) folder for more usage patterns.
28
+
29
+ For full API reference see [tontaube.ai/api-reference](https://tontaube.ai/api-reference).
@@ -0,0 +1,26 @@
1
+ [project]
2
+ name = "tontaube"
3
+ version = "0.1.0"
4
+ description = "Python SDK for the Tontaube text-to-speech API"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = { text = "MIT" }
8
+ dependencies = [
9
+ "httpx>=0.24",
10
+ "packaging>=21.0",
11
+ "pydantic>=2.0",
12
+ ]
13
+
14
+ [project.urls]
15
+ Homepage = "https://tontaube.ai"
16
+ "API Reference" = "https://tontaube.ai/api-reference"
17
+
18
+ [build-system]
19
+ requires = ["setuptools", "wheel"]
20
+ build-backend = "setuptools.build_meta"
21
+
22
+ [dependency-groups]
23
+ dev = [
24
+ "pytest>=8.0",
25
+ "ruff", # For Formatting
26
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,20 @@
1
+ from ._client import Client
2
+ from ._async_client import AsyncClient
3
+ from .models import Speaker, GenerateRequest, GenerateResponse
4
+ from .core import build_headers
5
+ from ._constants import DEFAULT_BASE_URL, DEFAULT_TIMEOUT
6
+ from ._exceptions import OutdatedSDKError
7
+ from .version import __version__
8
+
9
+ __all__ = [
10
+ "Client",
11
+ "AsyncClient",
12
+ "Speaker",
13
+ "GenerateRequest",
14
+ "GenerateResponse",
15
+ "OutdatedSDKError",
16
+ "build_headers",
17
+ "DEFAULT_BASE_URL",
18
+ "DEFAULT_TIMEOUT",
19
+ "__version__",
20
+ ]
@@ -0,0 +1,67 @@
1
+ from typing import List, Optional
2
+
3
+ import httpx
4
+
5
+ from .models import Speaker, GenerateRequest, GenerateResponse
6
+ from ._base_client import BaseClient
7
+ from ._constants import DEFAULT_BASE_URL, VERSION_CHECK_TIMEOUT
8
+
9
+
10
+ class AsyncClient(BaseClient):
11
+ def __init__(self, api_key: str, base_url: str = DEFAULT_BASE_URL, **kwargs):
12
+ super().__init__(api_key, base_url, **kwargs)
13
+ self._http_client = httpx.AsyncClient(
14
+ base_url=self.base_url,
15
+ headers=self._headers,
16
+ timeout=self._timeout,
17
+ )
18
+
19
+ async def check_version(self) -> None:
20
+ try:
21
+ response = await self._http_client.get("/sdk-status", timeout=VERSION_CHECK_TIMEOUT)
22
+ response.raise_for_status()
23
+ self._evaluate_version(response.json())
24
+ except RuntimeError:
25
+ raise
26
+ except Exception:
27
+ return
28
+
29
+ async def list_speakers(self) -> List[Speaker]:
30
+ response = await self._http_client.get("/speech/speakers")
31
+ self._handle_response(response)
32
+ return [Speaker.model_validate(s) for s in response.json()]
33
+
34
+ async def generate_speech(
35
+ self,
36
+ text: str,
37
+ speaker_id: str,
38
+ language: Optional[str] = None,
39
+ format: Optional[str] = None,
40
+ temperature: Optional[float] = None,
41
+ ) -> GenerateResponse:
42
+ payload = GenerateRequest(
43
+ text=text,
44
+ speaker_id=speaker_id,
45
+ language=language,
46
+ format=format,
47
+ temperature=temperature,
48
+ ).model_dump(exclude_none=True)
49
+
50
+ response = await self._http_client.post("/speech/generate", json=payload)
51
+ self._handle_response(response)
52
+ return GenerateResponse(
53
+ content=response.content,
54
+ sample_rate=response.headers.get("x-sample-rate"),
55
+ audio_duration=response.headers.get("x-audio-duration"),
56
+ cost_usd=response.headers.get("x-cost-usd"),
57
+ balance_usd=response.headers.get("x-balance-usd"),
58
+ )
59
+
60
+ async def close(self):
61
+ await self._http_client.aclose()
62
+
63
+ async def __aenter__(self):
64
+ return self
65
+
66
+ async def __aexit__(self, *args):
67
+ await self.close()
@@ -0,0 +1,55 @@
1
+ import warnings
2
+
3
+ import httpx
4
+ from packaging.version import Version
5
+ from typing import Optional
6
+
7
+ from ._exceptions import OutdatedSDKError
8
+ from .version import __version__
9
+ from .core import build_headers
10
+ from ._constants import DEFAULT_BASE_URL, DEFAULT_TIMEOUT
11
+
12
+
13
+ class BaseClient:
14
+ def __init__(self, api_key: str, base_url: str = DEFAULT_BASE_URL, _check_version: bool = True):
15
+ self.api_key = api_key
16
+ self.base_url = base_url
17
+ self._headers = build_headers(self.api_key)
18
+ self._timeout = DEFAULT_TIMEOUT
19
+ self._should_check_version = _check_version
20
+
21
+ def _evaluate_version(self, data: dict) -> None:
22
+ current = Version(__version__)
23
+ min_version = Version(data["min_version"])
24
+ latest_version = Version(data["latest_version"])
25
+
26
+ if current < min_version:
27
+ raise RuntimeError(
28
+ f"This version of the SDK ({__version__}) is no longer supported. "
29
+ f"Minimum required version is {min_version}. "
30
+ "Please upgrade: pip install --upgrade tontaube"
31
+ )
32
+
33
+ if current < latest_version:
34
+ warnings.warn(
35
+ f"A newer version of the SDK is available ({latest_version}). "
36
+ f"You are using {__version__}. "
37
+ "Please upgrade: pip install --upgrade tontaube",
38
+ DeprecationWarning,
39
+ stacklevel=3,
40
+ )
41
+
42
+ def _handle_response(self, response: httpx.Response) -> httpx.Response:
43
+ if response.status_code == 426:
44
+ try:
45
+ body = response.json()
46
+ message = body.get("message", "SDK upgrade required.")
47
+ upgrade_command = body.get(
48
+ "upgrade_command", "pip install --upgrade tontaube"
49
+ )
50
+ except Exception:
51
+ message = "SDK upgrade required."
52
+ upgrade_command = "pip install --upgrade tontaube"
53
+ raise OutdatedSDKError(f"{message} Upgrade with: {upgrade_command}")
54
+ response.raise_for_status()
55
+ return response
@@ -0,0 +1,67 @@
1
+ from typing import List, Optional
2
+
3
+ import httpx
4
+
5
+ from .models import Speaker, GenerateRequest, GenerateResponse
6
+ from ._base_client import BaseClient
7
+ from ._constants import DEFAULT_BASE_URL, VERSION_CHECK_TIMEOUT
8
+
9
+
10
+ class Client(BaseClient):
11
+ def __init__(self, api_key: str, base_url: str = DEFAULT_BASE_URL, **kwargs):
12
+ super().__init__(api_key, base_url, **kwargs)
13
+ self._http_client = httpx.Client(
14
+ base_url=self.base_url,
15
+ headers=self._headers,
16
+ timeout=self._timeout,
17
+ )
18
+
19
+ def check_version(self) -> None:
20
+ try:
21
+ response = self._http_client.get("/sdk-status", timeout=VERSION_CHECK_TIMEOUT)
22
+ response.raise_for_status()
23
+ self._evaluate_version(response.json())
24
+ except RuntimeError:
25
+ raise
26
+ except Exception:
27
+ return
28
+
29
+ def list_speakers(self) -> List[Speaker]:
30
+ response = self._http_client.get("/speech/speakers")
31
+ self._handle_response(response)
32
+ return [Speaker.model_validate(s) for s in response.json()]
33
+
34
+ def generate_speech(
35
+ self,
36
+ text: str,
37
+ speaker_id: str,
38
+ language: Optional[str] = None,
39
+ format: Optional[str] = None,
40
+ temperature: Optional[float] = None,
41
+ ) -> GenerateResponse:
42
+ payload = GenerateRequest(
43
+ text=text,
44
+ speaker_id=speaker_id,
45
+ language=language,
46
+ format=format,
47
+ temperature=temperature,
48
+ ).model_dump(exclude_none=True)
49
+
50
+ response = self._http_client.post("/speech/generate", json=payload)
51
+ self._handle_response(response)
52
+ return GenerateResponse(
53
+ content=response.content,
54
+ sample_rate=response.headers.get("x-sample-rate"),
55
+ audio_duration=response.headers.get("x-audio-duration"),
56
+ cost_usd=response.headers.get("x-cost-usd"),
57
+ balance_usd=response.headers.get("x-balance-usd"),
58
+ )
59
+
60
+ def close(self):
61
+ self._http_client.close()
62
+
63
+ def __enter__(self):
64
+ return self
65
+
66
+ def __exit__(self, *args):
67
+ self.close()
@@ -0,0 +1,11 @@
1
+ import platform
2
+ from .version import __version__
3
+
4
+ DEFAULT_BASE_URL = "https://api.tontaube.ai/v1"
5
+
6
+ DEFAULT_USER_AGENT = (
7
+ f"tontaube-python/{__version__} (Python/{platform.python_version()})"
8
+ )
9
+
10
+ DEFAULT_TIMEOUT = 600.0
11
+ VERSION_CHECK_TIMEOUT = 2.0
@@ -0,0 +1,2 @@
1
+ class OutdatedSDKError(Exception):
2
+ """Raised when the API returns HTTP 426 Upgrade Required."""
@@ -0,0 +1,14 @@
1
+ from typing import Optional
2
+ from ._constants import DEFAULT_USER_AGENT
3
+ from .version import __version__
4
+
5
+
6
+ def build_headers(api_key: Optional[str] = None) -> dict:
7
+ headers = {
8
+ "Content-Type": "application/json",
9
+ "User-Agent": DEFAULT_USER_AGENT,
10
+ "X-SDK-Version": __version__,
11
+ }
12
+ if api_key is not None:
13
+ headers["X-API-Key"] = api_key
14
+ return headers
@@ -0,0 +1,40 @@
1
+ from typing import Optional, List
2
+ from pydantic import BaseModel, ConfigDict, model_validator
3
+
4
+ _MAX_TEXT_LENGTH = 30_000
5
+ _ALLOWED_FORMATS = ["wav", "mp3", "opus"]
6
+
7
+ class Speaker(BaseModel):
8
+ id: str
9
+ name: str
10
+ voice_key: str
11
+ gender: Optional[str] = None
12
+ language_restrictions: Optional[List[str]] = None
13
+ voice_style: Optional[str] = None
14
+ preview_url: Optional[str] = None
15
+
16
+ class GenerateRequest(BaseModel):
17
+ text: str
18
+ speaker_id: str
19
+ language: Optional[str] = None
20
+ format: Optional[str] = None
21
+ temperature: Optional[float] = None
22
+
23
+ @model_validator(mode="after")
24
+ def validate_request(self):
25
+ if len(self.text) > _MAX_TEXT_LENGTH:
26
+ raise ValueError(f"Text length must be at most {_MAX_TEXT_LENGTH} characters")
27
+ if self.format and self.format.lower() not in _ALLOWED_FORMATS:
28
+ raise ValueError(f"Format must be one of: {', '.join(_ALLOWED_FORMATS)}")
29
+ if self.temperature and (self.temperature < 0.5 or self.temperature > 2.0):
30
+ raise ValueError("Temperature must be between 0.5 and 2.0")
31
+ return self
32
+
33
+ class GenerateResponse(BaseModel):
34
+ model_config = ConfigDict(arbitrary_types_allowed=True)
35
+
36
+ content: bytes
37
+ sample_rate: Optional[int] = None
38
+ audio_duration: Optional[float] = None
39
+ cost_usd: Optional[float] = None
40
+ balance_usd: Optional[float] = None
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.4
2
+ Name: tontaube
3
+ Version: 0.1.0
4
+ Summary: Python SDK for the Tontaube text-to-speech API
5
+ License: MIT
6
+ Project-URL: Homepage, https://tontaube.ai
7
+ Project-URL: API Reference, https://tontaube.ai/api-reference
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: httpx>=0.24
12
+ Requires-Dist: packaging>=21.0
13
+ Requires-Dist: pydantic>=2.0
14
+ Dynamic: license-file
15
+
16
+ # tontaube
17
+
18
+ Python SDK for the [Tontaube](https://tontaube.ai) text-to-speech API.
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ pip install tontaube
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ```python
29
+ import tontaube
30
+
31
+ with tontaube.Client(api_key="your-api-key") as client:
32
+ speakers = client.list_speakers()
33
+ response = client.generate_speech(
34
+ text="Tell me what we are building today, and I will get right to work.",
35
+ speaker_id=speakers[0].id,
36
+ )
37
+
38
+ with open("speech.wav", "wb") as f:
39
+ f.write(response.content)
40
+ ```
41
+
42
+ Async client is also available via `tontaube.AsyncClient`. See the [examples/](examples/) folder for more usage patterns.
43
+
44
+ For full API reference see [tontaube.ai/api-reference](https://tontaube.ai/api-reference).
@@ -0,0 +1,17 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/tontaube/__init__.py
5
+ src/tontaube/_async_client.py
6
+ src/tontaube/_base_client.py
7
+ src/tontaube/_client.py
8
+ src/tontaube/_constants.py
9
+ src/tontaube/_exceptions.py
10
+ src/tontaube/core.py
11
+ src/tontaube/models.py
12
+ src/tontaube/version.py
13
+ src/tontaube.egg-info/PKG-INFO
14
+ src/tontaube.egg-info/SOURCES.txt
15
+ src/tontaube.egg-info/dependency_links.txt
16
+ src/tontaube.egg-info/requires.txt
17
+ src/tontaube.egg-info/top_level.txt
@@ -0,0 +1,3 @@
1
+ httpx>=0.24
2
+ packaging>=21.0
3
+ pydantic>=2.0
@@ -0,0 +1 @@
1
+ tontaube