@yaks/speech 0.0.0-stage → 0.2.36

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 2026 Jeff Peterson
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,186 @@
1
- # Temporary Holding Version
1
+ # @yaks/speech
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
+ Speech to text, text to speech and speech to speech, with each provider given as
4
+ data. A `Provider` says where it answers, which models hear, speak and talk,
5
+ what each costs, and how its requests and streams are worded, all in its own
6
+ entry; one implementation calls any provider described that way. The key is an
7
+ argument; nothing here reads the environment.
8
+
9
+ - `DEEPGRAM`: Nova-3 hears a recording and tells its speakers apart, Flux hears
10
+ a call and says when a speaker's turn ends, and Aura-2 speaks. It has no model
11
+ that talks.
12
+ - `OPENAI`: gpt-transcribe hears a recording and a call's turns, gpt-4o-mini-tts
13
+ speaks (its 24 kHz PCM made μ-law for a call), gpt-realtime-2.1 and its mini
14
+ hear and speak in one stream (`talk`), and gpt-live-1 hears and speaks at
15
+ once, taking its own turns.
16
+ - `ELEVENLABS`: Multilingual v2 speaks unless Flash v2.5, v4 Turbo, v3
17
+ Conversational or v4 is asked for, Scribe v2 hears a recording and tells its
18
+ speakers apart, and the account keeps voices of its own, designed from a
19
+ description or cloned from recordings. It hears no stream and has no model
20
+ that talks. Its key goes in its own header, `xi-api-key` (`header`).
21
+
22
+ ## Speaking and hearing
23
+
24
+ - `speak({provider, key, text, voice?, format?, speed?, model?})` answers the
25
+ audio as it streams (`body`), its media type, and what it cost in `dollars`.
26
+ `model` is one of `provider.speak.models`, each priced by the thousand
27
+ characters, the first by default (`speakerOf`). `format` is
28
+ `{encoding: 'mp3'}` (the default) or raw samples,
29
+ `{encoding: 'mulaw' | 'linear16', rate}`, which come without a container,
30
+ ready for a phone call. μ-law comes without the silence a provider pads a clip
31
+ with, but 50 ms at each end (`trimmed`), so sentences said one clip at a time
32
+ follow each other as closely at any speed.
33
+ - `speed` is a multiple of the provider's own pace (1 by default), held within
34
+ the `speeds` each provider declares for speaking and for talking
35
+ (`paced(speeds, speed)`): Aura-2 0.7 to 1.5, gpt-4o-mini-tts 0.25 to 4, the
36
+ realtime models 0.25 to 1.5; gpt-live-1 has only its own.
37
+ - `hear({provider, key, audio, type})` answers a recording's `text`, its
38
+ `turns`, its length in `seconds`, and `dollars`. `provider.hear.bytes` is the
39
+ largest recording it hears: 2 GB on Nova-3, whose `audio` may be a stream sent
40
+ as it is read, and 25 MB on gpt-transcribe.
41
+ - A turn is what one speaker said up to a pause or another's voice:
42
+ `{speaker, text, from?, to?}`, `from` and `to` the seconds into the audio it
43
+ took, where the provider says. `speaker` numbers the voices a provider tells
44
+ apart from 0; `provider.hear.speakers` and each of `provider.turns`'
45
+ `speakers` say whether it tells them apart, and one that does not answers
46
+ every turn as speaker 0 (a recording's words as one turn). Nova-3 tells a
47
+ recording's and a stream's speakers apart; Flux and OpenAI's models tell none
48
+ apart. `heard(entry, seconds)` prices seconds on any of them.
49
+ - `turns({provider, key, format, told, model?})` hears audio as it streams, on
50
+ one of `provider.turns` (`streamOf(provider, model)`, the first by default:
51
+ Flux on Deepgram, the quickest to tell a call's turn has ended; Nova-3 there
52
+ tells speakers apart). `send` takes raw samples; `told.start()` fires when the
53
+ speaker starts a turn (stop whatever is playing to them), `told.end(turn)`
54
+ when they finish one, and `told.lost(reason)` when the stream drops. `spent()`
55
+ answers the seconds heard so far and their cost, `close()` ends the stream at
56
+ once answering the same, and `end()` answers it once the provider has told the
57
+ turns it was still hearing and closed. Each entry's `reader()` makes what
58
+ reads one stream's messages, so Nova-3 keeps a turn's words until a pause or
59
+ another speaker ends it.
60
+ - `talk({provider, key, format, instructions, tools?, model?, voice?, speed?, opens?, told})`
61
+ is a model that hears and speaks itself, `model` one of a `provider.talk`
62
+ entry's (`talkerOf(provider, model)`; the first by default), which is `Turned`
63
+ or `Duplex`. A `Turned` one (the realtime models) takes a turn as it is told
64
+ here. `send` takes the caller's raw samples; `told.audio(bytes)` is what to
65
+ play them, `told.over()` that they talked over the model and what plays should
66
+ stop (once their words say something, `meant`: an "okay", a laugh or a noise
67
+ lets it go on, and the response under way is cancelled), `told.stopped()` ends
68
+ their turn, when the model hears it end or once they are quiet 0.7 s. What the
69
+ model says to it waits for their words, and is not said when they stopped
70
+ where a sentence goes on (`open`: "the", "is", "um", a comma), when the model
71
+ calls the stream's own `listen` tool, or when they talk again before it plays;
72
+ a turn left unanswered is answered once they have been quiet 5 s. `words` are
73
+ what its hearing should expect, such as the names it is called by.
74
+ `told.heard` and `told.said` are each side's words, and
75
+ `told.call(name, args)` answers a tool the model asked for with its output,
76
+ before it goes on, and `told.done()` ends each of its responses. `say(text)`
77
+ asks it to say something, and `tell(text)` tells it something it knows from
78
+ now on without answering it; `spent()` answers the seconds heard and what the
79
+ stream cost so far, and `close()` ends it answering the same, each response
80
+ priced at its model's rates, or the stream's when it names none. A provider
81
+ without the model refuses.
82
+ - A `Turned` model asked only to listen calls the stream's `stay_silent`, or
83
+ listens always (`listening`, as in a room of several people). Each turn still
84
+ reaches it once its words are heard, but put as a choice of tools, never
85
+ words, with a reminder that letting it pass (`listen`) is the usual choice:
86
+ whatever it writes beside its choice is never said, and work it does with its
87
+ tools on such a turn is done without a word after. It speaks only by calling
88
+ `answer`, or `talk` to stop listening (not offered when it listens always). A
89
+ turn whose words are said to it (`addressed(words)`, such as naming it) is
90
+ answered in words, and its name said alone, let go on, carries to the next
91
+ turn; no turn is answered for it after a pause.
92
+ - `opens` is the model's first words, a call's greeting. Either kind of model is
93
+ asked for them once as the stream opens, and the caller's audio reaches it as
94
+ a quiet line (`muted`) until they have played: a hello the caller says over
95
+ them, or the sound of the line picking up, is no turn for the model to answer
96
+ with a greeting of its own. A `Turned` model writes them faster than they are
97
+ said, so they have played once the line has run as long as they last; a
98
+ `Duplex` one has said them once it spoke and was quiet 0.6 s. A model that
99
+ begins none in 6 s hears the caller anyway. A call the provider's own line
100
+ carries is asked for them too, its audio heard throughout.
101
+ - `first(format)` is that rule for whoever speaks a call's first words
102
+ themselves, as a call around `turns` and `speak` does: `said(audio)` takes the
103
+ words' audio as it is given to the line and `done()` that it all was, and
104
+ `heard(audio)` answers the caller's audio as the listener should get it, quiet
105
+ until the words have played.
106
+ - Asked to say given words (`opens`, `say`), a `Turned` model answers with no
107
+ tool, and only its answer plays: gpt-realtime-2.1-mini sometimes says such
108
+ words twice in one response, as a part before its answer and the answer.
109
+ - A `Duplex` one (gpt-live-1) hears and speaks at once and takes its own turns:
110
+ it yields to the caller and waits through their pauses itself, and its audio
111
+ comes as it is said, quiet and all, so nothing here stops it, ends a turn or
112
+ asks for a response. Nothing is sent before its session started. Its words
113
+ come a few at a time and are kept as lines, each side's ending when the other
114
+ speaks; an answer's first sound ends the caller's turn as `told.stopped(ago)`,
115
+ `ago` seconds back to their last sound. Its tools are whoever runs the call:
116
+ work it hands over goes to `told.delegate(request)`, the caller's words since
117
+ it last did, and what that answers it says in its own words, as it does what
118
+ `say` asks. Given a `backend` (`{model, instructions, tools}`, one of the
119
+ entry's `backends`: gpt-6-luna or gpt-6.2-sol), it hands its work to that
120
+ larger model on the provider's side instead, which searches the web itself and
121
+ calls `tools` through `told.call(name, args)`, each answer letting its work go
122
+ on. It is priced by the minute, and its backend by the token.
123
+ - A call the provider's own line carries, sent to it over SIP, never passes its
124
+ audio here. `talk.calls.rang(event)` reads the provider's webhook for the
125
+ call's `id` and SIP `headers`; `accept({provider, key, call, …})` picks it up
126
+ with the model set up as `talk` sets one up, and `reject` and `hangup` end it.
127
+ `talk({…, call})` then joins it instead of streaming: no `format`, nothing to
128
+ `send` and no `told.audio`; the caller talking over the model stops what plays
129
+ on the line, `told.plays()` says the model's audio began playing, and
130
+ `told.ended()` that the call ended (its stream closed cleanly). Its audio
131
+ never heard here, a turn ends only when the model hears it end, and what the
132
+ model says plays before the turn's words are heard. OpenAI's realtime models
133
+ take calls this way.
134
+ - A stream's `open(url, {authorization, protocols})` makes its socket: by
135
+ default the platform's `WebSocket`, offering the key as the provider's
136
+ subprotocols; a host whose sockets take headers sends `authorization`.
137
+ - `provider.speak.voices` (and `provider.talk.voices`) list the voices it speaks
138
+ in, each an `id` to pass as `voice`, a `name` and how it sounds (`about`).
139
+ - `balance({provider, key})` is the credit left on the account, in dollars, or
140
+ undefined where the provider does not say.
141
+ - `voices({provider, key})` lists the voices the key's account speaks in, page
142
+ after page, where the provider keeps them per account (`provider.voices`):
143
+ ElevenLabs' premade voices and those the account designed, cloned or added,
144
+ each with a `sample` to play. Another provider answers its own `speak.voices`.
145
+ - `design({provider, key, description, text?})` designs voices from words saying
146
+ how one sounds, each a `Design`: its `id`, and a sample saying `text` (or
147
+ words the provider picks) as `audio` bytes of `type`, `seconds` long.
148
+ `keep({provider, key, design, name, description})` keeps one as a voice of the
149
+ account's, and `clone({provider, key, name, samples, description?})` makes one
150
+ from recordings (`Blob`s); both answer the new voice's id. A provider that
151
+ makes no voices (`provider.make`) refuses, and one whose plan does not allow
152
+ cloning refuses with its reason.
153
+ - `spoken(provider, text, model?)` and `heard(provider, seconds)` price speech
154
+ before it is asked for.
155
+ - `mulawed(from, to)` turns a stream of 16-bit PCM into μ-law at a lower rate,
156
+ and `trimmed(rate, keep?)` takes the silence off both ends of a μ-law stream;
157
+ `base64` and `unbase64` carry audio in JSON.
158
+
159
+ A refusal rejects with `SpeechError`, carrying the provider's HTTP `status` and
160
+ its words; `retry` is true for a 429, a 5xx, or no answer at all.
161
+
162
+ ## How a persona speaks
163
+
164
+ `@yaks/speech/vocab` declares `speech{voice, pace, model, backend, speaker}`,
165
+ which any persona carries: the voice it speaks in (an id, which names its
166
+ provider), how fast (by the host's name for a pace), the model that answers it
167
+ on a call, the larger model that model hands a hard request to, and the model
168
+ that says the answers aloud where the answering model does not talk. Each is an
169
+ id the host knows. `speechFrom(persona, base, …)` reads it: each property is the
170
+ first row's in the chain that holds it, so a persona without one takes its base
171
+ persona's, and one none of them holds is absent, for the host to choose.
172
+ yaks.app's Operator keeps its voice this way (workers/yak/operator-persona.ts).
173
+
174
+ `@yaks/speech/ui` draws two cards of the kit's parts. `VoiceCard` is where a
175
+ persona's people pick how it sounds. Its host says what is offered (`Offer`):
176
+ the voice picked now and each voice it may pick, with what it is like, and the
177
+ paces, each list holding the one picked. `sample(id)` is where a voice's sample
178
+ plays from. It posts `voice` and `voice_speed`. `CallsCard` is where the host's
179
+ admin picks how every persona's calls are answered (`Calls`): the ways to
180
+ answer, who takes a hard request, and the models that say answers where a
181
+ provider has several, each named by its id over what choosing it means. It posts
182
+ `voice_model`, `voice_backend` and `voice_speaker`. The host's form holds each
183
+ card, so where they go is the host's. yaks.app's Operator page offers what its
184
+ keys reach (workers/yak/speech.ts `offered`), and its admin desk's Calls page
185
+ sets the model and backend on the base persona every Operator wears (`calls`,
186
+ `callsDoor`).
@@ -0,0 +1,65 @@
1
+ import type { Raw } from "./mod.js";
2
+ /** One 16-bit sample as G.711 μ-law. */ export declare let mulawOf: (sample: number) => number;
3
+ /**
4
+ * A stream of little-endian 16-bit PCM at `from` Hz as μ-law at `to` Hz,
5
+ * `from` a whole multiple of `to`: each `from / to` samples are averaged
6
+ * into one, and a chunk that ends mid-sample waits for the next.
7
+ *
8
+ * ```ts
9
+ * import { equal } from '@yaks/testing'
10
+ * import { mulawed } from '@yaks/speech'
11
+ * let pcm = new Uint8Array(new Int16Array([0, 0, 0, 1000, 1000, 1000]).buffer)
12
+ * let out = new Uint8Array(
13
+ * await new Response(
14
+ * new Response(pcm).body!.pipeThrough(mulawed(24000, 8000)),
15
+ * ).arrayBuffer(),
16
+ * )
17
+ * equal(out.length, 2)
18
+ * ```
19
+ */ export declare let mulawed: (from: number, to: number) => TransformStream<Uint8Array, Uint8Array>;
20
+ /**
21
+ * Whether raw samples hold a sound louder than a quiet line, about -36 dBFS:
22
+ * μ-law of exponent 4 or more, or 16-bit PCM over 512.
23
+ *
24
+ * ```ts
25
+ * import { equal } from '@yaks/testing'
26
+ * import { sounds } from '@yaks/speech'
27
+ * equal(sounds(new Uint8Array([0xff, 0x7f, 0xc5]), { encoding: 'mulaw', rate: 8000 }), false)
28
+ * equal(sounds(new Uint8Array([0xff, 0x10]), { encoding: 'mulaw', rate: 8000 }), true)
29
+ * let pcm = new Uint8Array(new Int16Array([40, -600]).buffer)
30
+ * equal(sounds(pcm, { encoding: 'linear16', rate: 24000 }), true)
31
+ * ```
32
+ */ export declare let sounds: (bytes: Uint8Array, format: Raw) => boolean;
33
+ /**
34
+ * A quiet line as long as `bytes`, in their format.
35
+ *
36
+ * ```ts
37
+ * import { equal } from '@yaks/testing'
38
+ * import { muted, sounds } from '@yaks/speech'
39
+ * let mulaw = { encoding: 'mulaw', rate: 8000 } as const
40
+ * let quiet = muted(new Uint8Array([0x10, 0x20, 0x30]), mulaw)
41
+ * equal([quiet.length, sounds(quiet, mulaw)], [3, false])
42
+ * ```
43
+ */ export declare let muted: (bytes: Uint8Array, format: Raw) => Uint8Array;
44
+ /**
45
+ * A stream of μ-law at `rate` Hz without the silence before its first sound
46
+ * and after its last, but `keep` seconds of each. A provider pads every
47
+ * clip it speaks, and speaking faster never shortens the padding, so a call
48
+ * said a sentence at a time would pause the same between sentences at any
49
+ * speed. Silence between sounds passes as it was, once the next sound comes.
50
+ *
51
+ * ```ts
52
+ * import { equal } from '@yaks/testing'
53
+ * import { trimmed } from '@yaks/speech'
54
+ * let clip = new Uint8Array([0xff, 0xff, 0xff, 0x10, 0xff, 0x10, 0xff, 0xff])
55
+ * let out = new Uint8Array(
56
+ * await new Response(
57
+ * new Response(clip).body!.pipeThrough(trimmed(1, 1)),
58
+ * ).arrayBuffer(),
59
+ * )
60
+ * equal([...out], [0xff, 0x10, 0xff, 0x10, 0xff])
61
+ * ```
62
+ */ export declare let trimmed: (rate: number, keep?: number) => TransformStream<Uint8Array, Uint8Array>;
63
+ /** Bytes as base64, the way a JSON stream carries audio. */ export declare let base64: (bytes: Uint8Array) => string;
64
+ /** Base64 as bytes. */ export declare let unbase64: (text: string) => Uint8Array;
65
+ //# sourceMappingURL=audio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audio.d.ts","sources":["../audio.ts"],"names":[],"mappings":"AAKA,cAAc,GAAG,mBAAkB;AAInC,sCAAsC,GACtC,OAAO,YAAI,UAAW,QAAQ,MAAM,KAAG,MAAM,CAO5C;AAED;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,YAAI,UACT,MAAM,MAAM,EACZ,IAAI,MAAM,KACT,gBAAgB,YAAY,YAyB9B;AAKD;;;;;;;;;;;;CAYC,GACD,OAAO,YAAI,SAAU,OAAO,YAAY,QAAQ,QAAM,OAAO,CAO5D;AAED;;;;;;;;;;CAUC,GACD,OAAO,YAAI,QAAS,OAAO,YAAY,QAAQ,QAAM,WACqB;AAE1E;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,YAAI,UACT,MAAM,MAAM,EACZ,kBACC,gBAAgB,YAAY,YAyB9B;AAED,0DAA0D,GAC1D,OAAO,YAAI,SAAU,OAAO,eAAa,MAAM,CAM9C;AAED,qBAAqB,GACrB,OAAO,YAAI,WAAY,MAAM,MAAM,KAAG,WACe"}
@@ -0,0 +1,3 @@
1
+ import type { Provider } from "./mod.js";
2
+ export declare let DEEPGRAM: Provider;
3
+ //# sourceMappingURL=deepgram.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deepgram.d.ts","sources":["../deepgram.ts"],"names":[],"mappings":"AAeA,cAA2B,QAAQ,mBAAwB;AAiK3D,OAAO,YAAI,UAAU,SAgUpB"}
@@ -0,0 +1,3 @@
1
+ import { type Provider } from "./mod.js";
2
+ export declare let ELEVENLABS: Provider;
3
+ //# sourceMappingURL=elevenlabs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elevenlabs.d.ts","sources":["../elevenlabs.ts"],"names":[],"mappings":"AAiBA,SAGE,KAAK,QAAQ,mBAGE;AAyHjB,OAAO,YAAI,YAAY,SA2ItB"}