geniete-voice 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.
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Genie, Inc.
|
|
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,52 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: geniete-voice
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: GenieTé Voice Python SDK — text in, speech out for AI agents
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: tts,voice,agents,geniete,text-to-speech
|
|
8
|
+
Author: Genie, Inc.
|
|
9
|
+
Author-email: renat@geniete.com
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Requires-Dist: httpx (>=0.27.0)
|
|
16
|
+
Project-URL: Company, https://www.genieinc.com/
|
|
17
|
+
Project-URL: Documentation, https://voice.geniete.com/docs/voice/
|
|
18
|
+
Project-URL: Homepage, https://voice.geniete.com/
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# geniete-voice
|
|
22
|
+
|
|
23
|
+
Python SDK for [GenieTé Voice](https://voice.geniete.com/) — text in,
|
|
24
|
+
speech out for AI agents. One call turns words into an MP3, a hosted
|
|
25
|
+
link, or live speech on a page you leave open anywhere.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install geniete-voice
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from geniete_voice import Speaker
|
|
33
|
+
|
|
34
|
+
spk = Speaker(api_key="vk_...", speaker_id="spk_...")
|
|
35
|
+
|
|
36
|
+
spk.say("Deploy finished. All checks green.") # plays on your listen pages
|
|
37
|
+
url = spk.speak_url("Sixty-second summary ...") # hosted MP3, plays anywhere
|
|
38
|
+
mp3 = spk.speak_bytes("Hello out loud.") # raw MP3 bytes
|
|
39
|
+
|
|
40
|
+
link = spk.listen_link(ttl_seconds=86_400) # standing speaker page
|
|
41
|
+
print(link["url"]) # open on any device
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Async twin: `AsyncSpeaker`, same methods awaited.
|
|
45
|
+
|
|
46
|
+
Create speakers and API keys in the [Voice console](https://voice.geniete.com/admin/).
|
|
47
|
+
Full docs: <https://voice.geniete.com/docs/voice/>. Errors raise
|
|
48
|
+
`VoiceError` with the server's reason (`insufficient_credits`,
|
|
49
|
+
`free_daily_ceiling`, `text_too_long`, ...).
|
|
50
|
+
|
|
51
|
+
MIT © Genie, Inc.
|
|
52
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# geniete-voice
|
|
2
|
+
|
|
3
|
+
Python SDK for [GenieTé Voice](https://voice.geniete.com/) — text in,
|
|
4
|
+
speech out for AI agents. One call turns words into an MP3, a hosted
|
|
5
|
+
link, or live speech on a page you leave open anywhere.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install geniete-voice
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
from geniete_voice import Speaker
|
|
13
|
+
|
|
14
|
+
spk = Speaker(api_key="vk_...", speaker_id="spk_...")
|
|
15
|
+
|
|
16
|
+
spk.say("Deploy finished. All checks green.") # plays on your listen pages
|
|
17
|
+
url = spk.speak_url("Sixty-second summary ...") # hosted MP3, plays anywhere
|
|
18
|
+
mp3 = spk.speak_bytes("Hello out loud.") # raw MP3 bytes
|
|
19
|
+
|
|
20
|
+
link = spk.listen_link(ttl_seconds=86_400) # standing speaker page
|
|
21
|
+
print(link["url"]) # open on any device
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Async twin: `AsyncSpeaker`, same methods awaited.
|
|
25
|
+
|
|
26
|
+
Create speakers and API keys in the [Voice console](https://voice.geniete.com/admin/).
|
|
27
|
+
Full docs: <https://voice.geniete.com/docs/voice/>. Errors raise
|
|
28
|
+
`VoiceError` with the server's reason (`insufficient_credits`,
|
|
29
|
+
`free_daily_ceiling`, `text_too_long`, ...).
|
|
30
|
+
|
|
31
|
+
MIT © Genie, Inc.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Publishes to PyPI as "geniete-voice"
|
|
2
|
+
# Install: pip install geniete-voice
|
|
3
|
+
#
|
|
4
|
+
# Public package: NO GenieForge dependencies — importable name "geniete_voice".
|
|
5
|
+
[project]
|
|
6
|
+
name = "geniete-voice"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "GenieTé Voice Python SDK — text in, speech out for AI agents"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
keywords = ["tts", "voice", "agents", "geniete", "text-to-speech"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 4 - Beta",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
"httpx>=0.27.0",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://voice.geniete.com/"
|
|
25
|
+
Documentation = "https://voice.geniete.com/docs/voice/"
|
|
26
|
+
Company = "https://www.genieinc.com/"
|
|
27
|
+
|
|
28
|
+
[build-system]
|
|
29
|
+
requires = ["poetry-core"]
|
|
30
|
+
build-backend = "poetry.core.masonry.api"
|
|
31
|
+
|
|
32
|
+
[tool.poetry]
|
|
33
|
+
name = "geniete-voice"
|
|
34
|
+
version = "0.1.0"
|
|
35
|
+
description = "GenieTé Voice Python SDK"
|
|
36
|
+
authors = ["Genie, Inc. <renat@geniete.com>"]
|
|
37
|
+
packages = [{ include = "geniete_voice", from = "src" }]
|
|
38
|
+
|
|
39
|
+
[tool.poetry.dependencies]
|
|
40
|
+
python = ">=3.10"
|
|
41
|
+
httpx = ">=0.27.0"
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"""
|
|
2
|
+
GenieTé Voice SDK — text in, speech out (voice.geniete.com).
|
|
3
|
+
|
|
4
|
+
Sync:
|
|
5
|
+
from geniete_voice import Speaker
|
|
6
|
+
spk = Speaker(api_key="vk_...", speaker_id="spk_...")
|
|
7
|
+
spk.say("Deploy finished. All checks green.") # plays on listen pages
|
|
8
|
+
url = spk.speak_url("Sixty-second summary ...") # hosted MP3 link
|
|
9
|
+
mp3 = spk.speak_bytes("Hello out loud.") # raw MP3 bytes
|
|
10
|
+
|
|
11
|
+
Async: AsyncSpeaker with the same methods, awaited.
|
|
12
|
+
|
|
13
|
+
Listen pages (leave one open anywhere; every say() plays there):
|
|
14
|
+
link = spk.listen_link(ttl_seconds=86_400)
|
|
15
|
+
"""
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import uuid
|
|
19
|
+
from typing import Any, Optional
|
|
20
|
+
|
|
21
|
+
import httpx
|
|
22
|
+
|
|
23
|
+
DEFAULT_BASE_URL = "https://voice.geniete.com"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class VoiceError(RuntimeError):
|
|
27
|
+
"""API refusal with the server's reason (e.g. free_daily_ceiling,
|
|
28
|
+
insufficient_credits, text_too_long)."""
|
|
29
|
+
|
|
30
|
+
def __init__(self, reason: str, detail: Optional[dict] = None) -> None:
|
|
31
|
+
super().__init__(reason)
|
|
32
|
+
self.reason = reason
|
|
33
|
+
self.detail = detail or {}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class _Base:
|
|
37
|
+
def __init__(
|
|
38
|
+
self,
|
|
39
|
+
api_key: str,
|
|
40
|
+
speaker_id: str,
|
|
41
|
+
base_url: str = DEFAULT_BASE_URL,
|
|
42
|
+
*,
|
|
43
|
+
transport: Any = None, # test seam: httpx transport
|
|
44
|
+
) -> None:
|
|
45
|
+
self.api_key = api_key
|
|
46
|
+
self.speaker_id = speaker_id
|
|
47
|
+
self.base_url = base_url.rstrip("/")
|
|
48
|
+
self._transport = transport
|
|
49
|
+
self._headers = {
|
|
50
|
+
"Authorization": f"Bearer {api_key}",
|
|
51
|
+
"Content-Type": "application/json",
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
def _speak_body(self, text: str, voice_id: str, **extra: Any) -> dict:
|
|
55
|
+
body = {
|
|
56
|
+
"speaker_id": self.speaker_id,
|
|
57
|
+
"voice_id": voice_id,
|
|
58
|
+
"text": text,
|
|
59
|
+
"request_id": extra.pop("request_id", None) or f"sdk_{uuid.uuid4().hex[:16]}",
|
|
60
|
+
}
|
|
61
|
+
body.update(extra)
|
|
62
|
+
return body
|
|
63
|
+
|
|
64
|
+
@staticmethod
|
|
65
|
+
def _raise_for_reason(r: httpx.Response) -> None:
|
|
66
|
+
if r.status_code < 400:
|
|
67
|
+
return
|
|
68
|
+
try:
|
|
69
|
+
detail = r.json()
|
|
70
|
+
except Exception:
|
|
71
|
+
detail = {}
|
|
72
|
+
raise VoiceError(detail.get("error", f"http_{r.status_code}"), detail)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class Speaker(_Base):
|
|
76
|
+
"""Synchronous Voice client, keyed to one speaker."""
|
|
77
|
+
|
|
78
|
+
def _client(self) -> httpx.Client:
|
|
79
|
+
return httpx.Client(timeout=130.0, transport=self._transport)
|
|
80
|
+
|
|
81
|
+
def say(self, text: str, voice_id: str = "kanika", **extra: Any) -> dict:
|
|
82
|
+
"""Pump mode: speak on every open listen page; small JSON ack
|
|
83
|
+
(charged credits + characters), no audio in the response."""
|
|
84
|
+
with self._client() as c:
|
|
85
|
+
r = c.post(f"{self.base_url}/public/api/speak", headers=self._headers,
|
|
86
|
+
json=self._speak_body(text, voice_id, return_audio=False, **extra))
|
|
87
|
+
self._raise_for_reason(r)
|
|
88
|
+
return r.json()
|
|
89
|
+
|
|
90
|
+
def speak_url(self, text: str, voice_id: str = "kanika", **extra: Any) -> str:
|
|
91
|
+
"""Hosted MP3 link (kept ~1 day) — plays anywhere, no server."""
|
|
92
|
+
with self._client() as c:
|
|
93
|
+
r = c.post(f"{self.base_url}/public/api/speak", headers=self._headers,
|
|
94
|
+
json=self._speak_body(text, voice_id, deliver="url", **extra))
|
|
95
|
+
self._raise_for_reason(r)
|
|
96
|
+
return r.json()["url"]
|
|
97
|
+
|
|
98
|
+
def speak_bytes(self, text: str, voice_id: str = "kanika", **extra: Any) -> bytes:
|
|
99
|
+
"""Raw MP3 bytes in the response body."""
|
|
100
|
+
with self._client() as c:
|
|
101
|
+
r = c.post(f"{self.base_url}/public/api/speak", headers=self._headers,
|
|
102
|
+
json=self._speak_body(text, voice_id, **extra))
|
|
103
|
+
self._raise_for_reason(r)
|
|
104
|
+
return r.content
|
|
105
|
+
|
|
106
|
+
def voices(self) -> list[dict]:
|
|
107
|
+
with self._client() as c:
|
|
108
|
+
r = c.get(f"{self.base_url}/public/api/voices")
|
|
109
|
+
self._raise_for_reason(r)
|
|
110
|
+
return r.json().get("voices", [])
|
|
111
|
+
|
|
112
|
+
def listen_link(self, ttl_seconds: Optional[int] = None) -> dict:
|
|
113
|
+
"""Mint a shareable listen-page link (one open seat per link).
|
|
114
|
+
Returns {url, token, expires_in_seconds}."""
|
|
115
|
+
with self._client() as c:
|
|
116
|
+
r = c.post(
|
|
117
|
+
f"{self.base_url}/public/api/speakers/{self.speaker_id}/listen-links",
|
|
118
|
+
headers=self._headers,
|
|
119
|
+
json={"ttl_seconds": ttl_seconds} if ttl_seconds else {},
|
|
120
|
+
)
|
|
121
|
+
self._raise_for_reason(r)
|
|
122
|
+
return r.json()
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class AsyncSpeaker(_Base):
|
|
126
|
+
"""Async Voice client, keyed to one speaker."""
|
|
127
|
+
|
|
128
|
+
def _client(self) -> httpx.AsyncClient:
|
|
129
|
+
return httpx.AsyncClient(timeout=130.0, transport=self._transport)
|
|
130
|
+
|
|
131
|
+
async def say(self, text: str, voice_id: str = "kanika", **extra: Any) -> dict:
|
|
132
|
+
async with self._client() as c:
|
|
133
|
+
r = await c.post(f"{self.base_url}/public/api/speak", headers=self._headers,
|
|
134
|
+
json=self._speak_body(text, voice_id, return_audio=False, **extra))
|
|
135
|
+
self._raise_for_reason(r)
|
|
136
|
+
return r.json()
|
|
137
|
+
|
|
138
|
+
async def speak_url(self, text: str, voice_id: str = "kanika", **extra: Any) -> str:
|
|
139
|
+
async with self._client() as c:
|
|
140
|
+
r = await c.post(f"{self.base_url}/public/api/speak", headers=self._headers,
|
|
141
|
+
json=self._speak_body(text, voice_id, deliver="url", **extra))
|
|
142
|
+
self._raise_for_reason(r)
|
|
143
|
+
return r.json()["url"]
|
|
144
|
+
|
|
145
|
+
async def speak_bytes(self, text: str, voice_id: str = "kanika", **extra: Any) -> bytes:
|
|
146
|
+
async with self._client() as c:
|
|
147
|
+
r = await c.post(f"{self.base_url}/public/api/speak", headers=self._headers,
|
|
148
|
+
json=self._speak_body(text, voice_id, **extra))
|
|
149
|
+
self._raise_for_reason(r)
|
|
150
|
+
return r.content
|
|
151
|
+
|
|
152
|
+
async def voices(self) -> list[dict]:
|
|
153
|
+
async with self._client() as c:
|
|
154
|
+
r = await c.get(f"{self.base_url}/public/api/voices")
|
|
155
|
+
self._raise_for_reason(r)
|
|
156
|
+
return r.json().get("voices", [])
|
|
157
|
+
|
|
158
|
+
async def listen_link(self, ttl_seconds: Optional[int] = None) -> dict:
|
|
159
|
+
async with self._client() as c:
|
|
160
|
+
r = await c.post(
|
|
161
|
+
f"{self.base_url}/public/api/speakers/{self.speaker_id}/listen-links",
|
|
162
|
+
headers=self._headers,
|
|
163
|
+
json={"ttl_seconds": ttl_seconds} if ttl_seconds else {},
|
|
164
|
+
)
|
|
165
|
+
self._raise_for_reason(r)
|
|
166
|
+
return r.json()
|