@sathamai/livekit-plugin 0.0.0-stage → 0.1.2

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.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,209 @@
1
- # Temporary Holding Version
1
+ # @sathamai/livekit-plugin
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ satham's realtime speech-to-speech model (satham-1) as a `RealtimeModel` for LiveKit Agents in Node.js
4
+ (agents-js). Your LiveKit agent keeps its own instructions and tools; satham hears the caller, ends
5
+ turns, replies in speech and handles barge-in, so the `voice.AgentSession` needs no STT, LLM, TTS or
6
+ VAD. The options follow LiveKit's OpenAI `RealtimeModel`, so moving an agent from OpenAI to satham is
7
+ mostly a one-line change. For a session with its own STT and LLM, `TTS` speaks with kural-1, satham's
8
+ text-to-speech model ([Text to speech](#text-to-speech)).
9
+
10
+ Works with `@livekit/agents` 1.10 and `@livekit/rtc-node` 1.2; Node.js 20+.
11
+
12
+ ```sh
13
+ npm install @sathamai/livekit-plugin @livekit/agents @livekit/rtc-node
14
+ ```
15
+
16
+ ## Use
17
+
18
+ You pass your satham endpoint and API key (or set `SATHAM_URL` and `SATHAM_API_KEY`); there is no
19
+ default server.
20
+
21
+ ```ts
22
+ import { fileURLToPath } from 'node:url';
23
+ import { cli, defineAgent, getJobContext, type JobContext, llm, ServerOptions, voice } from '@livekit/agents';
24
+ import * as satham from '@sathamai/livekit-plugin';
25
+ import { z } from 'zod';
26
+
27
+ const endCall = llm.tool({
28
+ description: 'End the call when the conversation is over. Say a short goodbye in the same turn.',
29
+ parameters: z.object({ reason: z.string().optional() }),
30
+ execute: async (_args, { ctx }) => {
31
+ await ctx.waitForPlayout(); // let the goodbye finish
32
+ await getJobContext().deleteRoom(); // returning nothing asks for no reply
33
+ },
34
+ });
35
+
36
+ export default defineAgent({
37
+ entry: async (ctx: JobContext) => {
38
+ await ctx.connect();
39
+ const session = new voice.AgentSession({
40
+ // was: new openai.realtime.RealtimeModel({ voice: ... })
41
+ llm: new satham.RealtimeModel({
42
+ url: process.env.SATHAM_URL,
43
+ apiKey: process.env.SATHAM_API_KEY,
44
+ greeting: 'Hello, this is Asha from Example Homes. Is this a good time?',
45
+ language: 'en',
46
+ languageSwitch: 'auto',
47
+ }),
48
+ });
49
+ // The agent's role and tools are satham's instructions and tools, as they stand.
50
+ const agent = new voice.Agent({
51
+ instructions: 'You are Asha, who books site visits for Example Homes.',
52
+ tools: { end_call: endCall },
53
+ });
54
+ await session.start({ agent, room: ctx.room });
55
+ },
56
+ });
57
+
58
+ cli.runApp(new ServerOptions({ agent: fileURLToPath(import.meta.url) }));
59
+ ```
60
+
61
+ - **Instructions and tools.** The LiveKit agent's instructions become the call's instructions and its
62
+ `llm.tool()`s the call's tools, with nothing else to set. Both can change mid-call.
63
+ - **The opening and fixed words.** With `greeting`, the agent says it first. Otherwise
64
+ `session.generateReply({ instructions })` asks for a reply now (satham's `response.create`), and the
65
+ realtime session's `say(text)` speaks fixed words in the call's voice (`response.say`) with no TTS.
66
+ agents-js 1.10's `AgentSession.say()` needs a TTS for realtime models, so call `say()` on the realtime
67
+ session itself. With neither, the caller speaks first.
68
+ - **Mid-call changes.** `model.updateOptions({...})` changes any control on every live call;
69
+ `RealtimeSession.updateOptions` changes one call.
70
+ - **Language changes** are emitted as `session_updated` (`{ language, reason }`, the reason being
71
+ `caller`, `reply` or `client`).
72
+
73
+ ## From OpenAI RealtimeModel to satham
74
+
75
+ <!-- openai -->
76
+ | OpenAI `RealtimeModel` | satham `RealtimeModel` | Supported | Notes |
77
+ | --- | --- | --- | --- |
78
+ | `model` | `model` | yes | default `"satham-1"` |
79
+ | `voice` | `voice` | yes | a satham voice name, or a cloned voice's id |
80
+ | `modalities` | `modalities` | yes | `["audio", "text"]`, `["audio"]`, or `["text"]`, which hands the words to the session's TTS as OpenAI's text mode does |
81
+ | `temperature` | `temperature` | yes | |
82
+ | `turnDetection` | `turnDetection` | yes | `server_vad` and `semantic_vad` are both satham's endpointing; `None`/`null` leaves turns to LiveKit; satham adds `barge_in`, `continue_within_ms`, ... |
83
+ | `inputAudioNoiseReduction` | `inputAudioNoiseReduction` | yes | `near_field` or `far_field`; `"none"` turns it off, and null keeps the server's default (on); satham adds `strength_db` and `apply_to_transcription` |
84
+ | `inputAudioTranscription` | `inputAudioTranscription` | partly | `enabled` and `code_mixed`; satham transcribes with its own models, so OpenAI's `model` and `prompt` are ignored |
85
+ | `maxResponseOutputTokens` | `maxResponseOutputTokens` | yes | or `"inf"` |
86
+ | `speed` | `speed` | yes | |
87
+ | `toolChoice` | `toolChoice` | yes | preview: needs a server with tool support |
88
+ | `apiKey` | `apiKey` | yes | your satham key |
89
+ | `baseURL` | `url` | yes | your satham endpoint |
90
+ | Agent instructions | Agent instructions | yes | can change mid-call |
91
+ | `generateReply()` | `generateReply()` | yes | `response.create`; `instructions` guide that reply alone |
92
+ | `say()` | `RealtimeSession.say()` | yes | `response.say`, no TTS needed (agents-js: call it on the realtime session) |
93
+ | tracing, reasoning | - | no | not applicable |
94
+ | azureDeployment, entraToken, apiVersion | - | no | not applicable |
95
+ | maxSessionDuration, connOptions | - | no | `connect_timeout` / `connectTimeoutMs` instead |
96
+ <!-- /openai -->
97
+
98
+ ## Controls
99
+
100
+ Every option of `new RealtimeModel({...})` and `updateOptions({...})` besides `url`, `apiKey` and
101
+ `connectTimeoutMs`. `modalities`, `turnDetection` and `inputAudioTranscription` also decide what the
102
+ model tells LiveKit it does, so they are fixed for a model once made. Controls you leave out are not
103
+ sent; values are checked against these ranges, or the server's from `GET /v1/info`.
104
+
105
+ The controls marked "needs session controls" need a satham server with session controls (its
106
+ `GET /v1/info` lists `controls`, as the server does since 2026-11-16); an older server refuses them
107
+ when the call starts. `greeting` and `agent` belong to the start of a call. Setting
108
+ `input_audio_noise_reduction`'s `mode` alone resets `strength_db` to that mode's preset, so send both
109
+ to keep a custom strength; `null` leaves noise reduction at the server's default (on), and `'none'`
110
+ turns it off. `agent` is an optional
111
+ preset on the server and is not needed.
112
+
113
+ <!-- controls -->
114
+ | Option | Range | Default | OpenAI equivalent | Notes |
115
+ | --- | --- | --- | --- | --- |
116
+ | `instructions` | text, up to 16000 characters | none | - | the agent's role; from the LiveKit agent or Pipecat context in the adapters |
117
+ | `greeting` | text, up to 1000 characters | none | - | said first; without one the caller speaks first |
118
+ | `tools` | up to 128 functions | none | - | preview: needs a server with tool support |
119
+ | `toolChoice` | see notes | "auto" | `toolChoice` | "auto", "none", "required" or one function |
120
+ | `agent` | text, up to 64 characters | none | - | optional: a preset agent on the server, such as a demo's |
121
+ | `model` | text, up to 64 characters | "satham-1" | `model` | "satham-1" only today; needs session controls |
122
+ | `modalities` | list | ["audio", "text"] | `modalities` | ["audio", "text"], ["audio"], or ["text"]: words only, for your own TTS; needs session controls |
123
+ | `language` | `auto`, `hi`, `ta`, `te`, `kn`, `bn`, `pa`, `en` | "auto" | - | |
124
+ | `languageSwitch` | `auto`, `off`, or `null` | "auto" | - | |
125
+ | `voiceOnLanguageSwitch` | `keep`, `native`, or `null` | "keep" | - | |
126
+ | `turnDetection.enabled` | true / false | true | `turnDetection: null` | false (or turn_detection=None): the client ends each turn; needs session controls |
127
+ | `turnDetection.type` | `server_vad`, `semantic_vad` | "server_vad" | `turnDetection.type` | needs session controls |
128
+ | `turnDetection.threshold` | 0.1 to 0.95 | 0.5 | `turnDetection.threshold` | the speech detector's threshold; needs session controls |
129
+ | `turnDetection.eagerness` | `auto`, `low`, `medium`, `high` | "auto" | `turnDetection.eagerness` | semantic_vad's end-of-turn wait; needs session controls |
130
+ | `turnDetection.prefix_padding_ms` | 0 to 1000 | 300 | `turnDetection.prefix_padding_ms` | needs session controls |
131
+ | `turnDetection.min_speech_ms` | 50 to 1000 | 100 | - | needs session controls |
132
+ | `turnDetection.silence_duration_ms` | 150 to 2000 | 350 | `turnDetection.silence_duration_ms` | server_vad's end-of-turn wait; needs session controls |
133
+ | `turnDetection.create_response` | true / false | true | `turnDetection.create_response` | answer each turn at once; needs session controls |
134
+ | `turnDetection.interrupt_response` | true / false | true | `turnDetection.interrupt_response` | barge-in on or off; needs session controls |
135
+ | `turnDetection.barge_in.min_speech_ms` | 0 to 2000 | 400 | - | needs session controls |
136
+ | `turnDetection.barge_in.min_probability` | 0 to 1 | 0.8 | - | needs session controls |
137
+ | `turnDetection.barge_in.min_dbfs` | -90 to 0, or `null` | -40 | - | needs session controls |
138
+ | `turnDetection.continue_within_ms` | 0 to 5000, or `null` | 2000 | - | the caller carrying on in the same turn; null: off; needs session controls |
139
+ | `turnDetection.continue_max_heard_ms` | 0 to 5000 | 1000 | - | needs session controls |
140
+ | `inputAudioNoiseReduction.enabled` | true / false | true | `inputAudioNoiseReduction={"type": "none"}` | false, "none" or {"type": "none"}: off; needs session controls |
141
+ | `inputAudioNoiseReduction.mode` | `near_field`, `far_field` | "near_field" | `inputAudioNoiseReduction.type` | resets strength_db to the mode's preset (12 or 30 dB) unless both are sent; needs session controls |
142
+ | `inputAudioNoiseReduction.strength_db` | 0 to 100 | 12 | - | needs session controls |
143
+ | `inputAudioNoiseReduction.apply_to_transcription` | true / false | false | - | needs session controls |
144
+ | `inputAudioTranscription.enabled` | true / false | true | `inputAudioTranscription: null` | transcript events to the client; needs session controls |
145
+ | `inputAudioTranscription.code_mixed` | true / false | true | - | English words in Latin script, and digits; needs session controls |
146
+ | `voice` | text, up to 64 characters | the language's | `voice` | |
147
+ | `breaths` | true / false, or `null` | off | - | |
148
+ | `naturalPauses` | true / false, or `null` | off | - | |
149
+ | `continuation` | true / false, or `null` | true | - | each phrase carries on from the one before; needs session controls |
150
+ | `speed` | 1 to 1 | 1.0 | `speed` | 1.0 only today; needs session controls |
151
+ | `phrasing.first_phrase_max_chars` | 1 to 120 | 120 | - | at least min_phrase_chars; needs session controls |
152
+ | `phrasing.min_phrase_chars` | 1 to 120 | 20 | - | needs session controls |
153
+ | `normaliseNumbers` | true / false | true | - | numbers and amounts said as words; needs session controls |
154
+ | `pronunciations` | word to respelling | none | - | {word: respelling}, up to 200; needs session controls |
155
+ | `temperature` | 0.6 to 1.2 | 0.7 | `temperature` | needs session controls |
156
+ | `topP` | 0.05 to 1 | 0.8 | - | needs session controls |
157
+ | `maxResponseOutputTokens` | 1 to 4096 | 320 | `maxResponseOutputTokens` | or "inf"; never above the server's; needs session controls |
158
+ | `tone` | `auto`, `conversational`, `happy`, `sad`, `excited`, `professional` | "auto" | - | "auto": the model picks; needs session controls |
159
+ | `repeatGuard` | true / false | true | - | re-asks a reply that repeats a recent one; needs session controls |
160
+ | `driftGuard` | true / false | true | - | keeps replies in the call's language; needs session controls |
161
+ <!-- /controls -->
162
+
163
+ ## Text mode, manual turns, tools, interruptions
164
+
165
+ - **`modalities: ['text']`.** The agent's words go to the `AgentSession`'s TTS, as with OpenAI's text
166
+ mode; give the session a `tts`.
167
+ - **`turnDetection: null`.** LiveKit's own turn detection ends each turn: the plugin commits the
168
+ caller's audio, and `generateReply()` returns the reply.
169
+ - **Tools (preview: they need a satham server with tool support).** Each call the agent makes runs
170
+ your tool; its result goes back to the server, which replies unless the tool returned nothing.
171
+ agents-js writes a returned value as JSON.
172
+ - **Interruptions.** The caller speaking over the agent interrupts it and the playout stops at once.
173
+ agents-js mutes the caller for the first 3 s of agent speech by default (`aecWarmupDuration`, off for
174
+ SIP calls); set it to `null` where echo cancellation is good.
175
+ - **Not supported:** video, and reconnection (a dropped connection ends the call with an
176
+ unrecoverable error).
177
+
178
+ ## Text to speech
179
+
180
+ `TTS` gives an `AgentSession` with its own STT and LLM satham's voices, spoken by kural-1, satham's
181
+ text-to-speech model:
182
+
183
+ ```ts
184
+ import { voice } from '@livekit/agents';
185
+ import * as satham from '@sathamai/livekit-plugin';
186
+
187
+ const session = new voice.AgentSession({
188
+ stt,
189
+ llm,
190
+ // SATHAM_URL and SATHAM_API_KEY, or url and apiKey here
191
+ tts: new satham.TTS({ voice: 'malar', language: 'ta', tone: 'professional' }),
192
+ });
193
+ ```
194
+
195
+ - **Streamed, a sentence at a time.** kural-1 takes whole texts, so the session splits each reply into
196
+ sentences (its `tts.StreamAdapter`, as for any TTS without streaming input), and the plugin asks for
197
+ them one at a time. Each comes back streamed as raw PCM and goes out frame by frame as it arrives,
198
+ so the audio starts as soon as it is made. 24 kHz, mono.
199
+ - **Options:** `url`, `apiKey`, `voice` (a named voice such as `naina`, `malar` or `vikram`, or an
200
+ alias such as `hi-female`), `language`, `tone`, `pace`, `instructions`, `breaths`, `naturalPauses` and `model`, as in
201
+ `@sathamai/sdk`'s `audio.speech` (its README lists the values). `tts.updateOptions({...})` changes
202
+ them from the next sentence on; set one to `undefined` to clear it. A pause marker in the text
203
+ (`<break time="0.5s"/>`, 0.1 to 3 seconds) is spoken as that much silence. `instructions` cannot be combined
204
+ with `tone` or `pace`.
205
+ - **Errors** reach the session as LiveKit's own: `APIStatusError` for a refusal (401 and 400 are not
206
+ retried; 429 and 5xx are, as the session's `connOptions.ttsConnOptions` say), `APIConnectionError`
207
+ for a failed connection, and `APITimeoutError` when no audio comes within `timeoutMs`. A sentence cut
208
+ off part-way is not retried, so no one hears its start twice.
209
+ - **On its own:** `await tts.synthesize('வணக்கம்!').collect()` is one `AudioFrame`.
@@ -0,0 +1,18 @@
1
+ /**
2
+ * satham for LiveKit Agents (agents-js): speech-to-speech (satham-1) as a `RealtimeModel`, and text
3
+ * to speech (kural-1, satham's text-to-speech model) as a `TTS`.
4
+ *
5
+ * ```ts
6
+ * import { voice } from '@livekit/agents';
7
+ * import * as satham from '@sathamai/livekit-plugin';
8
+ *
9
+ * const session = new voice.AgentSession({ llm: new satham.RealtimeModel({ greeting: 'Hello!' }) });
10
+ * await session.start({ agent: new voice.Agent({ instructions: role, tools }), room: ctx.room });
11
+ *
12
+ * // Or your own STT and LLM, with satham's voices:
13
+ * const tts = new satham.TTS({ voice: 'malar', language: 'ta' });
14
+ * const pipeline = new voice.AgentSession({ stt, llm, tts });
15
+ * ```
16
+ */
17
+ export { INPUT_SAMPLE_RATE, type OptionsUpdate, RealtimeModel, type RealtimeModelOptions, RealtimeSession, } from './realtime.js';
18
+ export { ChunkedStream, TTS, type TTSOptions, type TTSVoiceOptions } from './tts.js';
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * satham for LiveKit Agents (agents-js): speech-to-speech (satham-1) as a `RealtimeModel`, and text
3
+ * to speech (kural-1, satham's text-to-speech model) as a `TTS`.
4
+ *
5
+ * ```ts
6
+ * import { voice } from '@livekit/agents';
7
+ * import * as satham from '@sathamai/livekit-plugin';
8
+ *
9
+ * const session = new voice.AgentSession({ llm: new satham.RealtimeModel({ greeting: 'Hello!' }) });
10
+ * await session.start({ agent: new voice.Agent({ instructions: role, tools }), room: ctx.room });
11
+ *
12
+ * // Or your own STT and LLM, with satham's voices:
13
+ * const tts = new satham.TTS({ voice: 'malar', language: 'ta' });
14
+ * const pipeline = new voice.AgentSession({ stt, llm, tts });
15
+ * ```
16
+ */
17
+ export { INPUT_SAMPLE_RATE, RealtimeModel, RealtimeSession, } from './realtime.js';
18
+ export { ChunkedStream, TTS } from './tts.js';
@@ -0,0 +1,103 @@
1
+ /**
2
+ * satham's speech-to-speech model as a LiveKit Agents (agents-js) `RealtimeModel`.
3
+ *
4
+ * satham hears the caller, decides when a turn ends, replies in speech and handles barge-in on the
5
+ * server, so a `voice.AgentSession` given this model needs no STT, LLM, TTS or VAD of its own. One
6
+ * realtime session is one satham call:
7
+ *
8
+ * - the LiveKit agent's instructions are the call's role and its tools the call's tools, handed over
9
+ * when LiveKit creates the session; both can change mid-call. The agent speaks first when the model
10
+ * has a `greeting`, or when LiveKit asks (`session.generateReply()`, sent as `response.create`);
11
+ * - `RealtimeSession.say(text)` speaks fixed words in the call's voice (`response.say`), with no TTS;
12
+ * - every other setting is a control (`Controls` from `@sathamai/sdk`), with OpenAI's names where
13
+ * LiveKit's OpenAI realtime plugin has them, so moving an agent from OpenAI to satham is mostly a
14
+ * one-line change; `updateOptions()` changes any of them mid-call;
15
+ * - caller audio is resampled to 16 kHz mono and streamed; the agent's audio, its text and the caller's
16
+ * transcripts come back as LiveKit generations and transcription events. With `modalities: ['text']`
17
+ * the agent's words go to the session's TTS instead, as with OpenAI's text mode;
18
+ * - the caller speaking over the agent interrupts it; with `turnDetection: null` LiveKit's own turn
19
+ * detection ends each turn instead;
20
+ * - `llm.tool()` tools are sent as OpenAI-style function definitions; each call the agent makes is run
21
+ * by LiveKit, and its result goes back to the server, which then replies unless the tool returned
22
+ * nothing;
23
+ * - a change of language is emitted as `session_updated`.
24
+ */
25
+ import { llm } from '@livekit/agents';
26
+ import { AudioFrame } from '@livekit/rtc-node';
27
+ import { type Controls, type Session as SathamSession } from '@sathamai/sdk';
28
+ /** Caller audio goes to satham as 16 kHz mono 16-bit PCM. */
29
+ export declare const INPUT_SAMPLE_RATE = 16000;
30
+ /** How long `generateReply` and `say` wait for the reply to start. */
31
+ export declare const REPLY_TIMEOUT_MS = 10000;
32
+ /**
33
+ * Every satham control (see `Controls` in `@sathamai/sdk`): OpenAI's names (`model`, `voice`,
34
+ * `modalities`, `turnDetection`, `temperature`, `inputAudioNoiseReduction`, `inputAudioTranscription`,
35
+ * `maxResponseOutputTokens`, `speed`, `toolChoice`) and satham's own (`greeting`, `language`,
36
+ * `languageSwitch`, `voiceOnLanguageSwitch`, `breaths`, `naturalPauses`, `continuation`, `phrasing`,
37
+ * `normaliseNumbers`, `pronunciations`, `topP`, `tone`, `repeatGuard`, `driftGuard`, and `agent`, an
38
+ * optional preset agent on the server). `modalities`, `turnDetection` and `inputAudioTranscription` also
39
+ * decide what the model tells LiveKit it does, so they are fixed for a model once made.
40
+ */
41
+ export interface RealtimeModelOptions extends Controls {
42
+ /** Your satham endpoint (`wss://...` or `https://...`); `$SATHAM_URL`. */
43
+ url?: string;
44
+ /** Your API key; `$SATHAM_API_KEY`. */
45
+ apiKey?: string;
46
+ /** `"auto"`, `"none"`, `"required"` or one function. */
47
+ toolChoice?: llm.ToolChoice | null;
48
+ /** How long to wait for the call to start. */
49
+ connectTimeoutMs?: number;
50
+ }
51
+ /** A change of controls mid-call. */
52
+ export type OptionsUpdate = Controls & {
53
+ toolChoice?: llm.ToolChoice | null;
54
+ };
55
+ /** satham (satham-1) for `voice.AgentSession({ llm })`. */
56
+ export declare class RealtimeModel extends llm.RealtimeModel {
57
+ #private;
58
+ constructor(options?: RealtimeModelOptions);
59
+ get model(): string;
60
+ get provider(): string;
61
+ label(): string;
62
+ session(options?: llm.RealtimeSessionOptions): RealtimeSession;
63
+ /** Change controls for new calls and every live one (`session.update`). */
64
+ updateOptions(changes: OptionsUpdate): void;
65
+ close(): Promise<void>;
66
+ }
67
+ /**
68
+ * One satham call inside a LiveKit `AgentSession`. Besides the standard realtime events it emits
69
+ * `session_updated` (when the call's language changes) and `satham_server_event_received` (every
70
+ * server event).
71
+ */
72
+ export declare class RealtimeSession extends llm.RealtimeSession {
73
+ #private;
74
+ /** The call's language, following `session.updated`. */
75
+ language: string | null;
76
+ constructor(model: RealtimeModel, options?: llm.RealtimeSessionOptions);
77
+ /** The underlying `@sathamai/sdk` session, once the call has started. */
78
+ get call(): SathamSession | null;
79
+ /** Resolves once the call has started (or failed to). */
80
+ get started(): Promise<void>;
81
+ get chatCtx(): llm.ChatContext;
82
+ get tools(): llm.ToolContext;
83
+ /** The call's instructions: at the start, or mid-call (`session.update`). */
84
+ updateInstructions(instructions: string): Promise<void>;
85
+ updateChatCtx(chatCtx: llm.ChatContext): Promise<void>;
86
+ updateTools(tools: llm.ToolContext): Promise<void>;
87
+ /** Change the call's controls (`session.update`); before it starts, its start. */
88
+ updateOptions(options: OptionsUpdate): void;
89
+ pushAudio(frame: AudioFrame): void;
90
+ /** A reply now (`response.create`); `instructions` guide this reply alone. */
91
+ generateReply(instructions?: string): Promise<llm.GenerationCreatedEvent>;
92
+ /**
93
+ * Speak `text` as it is, in the call's voice (`response.say`), with no TTS. agents-js 1.10's
94
+ * `AgentSession.say()` needs a TTS for realtime models, so call this on the realtime session; the
95
+ * reply is played like any server reply.
96
+ */
97
+ say(text: string): Promise<llm.GenerationCreatedEvent>;
98
+ commitAudio(): Promise<void>;
99
+ clearAudio(): Promise<void>;
100
+ interrupt(): Promise<void>;
101
+ truncate(): Promise<void>;
102
+ close(): Promise<void>;
103
+ }