tw-livekit 0.1.0__tar.gz → 0.2.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.
- tw_livekit-0.2.0/PKG-INFO +48 -0
- tw_livekit-0.2.0/README.md +35 -0
- {tw_livekit-0.1.0 → tw_livekit-0.2.0}/pyproject.toml +2 -2
- tw_livekit-0.2.0/src/tw_livekit/__init__.py +3 -0
- {tw_livekit-0.1.0 → tw_livekit-0.2.0}/src/tw_livekit/tts.py +52 -50
- tw_livekit-0.2.0/src/tw_livekit.egg-info/PKG-INFO +48 -0
- tw_livekit-0.1.0/PKG-INFO +0 -48
- tw_livekit-0.1.0/README.md +0 -35
- tw_livekit-0.1.0/src/tw_livekit/__init__.py +0 -3
- tw_livekit-0.1.0/src/tw_livekit.egg-info/PKG-INFO +0 -48
- {tw_livekit-0.1.0 → tw_livekit-0.2.0}/LICENSE +0 -0
- {tw_livekit-0.1.0 → tw_livekit-0.2.0}/setup.cfg +0 -0
- {tw_livekit-0.1.0 → tw_livekit-0.2.0}/src/tw_livekit.egg-info/SOURCES.txt +0 -0
- {tw_livekit-0.1.0 → tw_livekit-0.2.0}/src/tw_livekit.egg-info/dependency_links.txt +0 -0
- {tw_livekit-0.1.0 → tw_livekit-0.2.0}/src/tw_livekit.egg-info/requires.txt +0 -0
- {tw_livekit-0.1.0 → tw_livekit-0.2.0}/src/tw_livekit.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tw-livekit
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: TeenageWorks streaming TTS for LiveKit Agents
|
|
5
|
+
Author: TeenageWorks
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: livekit-agents==1.8.1
|
|
11
|
+
Requires-Dist: websockets==15.0.1
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# TW LiveKit
|
|
15
|
+
|
|
16
|
+
Streaming TeenageWorks TTS for LiveKit Agents.
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install tw-livekit==0.2.0
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from livekit.agents import AgentSession
|
|
24
|
+
from tw_livekit import TTS
|
|
25
|
+
|
|
26
|
+
tts = TTS()
|
|
27
|
+
session = AgentSession(stt=your_stt, llm=your_llm, vad=your_vad, tts=tts)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Set `TW_TTS_URL` to your provisioned `wss://` endpoint and `TW_TTS_API_KEY` to its API key in the server-side environment before starting the agent. Alternatively, pass `url` and `api_key` to `TTS()`. The endpoint must use TLS and cannot contain embedded credentials, a query or a fragment. Credentials must never be sent to the browser. Replace `your_stt`, `your_llm` and `your_vad` with your existing providers.
|
|
31
|
+
|
|
32
|
+
The server controls synthesis defaults. PCM is 48 kHz, mono, signed 16-bit. Normalization defaults ON and can be changed with `TTS(normalization=False)`; generated leading quiet is retained. Each synthesis uses a fresh authenticated WebSocket; cancellation closes it and partial speech is never automatically replayed. The adapter emits 20 ms audio frames and verifies each complete segment's byte count, SHA-256 and natural stop, followed by `done` and normal WebSocket closure.
|
|
33
|
+
|
|
34
|
+
LiveKit streams LLM text into `stream()`. Eligible punctuation releases phrases; explicit LiveKit flush/end markers release pending text. Long input is flushed at whitespace when possible, before the 1,000-character pending buffer is exceeded. The adapter sends text and receives audio concurrently. All clients share the endpoint's connection limit; the adapter does not reserve idle connections.
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
@tts.on("metrics_collected")
|
|
38
|
+
def on_metrics(m):
|
|
39
|
+
print({"first_pcm_ms": m.ttfb * 1000,
|
|
40
|
+
"setup_ms": m.acquire_time * 1000,
|
|
41
|
+
"cancelled": m.cancelled})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Streaming TTS timing starts when the first text is sent, after connection/configuration; `setup_ms` is separate. The `synthesize()` whole-text path uses LiveKit's elapsed request timing, including setup. Neither is listener-side audible onset or total conversational response latency. Leading quiet, STT endpointing, LLM generation and transport/playout contribute separately.
|
|
45
|
+
|
|
46
|
+
Requires Python 3.11+, LiveKit Agents 1.8.1 and websockets 15.0.1. On systems whose Python build lacks the OS trust-store path, set `SSL_CERT_FILE` to your system CA bundle; retain certificate verification.
|
|
47
|
+
|
|
48
|
+
The distribution name is `tw-livekit`; the Python import is `tw_livekit`. Version 0.2.0 introduces the `TTS` API and requires explicit endpoint and API-key configuration. Applications using earlier versions must update their imports and constructor arguments. The endpoint must implement the streaming protocol described above; arbitrary TTS WebSocket services are not compatible. Only this integration is included: no model weights, inference service source, private credentials or fleet tooling.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# TW LiveKit
|
|
2
|
+
|
|
3
|
+
Streaming TeenageWorks TTS for LiveKit Agents.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install tw-livekit==0.2.0
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from livekit.agents import AgentSession
|
|
11
|
+
from tw_livekit import TTS
|
|
12
|
+
|
|
13
|
+
tts = TTS()
|
|
14
|
+
session = AgentSession(stt=your_stt, llm=your_llm, vad=your_vad, tts=tts)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Set `TW_TTS_URL` to your provisioned `wss://` endpoint and `TW_TTS_API_KEY` to its API key in the server-side environment before starting the agent. Alternatively, pass `url` and `api_key` to `TTS()`. The endpoint must use TLS and cannot contain embedded credentials, a query or a fragment. Credentials must never be sent to the browser. Replace `your_stt`, `your_llm` and `your_vad` with your existing providers.
|
|
18
|
+
|
|
19
|
+
The server controls synthesis defaults. PCM is 48 kHz, mono, signed 16-bit. Normalization defaults ON and can be changed with `TTS(normalization=False)`; generated leading quiet is retained. Each synthesis uses a fresh authenticated WebSocket; cancellation closes it and partial speech is never automatically replayed. The adapter emits 20 ms audio frames and verifies each complete segment's byte count, SHA-256 and natural stop, followed by `done` and normal WebSocket closure.
|
|
20
|
+
|
|
21
|
+
LiveKit streams LLM text into `stream()`. Eligible punctuation releases phrases; explicit LiveKit flush/end markers release pending text. Long input is flushed at whitespace when possible, before the 1,000-character pending buffer is exceeded. The adapter sends text and receives audio concurrently. All clients share the endpoint's connection limit; the adapter does not reserve idle connections.
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
@tts.on("metrics_collected")
|
|
25
|
+
def on_metrics(m):
|
|
26
|
+
print({"first_pcm_ms": m.ttfb * 1000,
|
|
27
|
+
"setup_ms": m.acquire_time * 1000,
|
|
28
|
+
"cancelled": m.cancelled})
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Streaming TTS timing starts when the first text is sent, after connection/configuration; `setup_ms` is separate. The `synthesize()` whole-text path uses LiveKit's elapsed request timing, including setup. Neither is listener-side audible onset or total conversational response latency. Leading quiet, STT endpointing, LLM generation and transport/playout contribute separately.
|
|
32
|
+
|
|
33
|
+
Requires Python 3.11+, LiveKit Agents 1.8.1 and websockets 15.0.1. On systems whose Python build lacks the OS trust-store path, set `SSL_CERT_FILE` to your system CA bundle; retain certificate verification.
|
|
34
|
+
|
|
35
|
+
The distribution name is `tw-livekit`; the Python import is `tw_livekit`. Version 0.2.0 introduces the `TTS` API and requires explicit endpoint and API-key configuration. Applications using earlier versions must update their imports and constructor arguments. The endpoint must implement the streaming protocol described above; arbitrary TTS WebSocket services are not compatible. Only this integration is included: no model weights, inference service source, private credentials or fleet tooling.
|
|
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "tw-livekit"
|
|
7
|
-
version = "0.
|
|
8
|
-
description = "TeenageWorks
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "TeenageWorks streaming TTS for LiveKit Agents"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
11
11
|
license = "MIT"
|
|
@@ -5,6 +5,7 @@ import os
|
|
|
5
5
|
import ssl
|
|
6
6
|
import time
|
|
7
7
|
import uuid
|
|
8
|
+
from urllib.parse import urlsplit
|
|
8
9
|
|
|
9
10
|
from livekit.agents import (
|
|
10
11
|
APIConnectOptions,
|
|
@@ -15,65 +16,69 @@ from livekit.agents import (
|
|
|
15
16
|
from websockets.asyncio.client import connect
|
|
16
17
|
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
VOICES = {
|
|
20
|
-
'Bunty': 'voice_407baf0b8d207300bdfd326aef6cacb9',
|
|
21
|
-
'Pari M': 'voice_47814eb3b3984421949ce9a5169fd901',
|
|
22
|
-
'Amelia': 'voice_bfc22e10bc1b493089f57bc4f0103d9f',
|
|
23
|
-
'Brittney': 'voice_d873dea37b254c1a95310eaa1db30f7d',
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class _BlueConnect(connect):
|
|
19
|
+
class _Connect(connect):
|
|
28
20
|
def process_redirect(self, exc):
|
|
29
21
|
return exc
|
|
30
22
|
|
|
31
23
|
|
|
32
|
-
class
|
|
24
|
+
class TTS(tts.TTS):
|
|
33
25
|
def __init__(
|
|
34
|
-
self, *,
|
|
26
|
+
self, *, url=None, api_key=None, normalization=True,
|
|
35
27
|
):
|
|
36
|
-
|
|
28
|
+
endpoint = url if url is not None else os.environ.get('TW_TTS_URL', '')
|
|
29
|
+
if not isinstance(endpoint, str) or not endpoint or any(ord(c) <= 32 or ord(c) == 127 for c in endpoint):
|
|
30
|
+
raise ValueError('Set url or TW_TTS_URL to a secure wss endpoint')
|
|
31
|
+
try:
|
|
32
|
+
parsed = urlsplit(endpoint)
|
|
33
|
+
port = parsed.port
|
|
34
|
+
valid = (parsed.scheme == 'wss' and parsed.hostname
|
|
35
|
+
and parsed.username is None and parsed.password is None
|
|
36
|
+
and not parsed.query and not parsed.fragment
|
|
37
|
+
and (port is None or 0 < port <= 65535))
|
|
38
|
+
except ValueError:
|
|
39
|
+
valid = False
|
|
40
|
+
if not valid:
|
|
41
|
+
raise ValueError('TTS endpoint must use wss with a host and no embedded credentials, query or fragment')
|
|
42
|
+
key = api_key if api_key is not None else os.environ.get('TW_TTS_API_KEY', '')
|
|
43
|
+
if not isinstance(key, str):
|
|
44
|
+
raise ValueError('Set api_key or TW_TTS_API_KEY to the server API key')
|
|
37
45
|
key = key.strip()
|
|
38
46
|
if not key or any(ord(c) <= 32 or ord(c) >= 127 for c in key):
|
|
39
|
-
raise ValueError('Set
|
|
40
|
-
if voice not in VOICES or language not in ('en', 'hi', 'hinglish'):
|
|
41
|
-
raise ValueError('Unsupported voice or language')
|
|
47
|
+
raise ValueError('Set api_key or TW_TTS_API_KEY to the server API key')
|
|
42
48
|
if type(normalization) is not bool:
|
|
43
49
|
raise ValueError('normalization must be boolean')
|
|
44
50
|
super().__init__(
|
|
45
51
|
capabilities=tts.TTSCapabilities(streaming=True),
|
|
46
52
|
sample_rate=48000, num_channels=1,
|
|
47
53
|
)
|
|
48
|
-
self.
|
|
49
|
-
self.
|
|
50
|
-
self.
|
|
51
|
-
self._blue_normalization = normalization
|
|
54
|
+
self._url = endpoint
|
|
55
|
+
self._api_key = key
|
|
56
|
+
self._normalization = normalization
|
|
52
57
|
|
|
53
58
|
@property
|
|
54
59
|
def model(self):
|
|
55
|
-
return '
|
|
60
|
+
return 'tts'
|
|
56
61
|
|
|
57
62
|
@property
|
|
58
63
|
def provider(self):
|
|
59
|
-
return 'TeenageWorks
|
|
64
|
+
return 'TeenageWorks'
|
|
60
65
|
|
|
61
66
|
def stream(self, *, conn_options=DEFAULT_API_CONNECT_OPTIONS):
|
|
62
67
|
options = APIConnectOptions(max_retry=0, timeout=conn_options.timeout)
|
|
63
|
-
return
|
|
68
|
+
return _Stream(tts=self, conn_options=options)
|
|
64
69
|
|
|
65
70
|
def synthesize(self, text, *, conn_options=DEFAULT_API_CONNECT_OPTIONS):
|
|
66
71
|
options = APIConnectOptions(max_retry=0, timeout=conn_options.timeout)
|
|
67
|
-
return
|
|
72
|
+
return _ChunkedStream(tts=self, input_text=text, conn_options=options)
|
|
68
73
|
|
|
69
74
|
|
|
70
|
-
class
|
|
75
|
+
class _ChunkedStream(tts.ChunkedStream):
|
|
71
76
|
async def _run(self, output_emitter):
|
|
72
77
|
output_emitter.initialize(
|
|
73
78
|
request_id=uuid.uuid4().hex, sample_rate=48000, num_channels=1,
|
|
74
79
|
mime_type='audio/pcm', frame_size_ms=20,
|
|
75
80
|
)
|
|
76
|
-
async with
|
|
81
|
+
async with _Stream(
|
|
77
82
|
tts=self._tts, conn_options=self._conn_options, emit_metrics=False,
|
|
78
83
|
) as stream:
|
|
79
84
|
stream.push_text(self._input_text)
|
|
@@ -83,13 +88,13 @@ class _BlueChunkedStream(tts.ChunkedStream):
|
|
|
83
88
|
output_emitter.push(event.frame.data.tobytes())
|
|
84
89
|
|
|
85
90
|
|
|
86
|
-
class
|
|
91
|
+
class _Stream(tts.SynthesizeStream):
|
|
87
92
|
def __init__(self, *, tts, conn_options, emit_metrics=True):
|
|
88
|
-
self.
|
|
93
|
+
self._emit_usage_metrics = emit_metrics
|
|
89
94
|
super().__init__(tts=tts, conn_options=conn_options)
|
|
90
95
|
|
|
91
96
|
async def _metrics_monitor_task(self, event_aiter):
|
|
92
|
-
if self.
|
|
97
|
+
if self._emit_usage_metrics:
|
|
93
98
|
await super()._metrics_monitor_task(event_aiter)
|
|
94
99
|
else:
|
|
95
100
|
async for event in event_aiter:
|
|
@@ -114,9 +119,9 @@ class _BlueStream(tts.SynthesizeStream):
|
|
|
114
119
|
return raw if isinstance(raw, bytes) else json.loads(raw)
|
|
115
120
|
|
|
116
121
|
try:
|
|
117
|
-
async with
|
|
118
|
-
|
|
119
|
-
additional_headers={'Authorization': 'Bearer ' + self._tts.
|
|
122
|
+
async with _Connect(
|
|
123
|
+
self._tts._url, ssl=tls,
|
|
124
|
+
additional_headers={'Authorization': 'Bearer ' + self._tts._api_key},
|
|
120
125
|
origin=None, compression=None, proxy=None,
|
|
121
126
|
open_timeout=self._conn_options.timeout, close_timeout=5,
|
|
122
127
|
max_size=2**20, max_queue=4,
|
|
@@ -124,19 +129,16 @@ class _BlueStream(tts.SynthesizeStream):
|
|
|
124
129
|
ready = await event(ws)
|
|
125
130
|
if (not isinstance(ready, dict) or ready.get('type') != 'ready'
|
|
126
131
|
or (ready.get('format'), ready.get('sample_rate'), ready.get('channels'))
|
|
127
|
-
!= ('s16le', 48000, 1)
|
|
128
|
-
|
|
129
|
-
raise RuntimeError('Unexpected Blue ready event')
|
|
132
|
+
!= ('s16le', 48000, 1)):
|
|
133
|
+
raise RuntimeError('Unexpected TTS ready event')
|
|
130
134
|
await ws.send(json.dumps({
|
|
131
|
-
'type': 'configure', '
|
|
132
|
-
'
|
|
133
|
-
'normalization': self._tts._blue_normalization,
|
|
135
|
+
'type': 'configure', 'reset': True,
|
|
136
|
+
'normalization': self._tts._normalization,
|
|
134
137
|
}))
|
|
135
138
|
configured = await event(ws)
|
|
136
139
|
if (not isinstance(configured, dict) or configured.get('type') != 'configured'
|
|
137
|
-
or configured.get('
|
|
138
|
-
|
|
139
|
-
raise RuntimeError('Blue configuration refused')
|
|
140
|
+
or configured.get('normalization') is not self._tts._normalization):
|
|
141
|
+
raise RuntimeError('TTS configuration refused')
|
|
140
142
|
self._acquire_time = time.perf_counter() - acquire_started
|
|
141
143
|
|
|
142
144
|
async def send():
|
|
@@ -196,13 +198,13 @@ class _BlueStream(tts.SynthesizeStream):
|
|
|
196
198
|
value = await next_response()
|
|
197
199
|
if isinstance(value, bytes):
|
|
198
200
|
if current is None or len(value) % 2:
|
|
199
|
-
raise RuntimeError('Unexpected
|
|
201
|
+
raise RuntimeError('Unexpected TTS PCM')
|
|
200
202
|
current['hash'].update(value)
|
|
201
203
|
current['bytes'] += len(value)
|
|
202
204
|
output_emitter.push(value)
|
|
203
205
|
elif value.get('type') == 'segment_start':
|
|
204
206
|
if current is not None or value['id'] in seen:
|
|
205
|
-
raise RuntimeError('Unexpected
|
|
207
|
+
raise RuntimeError('Unexpected TTS segment ordering')
|
|
206
208
|
seen.add(value['id'])
|
|
207
209
|
current = {'id': value['id'], 'bytes': 0, 'hash': hashlib.sha256()}
|
|
208
210
|
elif value.get('type') == 'segment_done':
|
|
@@ -210,21 +212,21 @@ class _BlueStream(tts.SynthesizeStream):
|
|
|
210
212
|
or not current['bytes'] or current['bytes'] != value['bytes']
|
|
211
213
|
or current['hash'].hexdigest() != value['sha256']
|
|
212
214
|
or value.get('natural_stop') is not True):
|
|
213
|
-
raise RuntimeError('
|
|
215
|
+
raise RuntimeError('TTS PCM integrity or native-stop failure')
|
|
214
216
|
current = None
|
|
215
217
|
completed += 1
|
|
216
218
|
elif value.get('type') == 'done':
|
|
217
219
|
if current is not None or (meaningful and not completed):
|
|
218
|
-
raise RuntimeError('Incomplete
|
|
220
|
+
raise RuntimeError('Incomplete TTS stream')
|
|
219
221
|
await asyncio.wait_for(ws.wait_closed(), self._conn_options.timeout)
|
|
220
222
|
if ws.close_code != 1000:
|
|
221
|
-
raise RuntimeError('Abnormal
|
|
223
|
+
raise RuntimeError('Abnormal TTS WebSocket close')
|
|
222
224
|
output_emitter.end_segment()
|
|
223
225
|
return
|
|
224
226
|
elif value.get('type') == 'error':
|
|
225
|
-
raise RuntimeError('
|
|
227
|
+
raise RuntimeError('TTS server error: ' + str(value.get('code')))
|
|
226
228
|
else:
|
|
227
|
-
raise RuntimeError('Unexpected
|
|
229
|
+
raise RuntimeError('Unexpected TTS event')
|
|
228
230
|
|
|
229
231
|
input_done_wait = asyncio.create_task(input_done.wait())
|
|
230
232
|
sender = asyncio.create_task(send())
|
|
@@ -238,5 +240,5 @@ class _BlueStream(tts.SynthesizeStream):
|
|
|
238
240
|
except asyncio.CancelledError:
|
|
239
241
|
raise
|
|
240
242
|
except Exception as error:
|
|
241
|
-
message = str(error).replace(self._tts.
|
|
242
|
-
raise APIError('
|
|
243
|
+
message = str(error).replace(self._tts._api_key, '[REDACTED]')
|
|
244
|
+
raise APIError('TTS WebSocket failed: ' + message, retryable=False) from None
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tw-livekit
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: TeenageWorks streaming TTS for LiveKit Agents
|
|
5
|
+
Author: TeenageWorks
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: livekit-agents==1.8.1
|
|
11
|
+
Requires-Dist: websockets==15.0.1
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# TW LiveKit
|
|
15
|
+
|
|
16
|
+
Streaming TeenageWorks TTS for LiveKit Agents.
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install tw-livekit==0.2.0
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from livekit.agents import AgentSession
|
|
24
|
+
from tw_livekit import TTS
|
|
25
|
+
|
|
26
|
+
tts = TTS()
|
|
27
|
+
session = AgentSession(stt=your_stt, llm=your_llm, vad=your_vad, tts=tts)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Set `TW_TTS_URL` to your provisioned `wss://` endpoint and `TW_TTS_API_KEY` to its API key in the server-side environment before starting the agent. Alternatively, pass `url` and `api_key` to `TTS()`. The endpoint must use TLS and cannot contain embedded credentials, a query or a fragment. Credentials must never be sent to the browser. Replace `your_stt`, `your_llm` and `your_vad` with your existing providers.
|
|
31
|
+
|
|
32
|
+
The server controls synthesis defaults. PCM is 48 kHz, mono, signed 16-bit. Normalization defaults ON and can be changed with `TTS(normalization=False)`; generated leading quiet is retained. Each synthesis uses a fresh authenticated WebSocket; cancellation closes it and partial speech is never automatically replayed. The adapter emits 20 ms audio frames and verifies each complete segment's byte count, SHA-256 and natural stop, followed by `done` and normal WebSocket closure.
|
|
33
|
+
|
|
34
|
+
LiveKit streams LLM text into `stream()`. Eligible punctuation releases phrases; explicit LiveKit flush/end markers release pending text. Long input is flushed at whitespace when possible, before the 1,000-character pending buffer is exceeded. The adapter sends text and receives audio concurrently. All clients share the endpoint's connection limit; the adapter does not reserve idle connections.
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
@tts.on("metrics_collected")
|
|
38
|
+
def on_metrics(m):
|
|
39
|
+
print({"first_pcm_ms": m.ttfb * 1000,
|
|
40
|
+
"setup_ms": m.acquire_time * 1000,
|
|
41
|
+
"cancelled": m.cancelled})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Streaming TTS timing starts when the first text is sent, after connection/configuration; `setup_ms` is separate. The `synthesize()` whole-text path uses LiveKit's elapsed request timing, including setup. Neither is listener-side audible onset or total conversational response latency. Leading quiet, STT endpointing, LLM generation and transport/playout contribute separately.
|
|
45
|
+
|
|
46
|
+
Requires Python 3.11+, LiveKit Agents 1.8.1 and websockets 15.0.1. On systems whose Python build lacks the OS trust-store path, set `SSL_CERT_FILE` to your system CA bundle; retain certificate verification.
|
|
47
|
+
|
|
48
|
+
The distribution name is `tw-livekit`; the Python import is `tw_livekit`. Version 0.2.0 introduces the `TTS` API and requires explicit endpoint and API-key configuration. Applications using earlier versions must update their imports and constructor arguments. The endpoint must implement the streaming protocol described above; arbitrary TTS WebSocket services are not compatible. Only this integration is included: no model weights, inference service source, private credentials or fleet tooling.
|
tw_livekit-0.1.0/PKG-INFO
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: tw-livekit
|
|
3
|
-
Version: 0.1.0
|
|
4
|
-
Summary: TeenageWorks Blue streaming TTS for LiveKit Agents
|
|
5
|
-
Author: TeenageWorks
|
|
6
|
-
License-Expression: MIT
|
|
7
|
-
Requires-Python: >=3.11
|
|
8
|
-
Description-Content-Type: text/markdown
|
|
9
|
-
License-File: LICENSE
|
|
10
|
-
Requires-Dist: livekit-agents==1.8.1
|
|
11
|
-
Requires-Dist: websockets==15.0.1
|
|
12
|
-
Dynamic: license-file
|
|
13
|
-
|
|
14
|
-
# TW LiveKit
|
|
15
|
-
|
|
16
|
-
Streaming TeenageWorks Blue TTS for LiveKit Agents.
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
pip install tw-livekit
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
```python
|
|
23
|
-
from livekit.agents import AgentSession
|
|
24
|
-
from tw_livekit import BlueTTS
|
|
25
|
-
|
|
26
|
-
tts = BlueTTS(voice="Amelia", language="hinglish", normalization=True)
|
|
27
|
-
session = AgentSession(stt=your_stt, llm=your_llm, vad=your_vad, tts=tts)
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Replace `your_stt`, `your_llm` and `your_vad` with your existing providers. Set the main Blue key in the server-side environment variable `BLUE_TTS_API_KEY`. Credentials must never be sent to the browser.
|
|
31
|
-
|
|
32
|
-
Voices: Bunty, Pari M, Amelia, Brittney. Languages: `en`, `hi`, `hinglish`. PCM: 48 kHz, mono, signed 16-bit. Normalization defaults ON; generated leading quiet is retained. Each synthesis uses a fresh authenticated WebSocket; cancellation closes it and partial speech is never automatically replayed. The adapter emits 20 ms audio frames and verifies each complete Blue segment's byte count, SHA-256 and natural stop, followed by `done` and normal WebSocket closure.
|
|
33
|
-
|
|
34
|
-
LiveKit streams LLM text into `stream()`. Eligible punctuation releases Blue phrases; explicit LiveKit flush/end markers release pending text. Long input is flushed at whitespace when possible, before Blue's 1,000-character pending buffer is exceeded. The adapter sends text and receives audio concurrently. All clients share the endpoint's connection limit; the adapter does not reserve idle connections.
|
|
35
|
-
|
|
36
|
-
```python
|
|
37
|
-
@tts.on("metrics_collected")
|
|
38
|
-
def on_metrics(m):
|
|
39
|
-
print({"first_pcm_ms": m.ttfb * 1000,
|
|
40
|
-
"setup_ms": m.acquire_time * 1000,
|
|
41
|
-
"cancelled": m.cancelled})
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Streaming TTS timing starts when the first text is sent, after connection/configuration; `setup_ms` is separate. The `synthesize()` whole-text path uses LiveKit's elapsed request timing, including setup. Neither is listener-side audible onset or total conversational response latency. Leading quiet, STT endpointing, LLM generation and transport/playout contribute separately.
|
|
45
|
-
|
|
46
|
-
Requires Python 3.11+, LiveKit Agents 1.8.1 and websockets 15.0.1. On systems whose Python build lacks the OS trust-store path, set `SSL_CERT_FILE` to your system CA bundle; retain certificate verification.
|
|
47
|
-
|
|
48
|
-
The distribution name is `tw-livekit`; the Python import is `tw_livekit`. Only this integration is included: no model weights, inference service source, private credentials or fleet tooling.
|
tw_livekit-0.1.0/README.md
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# TW LiveKit
|
|
2
|
-
|
|
3
|
-
Streaming TeenageWorks Blue TTS for LiveKit Agents.
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
pip install tw-livekit
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
```python
|
|
10
|
-
from livekit.agents import AgentSession
|
|
11
|
-
from tw_livekit import BlueTTS
|
|
12
|
-
|
|
13
|
-
tts = BlueTTS(voice="Amelia", language="hinglish", normalization=True)
|
|
14
|
-
session = AgentSession(stt=your_stt, llm=your_llm, vad=your_vad, tts=tts)
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Replace `your_stt`, `your_llm` and `your_vad` with your existing providers. Set the main Blue key in the server-side environment variable `BLUE_TTS_API_KEY`. Credentials must never be sent to the browser.
|
|
18
|
-
|
|
19
|
-
Voices: Bunty, Pari M, Amelia, Brittney. Languages: `en`, `hi`, `hinglish`. PCM: 48 kHz, mono, signed 16-bit. Normalization defaults ON; generated leading quiet is retained. Each synthesis uses a fresh authenticated WebSocket; cancellation closes it and partial speech is never automatically replayed. The adapter emits 20 ms audio frames and verifies each complete Blue segment's byte count, SHA-256 and natural stop, followed by `done` and normal WebSocket closure.
|
|
20
|
-
|
|
21
|
-
LiveKit streams LLM text into `stream()`. Eligible punctuation releases Blue phrases; explicit LiveKit flush/end markers release pending text. Long input is flushed at whitespace when possible, before Blue's 1,000-character pending buffer is exceeded. The adapter sends text and receives audio concurrently. All clients share the endpoint's connection limit; the adapter does not reserve idle connections.
|
|
22
|
-
|
|
23
|
-
```python
|
|
24
|
-
@tts.on("metrics_collected")
|
|
25
|
-
def on_metrics(m):
|
|
26
|
-
print({"first_pcm_ms": m.ttfb * 1000,
|
|
27
|
-
"setup_ms": m.acquire_time * 1000,
|
|
28
|
-
"cancelled": m.cancelled})
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Streaming TTS timing starts when the first text is sent, after connection/configuration; `setup_ms` is separate. The `synthesize()` whole-text path uses LiveKit's elapsed request timing, including setup. Neither is listener-side audible onset or total conversational response latency. Leading quiet, STT endpointing, LLM generation and transport/playout contribute separately.
|
|
32
|
-
|
|
33
|
-
Requires Python 3.11+, LiveKit Agents 1.8.1 and websockets 15.0.1. On systems whose Python build lacks the OS trust-store path, set `SSL_CERT_FILE` to your system CA bundle; retain certificate verification.
|
|
34
|
-
|
|
35
|
-
The distribution name is `tw-livekit`; the Python import is `tw_livekit`. Only this integration is included: no model weights, inference service source, private credentials or fleet tooling.
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: tw-livekit
|
|
3
|
-
Version: 0.1.0
|
|
4
|
-
Summary: TeenageWorks Blue streaming TTS for LiveKit Agents
|
|
5
|
-
Author: TeenageWorks
|
|
6
|
-
License-Expression: MIT
|
|
7
|
-
Requires-Python: >=3.11
|
|
8
|
-
Description-Content-Type: text/markdown
|
|
9
|
-
License-File: LICENSE
|
|
10
|
-
Requires-Dist: livekit-agents==1.8.1
|
|
11
|
-
Requires-Dist: websockets==15.0.1
|
|
12
|
-
Dynamic: license-file
|
|
13
|
-
|
|
14
|
-
# TW LiveKit
|
|
15
|
-
|
|
16
|
-
Streaming TeenageWorks Blue TTS for LiveKit Agents.
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
pip install tw-livekit
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
```python
|
|
23
|
-
from livekit.agents import AgentSession
|
|
24
|
-
from tw_livekit import BlueTTS
|
|
25
|
-
|
|
26
|
-
tts = BlueTTS(voice="Amelia", language="hinglish", normalization=True)
|
|
27
|
-
session = AgentSession(stt=your_stt, llm=your_llm, vad=your_vad, tts=tts)
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Replace `your_stt`, `your_llm` and `your_vad` with your existing providers. Set the main Blue key in the server-side environment variable `BLUE_TTS_API_KEY`. Credentials must never be sent to the browser.
|
|
31
|
-
|
|
32
|
-
Voices: Bunty, Pari M, Amelia, Brittney. Languages: `en`, `hi`, `hinglish`. PCM: 48 kHz, mono, signed 16-bit. Normalization defaults ON; generated leading quiet is retained. Each synthesis uses a fresh authenticated WebSocket; cancellation closes it and partial speech is never automatically replayed. The adapter emits 20 ms audio frames and verifies each complete Blue segment's byte count, SHA-256 and natural stop, followed by `done` and normal WebSocket closure.
|
|
33
|
-
|
|
34
|
-
LiveKit streams LLM text into `stream()`. Eligible punctuation releases Blue phrases; explicit LiveKit flush/end markers release pending text. Long input is flushed at whitespace when possible, before Blue's 1,000-character pending buffer is exceeded. The adapter sends text and receives audio concurrently. All clients share the endpoint's connection limit; the adapter does not reserve idle connections.
|
|
35
|
-
|
|
36
|
-
```python
|
|
37
|
-
@tts.on("metrics_collected")
|
|
38
|
-
def on_metrics(m):
|
|
39
|
-
print({"first_pcm_ms": m.ttfb * 1000,
|
|
40
|
-
"setup_ms": m.acquire_time * 1000,
|
|
41
|
-
"cancelled": m.cancelled})
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Streaming TTS timing starts when the first text is sent, after connection/configuration; `setup_ms` is separate. The `synthesize()` whole-text path uses LiveKit's elapsed request timing, including setup. Neither is listener-side audible onset or total conversational response latency. Leading quiet, STT endpointing, LLM generation and transport/playout contribute separately.
|
|
45
|
-
|
|
46
|
-
Requires Python 3.11+, LiveKit Agents 1.8.1 and websockets 15.0.1. On systems whose Python build lacks the OS trust-store path, set `SSL_CERT_FILE` to your system CA bundle; retain certificate verification.
|
|
47
|
-
|
|
48
|
-
The distribution name is `tw-livekit`; the Python import is `tw_livekit`. Only this integration is included: no model weights, inference service source, private credentials or fleet tooling.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|