@copilotkit/voice 0.0.0-a2ui-v0-9-latest-20260408115931
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/CHANGELOG.md +401 -0
- package/LICENSE +21 -0
- package/README.md +56 -0
- package/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/index.cjs +4 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +3 -0
- package/dist/index.umd.js +108 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/transcription/transcription-service-openai.cjs +34 -0
- package/dist/transcription/transcription-service-openai.cjs.map +1 -0
- package/dist/transcription/transcription-service-openai.d.cts +40 -0
- package/dist/transcription/transcription-service-openai.d.cts.map +1 -0
- package/dist/transcription/transcription-service-openai.d.mts +40 -0
- package/dist/transcription/transcription-service-openai.d.mts.map +1 -0
- package/dist/transcription/transcription-service-openai.mjs +32 -0
- package/dist/transcription/transcription-service-openai.mjs.map +1 -0
- package/package.json +45 -0
- package/src/__tests__/smoke.test.ts +7 -0
- package/src/index.ts +2 -0
- package/src/transcription/transcription-service-openai.ts +58 -0
- package/tsconfig.json +12 -0
- package/tsdown.config.ts +35 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
# @copilotkit/voice
|
|
2
|
+
|
|
3
|
+
## 0.0.0-a2ui-v0-9-latest-20260408115931
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1ceb963: refactor: consolidate V1/V2 packages into flat @copilotkit/\* structure
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [1ceb963]
|
|
12
|
+
- Updated dependencies [1ceb963]
|
|
13
|
+
- Updated dependencies [8aafcbe]
|
|
14
|
+
- Updated dependencies [52a9322]
|
|
15
|
+
- Updated dependencies [1ceb963]
|
|
16
|
+
- Updated dependencies [9a6ee39]
|
|
17
|
+
- Updated dependencies [1ceb963]
|
|
18
|
+
- Updated dependencies [5289791]
|
|
19
|
+
- @copilotkit/runtime@0.0.0-a2ui-v0-9-latest-20260408115931
|
|
20
|
+
|
|
21
|
+
## 1.55.0-next.8
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [8aafcbe]
|
|
26
|
+
- @copilotkit/runtime@1.55.0-next.8
|
|
27
|
+
|
|
28
|
+
## 1.55.0-next.7
|
|
29
|
+
|
|
30
|
+
### Minor Changes
|
|
31
|
+
|
|
32
|
+
- 1ceb963: refactor: consolidate V1/V2 packages into flat @copilotkit/\* structure
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [1ceb963]
|
|
37
|
+
- @copilotkit/runtime@1.55.0-next.7
|
|
38
|
+
|
|
39
|
+
## 1.54.1-next.6
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- @copilotkitnext/runtime@1.54.1-next.6
|
|
44
|
+
|
|
45
|
+
## 1.54.1-next.5
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- @copilotkitnext/runtime@1.54.1-next.5
|
|
50
|
+
|
|
51
|
+
## 1.54.1-next.4
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- @copilotkitnext/runtime@1.54.1-next.4
|
|
56
|
+
|
|
57
|
+
## 1.54.1-next.3
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- @copilotkitnext/runtime@1.54.1-next.3
|
|
62
|
+
|
|
63
|
+
## 1.54.1-next.2
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- @copilotkitnext/runtime@1.54.1-next.2
|
|
68
|
+
|
|
69
|
+
## 1.54.1-next.1
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- @copilotkitnext/runtime@1.54.1-next.1
|
|
74
|
+
|
|
75
|
+
## 1.54.1-next.0
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- @copilotkitnext/runtime@1.54.1-next.0
|
|
80
|
+
|
|
81
|
+
## 1.54.0
|
|
82
|
+
|
|
83
|
+
### Patch Changes
|
|
84
|
+
|
|
85
|
+
- Updated dependencies [3780c6a]
|
|
86
|
+
- @copilotkitnext/runtime@1.54.0
|
|
87
|
+
|
|
88
|
+
## 1.54.0-next.9
|
|
89
|
+
|
|
90
|
+
### Patch Changes
|
|
91
|
+
|
|
92
|
+
- Updated dependencies [3780c6a]
|
|
93
|
+
- @copilotkitnext/runtime@1.54.0-next.9
|
|
94
|
+
|
|
95
|
+
## 1.54.0-next.8
|
|
96
|
+
|
|
97
|
+
### Patch Changes
|
|
98
|
+
|
|
99
|
+
- @copilotkitnext/runtime@1.54.0-next.8
|
|
100
|
+
|
|
101
|
+
## 1.54.0-next.7
|
|
102
|
+
|
|
103
|
+
### Patch Changes
|
|
104
|
+
|
|
105
|
+
- @copilotkitnext/runtime@1.54.0-next.7
|
|
106
|
+
|
|
107
|
+
## 1.54.0-next.6
|
|
108
|
+
|
|
109
|
+
### Patch Changes
|
|
110
|
+
|
|
111
|
+
- @copilotkitnext/runtime@1.54.0-next.6
|
|
112
|
+
|
|
113
|
+
## 1.54.0-next.5
|
|
114
|
+
|
|
115
|
+
### Patch Changes
|
|
116
|
+
|
|
117
|
+
- @copilotkitnext/runtime@1.54.0-next.5
|
|
118
|
+
|
|
119
|
+
## 1.54.0-next.4
|
|
120
|
+
|
|
121
|
+
### Patch Changes
|
|
122
|
+
|
|
123
|
+
- @copilotkitnext/runtime@1.54.0-next.4
|
|
124
|
+
|
|
125
|
+
## 1.54.0-next.3
|
|
126
|
+
|
|
127
|
+
### Patch Changes
|
|
128
|
+
|
|
129
|
+
- @copilotkitnext/runtime@1.54.0-next.3
|
|
130
|
+
|
|
131
|
+
## 1.53.1-next.2
|
|
132
|
+
|
|
133
|
+
### Patch Changes
|
|
134
|
+
|
|
135
|
+
- @copilotkit/runtime@1.53.1-next.2
|
|
136
|
+
|
|
137
|
+
## 1.53.1-next.1
|
|
138
|
+
|
|
139
|
+
### Patch Changes
|
|
140
|
+
|
|
141
|
+
- @copilotkit/runtime@1.53.1-next.1
|
|
142
|
+
|
|
143
|
+
## 1.53.1-next.0
|
|
144
|
+
|
|
145
|
+
### Patch Changes
|
|
146
|
+
|
|
147
|
+
- @copilotkit/runtime@1.53.1-next.0
|
|
148
|
+
|
|
149
|
+
## 1.53.0
|
|
150
|
+
|
|
151
|
+
### Patch Changes
|
|
152
|
+
|
|
153
|
+
- Updated dependencies [1510f64]
|
|
154
|
+
- @copilotkit/runtime@1.53.0
|
|
155
|
+
|
|
156
|
+
## 1.53.0-next.6
|
|
157
|
+
|
|
158
|
+
### Patch Changes
|
|
159
|
+
|
|
160
|
+
- @copilotkit/runtime@1.53.0-next.6
|
|
161
|
+
|
|
162
|
+
## 1.53.0-next.5
|
|
163
|
+
|
|
164
|
+
### Patch Changes
|
|
165
|
+
|
|
166
|
+
- @copilotkit/runtime@1.53.0-next.5
|
|
167
|
+
|
|
168
|
+
## 1.52.2-next.4
|
|
169
|
+
|
|
170
|
+
### Patch Changes
|
|
171
|
+
|
|
172
|
+
- @copilotkit/runtime@1.52.2-next.4
|
|
173
|
+
|
|
174
|
+
## 1.52.2-next.3
|
|
175
|
+
|
|
176
|
+
### Patch Changes
|
|
177
|
+
|
|
178
|
+
- Updated dependencies [1510f64]
|
|
179
|
+
- @copilotkit/runtime@1.52.2-next.3
|
|
180
|
+
|
|
181
|
+
## 1.52.2-next.2
|
|
182
|
+
|
|
183
|
+
### Patch Changes
|
|
184
|
+
|
|
185
|
+
- @copilotkit/runtime@1.52.2-next.2
|
|
186
|
+
|
|
187
|
+
## 1.52.2-next.1
|
|
188
|
+
|
|
189
|
+
### Patch Changes
|
|
190
|
+
|
|
191
|
+
- @copilotkit/runtime@1.52.2-next.1
|
|
192
|
+
|
|
193
|
+
## 1.52.2-next.0
|
|
194
|
+
|
|
195
|
+
### Patch Changes
|
|
196
|
+
|
|
197
|
+
- @copilotkit/runtime@1.52.2-next.0
|
|
198
|
+
|
|
199
|
+
## 1.52.1
|
|
200
|
+
|
|
201
|
+
### Patch Changes
|
|
202
|
+
|
|
203
|
+
- @copilotkit/runtime@1.52.1
|
|
204
|
+
|
|
205
|
+
## 1.52.1-next.1
|
|
206
|
+
|
|
207
|
+
### Patch Changes
|
|
208
|
+
|
|
209
|
+
- @copilotkit/runtime@1.52.1-next.1
|
|
210
|
+
|
|
211
|
+
## 1.52.1-next.0
|
|
212
|
+
|
|
213
|
+
### Patch Changes
|
|
214
|
+
|
|
215
|
+
- @copilotkit/runtime@1.52.1-next.0
|
|
216
|
+
|
|
217
|
+
## 1.52.0
|
|
218
|
+
|
|
219
|
+
### Patch Changes
|
|
220
|
+
|
|
221
|
+
- Updated dependencies [ef0f539]
|
|
222
|
+
- @copilotkit/runtime@1.52.0
|
|
223
|
+
|
|
224
|
+
## 1.52.0-next.8
|
|
225
|
+
|
|
226
|
+
### Patch Changes
|
|
227
|
+
|
|
228
|
+
- @copilotkit/runtime@1.52.0-next.8
|
|
229
|
+
|
|
230
|
+
## 1.52.0-next.7
|
|
231
|
+
|
|
232
|
+
### Patch Changes
|
|
233
|
+
|
|
234
|
+
- @copilotkit/runtime@1.52.0-next.7
|
|
235
|
+
|
|
236
|
+
## 1.52.0-next.6
|
|
237
|
+
|
|
238
|
+
### Patch Changes
|
|
239
|
+
|
|
240
|
+
- @copilotkit/runtime@1.52.0-next.6
|
|
241
|
+
|
|
242
|
+
## 1.52.0-next.5
|
|
243
|
+
|
|
244
|
+
### Patch Changes
|
|
245
|
+
|
|
246
|
+
- @copilotkit/runtime@1.52.0-next.5
|
|
247
|
+
|
|
248
|
+
## 1.51.5-next.4
|
|
249
|
+
|
|
250
|
+
### Patch Changes
|
|
251
|
+
|
|
252
|
+
- @copilotkit/runtime@1.51.5-next.4
|
|
253
|
+
|
|
254
|
+
## 1.51.5-next.3
|
|
255
|
+
|
|
256
|
+
### Patch Changes
|
|
257
|
+
|
|
258
|
+
- @copilotkit/runtime@1.51.5-next.3
|
|
259
|
+
|
|
260
|
+
## 1.51.5-next.2
|
|
261
|
+
|
|
262
|
+
### Patch Changes
|
|
263
|
+
|
|
264
|
+
- @copilotkit/runtime@1.51.5-next.2
|
|
265
|
+
|
|
266
|
+
## 1.51.5-next.1
|
|
267
|
+
|
|
268
|
+
### Patch Changes
|
|
269
|
+
|
|
270
|
+
- @copilotkit/runtime@1.51.5-next.1
|
|
271
|
+
|
|
272
|
+
## 1.51.5-next.0
|
|
273
|
+
|
|
274
|
+
### Patch Changes
|
|
275
|
+
|
|
276
|
+
- Updated dependencies [ef0f539]
|
|
277
|
+
- @copilotkit/runtime@1.51.5-next.0
|
|
278
|
+
|
|
279
|
+
## 1.51.4
|
|
280
|
+
|
|
281
|
+
### Patch Changes
|
|
282
|
+
|
|
283
|
+
- @copilotkit/runtime@1.51.4
|
|
284
|
+
|
|
285
|
+
## 1.51.4-next.8
|
|
286
|
+
|
|
287
|
+
### Patch Changes
|
|
288
|
+
|
|
289
|
+
- @copilotkit/runtime@1.51.4-next.8
|
|
290
|
+
|
|
291
|
+
## 1.51.4-next.7
|
|
292
|
+
|
|
293
|
+
### Patch Changes
|
|
294
|
+
|
|
295
|
+
- @copilotkit/runtime@1.51.4-next.7
|
|
296
|
+
|
|
297
|
+
## 1.51.4-next.6
|
|
298
|
+
|
|
299
|
+
### Patch Changes
|
|
300
|
+
|
|
301
|
+
- @copilotkit/runtime@1.51.4-next.6
|
|
302
|
+
|
|
303
|
+
## 1.51.4-next.5
|
|
304
|
+
|
|
305
|
+
### Patch Changes
|
|
306
|
+
|
|
307
|
+
- @copilotkit/runtime@1.51.4-next.5
|
|
308
|
+
|
|
309
|
+
## 1.51.4-next.4
|
|
310
|
+
|
|
311
|
+
### Patch Changes
|
|
312
|
+
|
|
313
|
+
- @copilotkit/runtime@1.51.4-next.4
|
|
314
|
+
|
|
315
|
+
## 1.51.4-next.3
|
|
316
|
+
|
|
317
|
+
### Patch Changes
|
|
318
|
+
|
|
319
|
+
- @copilotkit/runtime@1.51.4-next.3
|
|
320
|
+
|
|
321
|
+
## 1.51.4-next.2
|
|
322
|
+
|
|
323
|
+
### Patch Changes
|
|
324
|
+
|
|
325
|
+
- @copilotkit/runtime@1.51.4-next.2
|
|
326
|
+
|
|
327
|
+
## 1.51.4-next.1
|
|
328
|
+
|
|
329
|
+
### Patch Changes
|
|
330
|
+
|
|
331
|
+
- @copilotkit/runtime@1.51.4-next.1
|
|
332
|
+
|
|
333
|
+
## 1.51.4-next.0
|
|
334
|
+
|
|
335
|
+
### Patch Changes
|
|
336
|
+
|
|
337
|
+
- @copilotkit/runtime@1.51.4-next.0
|
|
338
|
+
|
|
339
|
+
## 1.51.3
|
|
340
|
+
|
|
341
|
+
### Patch Changes
|
|
342
|
+
|
|
343
|
+
- d36fc1e: Add UMD export
|
|
344
|
+
- Updated dependencies [d36fc1e]
|
|
345
|
+
- @copilotkit/runtime@1.51.3
|
|
346
|
+
|
|
347
|
+
## 1.51.3-next.8
|
|
348
|
+
|
|
349
|
+
### Patch Changes
|
|
350
|
+
|
|
351
|
+
- d36fc1e: Add UMD export
|
|
352
|
+
- Updated dependencies [d36fc1e]
|
|
353
|
+
- @copilotkit/runtime@1.51.3-next.8
|
|
354
|
+
|
|
355
|
+
## 1.51.3-next.7
|
|
356
|
+
|
|
357
|
+
### Patch Changes
|
|
358
|
+
|
|
359
|
+
- @copilotkit/runtime@1.51.3-next.7
|
|
360
|
+
|
|
361
|
+
## 1.51.3-next.6
|
|
362
|
+
|
|
363
|
+
### Patch Changes
|
|
364
|
+
|
|
365
|
+
- @copilotkit/runtime@1.51.3-next.6
|
|
366
|
+
|
|
367
|
+
## 1.51.3-next.5
|
|
368
|
+
|
|
369
|
+
### Patch Changes
|
|
370
|
+
|
|
371
|
+
- @copilotkit/runtime@1.51.3-next.5
|
|
372
|
+
|
|
373
|
+
## 1.51.3-next.4
|
|
374
|
+
|
|
375
|
+
### Patch Changes
|
|
376
|
+
|
|
377
|
+
- @copilotkit/runtime@1.51.3-next.4
|
|
378
|
+
|
|
379
|
+
## 1.51.3-next.3
|
|
380
|
+
|
|
381
|
+
### Patch Changes
|
|
382
|
+
|
|
383
|
+
- @copilotkit/runtime@1.51.3-next.3
|
|
384
|
+
|
|
385
|
+
## 1.51.3-next.2
|
|
386
|
+
|
|
387
|
+
### Patch Changes
|
|
388
|
+
|
|
389
|
+
- @copilotkit/runtime@1.51.3-next.2
|
|
390
|
+
|
|
391
|
+
## 1.51.3-next.1
|
|
392
|
+
|
|
393
|
+
### Patch Changes
|
|
394
|
+
|
|
395
|
+
- @copilotkit/runtime@1.51.3-next.1
|
|
396
|
+
|
|
397
|
+
## 1.51.3-next.0
|
|
398
|
+
|
|
399
|
+
### Patch Changes
|
|
400
|
+
|
|
401
|
+
- @copilotkit/runtime@1.51.3-next.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Atai Barkai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# @copilotkit/voice
|
|
2
|
+
|
|
3
|
+
Audio transcription providers for CopilotKit.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @copilotkit/voice openai
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { CopilotRuntime, createCopilotEndpoint } from "@copilotkit/runtime";
|
|
13
|
+
import { TranscriptionServiceOpenAI } from "@copilotkit/voice";
|
|
14
|
+
import OpenAI from "openai";
|
|
15
|
+
|
|
16
|
+
const runtime = new CopilotRuntime({
|
|
17
|
+
agents: { default: yourAgent },
|
|
18
|
+
transcriptionService: new TranscriptionServiceOpenAI({
|
|
19
|
+
openai: new OpenAI({ apiKey: process.env.OPENAI_API_KEY }),
|
|
20
|
+
}),
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Once configured, the chat UI shows a microphone button. Users can record audio, which gets transcribed and inserted into the input field as text.
|
|
25
|
+
|
|
26
|
+
## TranscriptionServiceOpenAI
|
|
27
|
+
|
|
28
|
+
Uses [OpenAI Whisper](https://platform.openai.com/docs/guides/speech-to-text) for transcription.
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
new TranscriptionServiceOpenAI({
|
|
32
|
+
openai: new OpenAI({ apiKey: "..." }), // required
|
|
33
|
+
model: "whisper-1", // default
|
|
34
|
+
language: "en", // optional, ISO-639-1 code
|
|
35
|
+
prompt: "Technical discussion context", // optional, helps with domain terms
|
|
36
|
+
temperature: 0, // optional, 0 = deterministic
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Custom providers
|
|
41
|
+
|
|
42
|
+
Extend `TranscriptionService` from runtime:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import {
|
|
46
|
+
TranscriptionService,
|
|
47
|
+
TranscribeFileOptions,
|
|
48
|
+
} from "@copilotkit/runtime";
|
|
49
|
+
|
|
50
|
+
class MyTranscriptionService extends TranscriptionService {
|
|
51
|
+
async transcribeFile(options: TranscribeFileOptions): Promise<string> {
|
|
52
|
+
// options.audioFile, options.mimeType, options.size
|
|
53
|
+
return "transcribed text";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_transcription_service_openai = require('./transcription/transcription-service-openai.cjs');
|
|
3
|
+
|
|
4
|
+
exports.TranscriptionServiceOpenAI = require_transcription_service_openai.TranscriptionServiceOpenAI;
|
package/dist/index.d.cts
ADDED
package/dist/index.d.mts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@copilotkit/runtime/v2'), require('openai')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@copilotkit/runtime/v2', 'openai'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitVoice = {}), global._copilotkit_runtime_v2,global.openai));
|
|
5
|
+
})(this, function(exports, _copilotkit_runtime_v2, openai) {
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
7
|
+
//#region \0rolldown/runtime.js
|
|
8
|
+
var __create = Object.create;
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
17
|
+
key = keys[i];
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
19
|
+
__defProp(to, key, {
|
|
20
|
+
get: ((k) => from[k]).bind(null, key),
|
|
21
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
29
|
+
value: mod,
|
|
30
|
+
enumerable: true
|
|
31
|
+
}) : target, mod));
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
openai = __toESM(openai);
|
|
35
|
+
|
|
36
|
+
//#region \0@oxc-project+runtime@0.112.0/helpers/typeof.js
|
|
37
|
+
function _typeof(o) {
|
|
38
|
+
"@babel/helpers - typeof";
|
|
39
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
40
|
+
return typeof o;
|
|
41
|
+
} : function(o) {
|
|
42
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
43
|
+
}, _typeof(o);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region \0@oxc-project+runtime@0.112.0/helpers/toPrimitive.js
|
|
48
|
+
function toPrimitive(t, r) {
|
|
49
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
50
|
+
var e = t[Symbol.toPrimitive];
|
|
51
|
+
if (void 0 !== e) {
|
|
52
|
+
var i = e.call(t, r || "default");
|
|
53
|
+
if ("object" != _typeof(i)) return i;
|
|
54
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
55
|
+
}
|
|
56
|
+
return ("string" === r ? String : Number)(t);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region \0@oxc-project+runtime@0.112.0/helpers/toPropertyKey.js
|
|
61
|
+
function toPropertyKey(t) {
|
|
62
|
+
var i = toPrimitive(t, "string");
|
|
63
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region \0@oxc-project+runtime@0.112.0/helpers/defineProperty.js
|
|
68
|
+
function _defineProperty(e, r, t) {
|
|
69
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
70
|
+
value: t,
|
|
71
|
+
enumerable: !0,
|
|
72
|
+
configurable: !0,
|
|
73
|
+
writable: !0
|
|
74
|
+
}) : e[r] = t, e;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/transcription/transcription-service-openai.ts
|
|
79
|
+
var TranscriptionServiceOpenAI = class extends _copilotkit_runtime_v2.TranscriptionService {
|
|
80
|
+
constructor(config) {
|
|
81
|
+
var _config$openai, _config$model;
|
|
82
|
+
super();
|
|
83
|
+
_defineProperty(this, "openai", void 0);
|
|
84
|
+
_defineProperty(this, "model", void 0);
|
|
85
|
+
_defineProperty(this, "language", void 0);
|
|
86
|
+
_defineProperty(this, "prompt", void 0);
|
|
87
|
+
_defineProperty(this, "temperature", void 0);
|
|
88
|
+
this.openai = (_config$openai = config.openai) !== null && _config$openai !== void 0 ? _config$openai : new openai.default();
|
|
89
|
+
this.model = (_config$model = config.model) !== null && _config$model !== void 0 ? _config$model : "whisper-1";
|
|
90
|
+
this.language = config.language;
|
|
91
|
+
this.prompt = config.prompt;
|
|
92
|
+
this.temperature = config.temperature;
|
|
93
|
+
}
|
|
94
|
+
async transcribeFile(options) {
|
|
95
|
+
return (await this.openai.audio.transcriptions.create({
|
|
96
|
+
file: options.audioFile,
|
|
97
|
+
model: this.model,
|
|
98
|
+
...this.language && { language: this.language },
|
|
99
|
+
...this.prompt && { prompt: this.prompt },
|
|
100
|
+
...this.temperature !== void 0 && { temperature: this.temperature }
|
|
101
|
+
})).text;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
exports.TranscriptionServiceOpenAI = TranscriptionServiceOpenAI;
|
|
107
|
+
});
|
|
108
|
+
//# sourceMappingURL=index.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.umd.js","names":["TranscriptionService","OpenAI"],"sources":["../src/transcription/transcription-service-openai.ts"],"sourcesContent":["import {\n TranscribeFileOptions,\n TranscriptionService,\n} from \"@copilotkit/runtime/v2\";\nimport OpenAI from \"openai\";\n\n/**\n * Configuration options for the OpenAI transcription service.\n */\nexport interface TranscriptionServiceOpenAIConfig {\n /** OpenAI client instance. */\n openai: OpenAI;\n /** Whisper model to use. Defaults to \"whisper-1\". */\n model?: string;\n /**\n * Language of the audio in ISO-639-1 format (e.g., \"en\", \"de\", \"fr\").\n * Providing the language improves accuracy and latency.\n */\n language?: string;\n /**\n * Optional text to guide the model's style or continue a previous segment.\n * Should match the audio language.\n */\n prompt?: string;\n /**\n * Sampling temperature between 0 and 1.\n * Lower values are more deterministic, higher values more creative.\n */\n temperature?: number;\n}\n\nexport class TranscriptionServiceOpenAI extends TranscriptionService {\n private openai: OpenAI;\n private model: string;\n private language?: string;\n private prompt?: string;\n private temperature?: number;\n\n constructor(config: TranscriptionServiceOpenAIConfig) {\n super();\n this.openai = config.openai ?? new OpenAI();\n this.model = config.model ?? \"whisper-1\";\n this.language = config.language;\n this.prompt = config.prompt;\n this.temperature = config.temperature;\n }\n\n async transcribeFile(options: TranscribeFileOptions): Promise<string> {\n const response = await this.openai.audio.transcriptions.create({\n file: options.audioFile,\n model: this.model,\n ...(this.language && { language: this.language }),\n ...(this.prompt && { prompt: this.prompt }),\n ...(this.temperature !== undefined && { temperature: this.temperature }),\n });\n return response.text;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BA,IAAa,6BAAb,cAAgDA,4CAAqB;EAOnE,YAAY,QAA0C;;AACpD,UAAO;yBAPD;yBACA;yBACA;yBACA;yBACA;AAIN,QAAK,2BAAS,OAAO,iEAAU,IAAIC,gBAAQ;AAC3C,QAAK,yBAAQ,OAAO,8DAAS;AAC7B,QAAK,WAAW,OAAO;AACvB,QAAK,SAAS,OAAO;AACrB,QAAK,cAAc,OAAO;;EAG5B,MAAM,eAAe,SAAiD;AAQpE,WAPiB,MAAM,KAAK,OAAO,MAAM,eAAe,OAAO;IAC7D,MAAM,QAAQ;IACd,OAAO,KAAK;IACZ,GAAI,KAAK,YAAY,EAAE,UAAU,KAAK,UAAU;IAChD,GAAI,KAAK,UAAU,EAAE,QAAQ,KAAK,QAAQ;IAC1C,GAAI,KAAK,gBAAgB,UAAa,EAAE,aAAa,KAAK,aAAa;IACxE,CAAC,EACc"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
let _copilotkit_runtime_v2 = require("@copilotkit/runtime/v2");
|
|
3
|
+
let openai = require("openai");
|
|
4
|
+
openai = require_runtime.__toESM(openai);
|
|
5
|
+
|
|
6
|
+
//#region src/transcription/transcription-service-openai.ts
|
|
7
|
+
var TranscriptionServiceOpenAI = class extends _copilotkit_runtime_v2.TranscriptionService {
|
|
8
|
+
openai;
|
|
9
|
+
model;
|
|
10
|
+
language;
|
|
11
|
+
prompt;
|
|
12
|
+
temperature;
|
|
13
|
+
constructor(config) {
|
|
14
|
+
super();
|
|
15
|
+
this.openai = config.openai ?? new openai.default();
|
|
16
|
+
this.model = config.model ?? "whisper-1";
|
|
17
|
+
this.language = config.language;
|
|
18
|
+
this.prompt = config.prompt;
|
|
19
|
+
this.temperature = config.temperature;
|
|
20
|
+
}
|
|
21
|
+
async transcribeFile(options) {
|
|
22
|
+
return (await this.openai.audio.transcriptions.create({
|
|
23
|
+
file: options.audioFile,
|
|
24
|
+
model: this.model,
|
|
25
|
+
...this.language && { language: this.language },
|
|
26
|
+
...this.prompt && { prompt: this.prompt },
|
|
27
|
+
...this.temperature !== void 0 && { temperature: this.temperature }
|
|
28
|
+
})).text;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
exports.TranscriptionServiceOpenAI = TranscriptionServiceOpenAI;
|
|
34
|
+
//# sourceMappingURL=transcription-service-openai.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcription-service-openai.cjs","names":["TranscriptionService","OpenAI"],"sources":["../../src/transcription/transcription-service-openai.ts"],"sourcesContent":["import {\n TranscribeFileOptions,\n TranscriptionService,\n} from \"@copilotkit/runtime/v2\";\nimport OpenAI from \"openai\";\n\n/**\n * Configuration options for the OpenAI transcription service.\n */\nexport interface TranscriptionServiceOpenAIConfig {\n /** OpenAI client instance. */\n openai: OpenAI;\n /** Whisper model to use. Defaults to \"whisper-1\". */\n model?: string;\n /**\n * Language of the audio in ISO-639-1 format (e.g., \"en\", \"de\", \"fr\").\n * Providing the language improves accuracy and latency.\n */\n language?: string;\n /**\n * Optional text to guide the model's style or continue a previous segment.\n * Should match the audio language.\n */\n prompt?: string;\n /**\n * Sampling temperature between 0 and 1.\n * Lower values are more deterministic, higher values more creative.\n */\n temperature?: number;\n}\n\nexport class TranscriptionServiceOpenAI extends TranscriptionService {\n private openai: OpenAI;\n private model: string;\n private language?: string;\n private prompt?: string;\n private temperature?: number;\n\n constructor(config: TranscriptionServiceOpenAIConfig) {\n super();\n this.openai = config.openai ?? new OpenAI();\n this.model = config.model ?? \"whisper-1\";\n this.language = config.language;\n this.prompt = config.prompt;\n this.temperature = config.temperature;\n }\n\n async transcribeFile(options: TranscribeFileOptions): Promise<string> {\n const response = await this.openai.audio.transcriptions.create({\n file: options.audioFile,\n model: this.model,\n ...(this.language && { language: this.language }),\n ...(this.prompt && { prompt: this.prompt }),\n ...(this.temperature !== undefined && { temperature: this.temperature }),\n });\n return response.text;\n }\n}\n"],"mappings":";;;;;;AA+BA,IAAa,6BAAb,cAAgDA,4CAAqB;CACnE,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,YAAY,QAA0C;AACpD,SAAO;AACP,OAAK,SAAS,OAAO,UAAU,IAAIC,gBAAQ;AAC3C,OAAK,QAAQ,OAAO,SAAS;AAC7B,OAAK,WAAW,OAAO;AACvB,OAAK,SAAS,OAAO;AACrB,OAAK,cAAc,OAAO;;CAG5B,MAAM,eAAe,SAAiD;AAQpE,UAPiB,MAAM,KAAK,OAAO,MAAM,eAAe,OAAO;GAC7D,MAAM,QAAQ;GACd,OAAO,KAAK;GACZ,GAAI,KAAK,YAAY,EAAE,UAAU,KAAK,UAAU;GAChD,GAAI,KAAK,UAAU,EAAE,QAAQ,KAAK,QAAQ;GAC1C,GAAI,KAAK,gBAAgB,UAAa,EAAE,aAAa,KAAK,aAAa;GACxE,CAAC,EACc"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TranscribeFileOptions, TranscriptionService } from "@copilotkit/runtime/v2";
|
|
2
|
+
import OpenAI from "openai";
|
|
3
|
+
|
|
4
|
+
//#region src/transcription/transcription-service-openai.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for the OpenAI transcription service.
|
|
7
|
+
*/
|
|
8
|
+
interface TranscriptionServiceOpenAIConfig {
|
|
9
|
+
/** OpenAI client instance. */
|
|
10
|
+
openai: OpenAI;
|
|
11
|
+
/** Whisper model to use. Defaults to "whisper-1". */
|
|
12
|
+
model?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Language of the audio in ISO-639-1 format (e.g., "en", "de", "fr").
|
|
15
|
+
* Providing the language improves accuracy and latency.
|
|
16
|
+
*/
|
|
17
|
+
language?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Optional text to guide the model's style or continue a previous segment.
|
|
20
|
+
* Should match the audio language.
|
|
21
|
+
*/
|
|
22
|
+
prompt?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Sampling temperature between 0 and 1.
|
|
25
|
+
* Lower values are more deterministic, higher values more creative.
|
|
26
|
+
*/
|
|
27
|
+
temperature?: number;
|
|
28
|
+
}
|
|
29
|
+
declare class TranscriptionServiceOpenAI extends TranscriptionService {
|
|
30
|
+
private openai;
|
|
31
|
+
private model;
|
|
32
|
+
private language?;
|
|
33
|
+
private prompt?;
|
|
34
|
+
private temperature?;
|
|
35
|
+
constructor(config: TranscriptionServiceOpenAIConfig);
|
|
36
|
+
transcribeFile(options: TranscribeFileOptions): Promise<string>;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { TranscriptionServiceOpenAI, TranscriptionServiceOpenAIConfig };
|
|
40
|
+
//# sourceMappingURL=transcription-service-openai.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcription-service-openai.d.cts","names":[],"sources":["../../src/transcription/transcription-service-openai.ts"],"mappings":";;;;;;AASA;UAAiB,gCAAA;;EAEf,MAAA,EAAQ,MAAA;EAAR;EAEA,KAAA;EAAA;;;;EAKA,QAAA;EAUW;AAGb;;;EARE,MAAA;EAwB8B;;;;EAnB9B,WAAA;AAAA;AAAA,cAGW,0BAAA,SAAmC,oBAAA;EAAA,QACtC,MAAA;EAAA,QACA,KAAA;EAAA,QACA,QAAA;EAAA,QACA,MAAA;EAAA,QACA,WAAA;cAEI,MAAA,EAAQ,gCAAA;EASd,cAAA,CAAe,OAAA,EAAS,qBAAA,GAAwB,OAAA;AAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TranscribeFileOptions, TranscriptionService } from "@copilotkit/runtime/v2";
|
|
2
|
+
import OpenAI from "openai";
|
|
3
|
+
|
|
4
|
+
//#region src/transcription/transcription-service-openai.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for the OpenAI transcription service.
|
|
7
|
+
*/
|
|
8
|
+
interface TranscriptionServiceOpenAIConfig {
|
|
9
|
+
/** OpenAI client instance. */
|
|
10
|
+
openai: OpenAI;
|
|
11
|
+
/** Whisper model to use. Defaults to "whisper-1". */
|
|
12
|
+
model?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Language of the audio in ISO-639-1 format (e.g., "en", "de", "fr").
|
|
15
|
+
* Providing the language improves accuracy and latency.
|
|
16
|
+
*/
|
|
17
|
+
language?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Optional text to guide the model's style or continue a previous segment.
|
|
20
|
+
* Should match the audio language.
|
|
21
|
+
*/
|
|
22
|
+
prompt?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Sampling temperature between 0 and 1.
|
|
25
|
+
* Lower values are more deterministic, higher values more creative.
|
|
26
|
+
*/
|
|
27
|
+
temperature?: number;
|
|
28
|
+
}
|
|
29
|
+
declare class TranscriptionServiceOpenAI extends TranscriptionService {
|
|
30
|
+
private openai;
|
|
31
|
+
private model;
|
|
32
|
+
private language?;
|
|
33
|
+
private prompt?;
|
|
34
|
+
private temperature?;
|
|
35
|
+
constructor(config: TranscriptionServiceOpenAIConfig);
|
|
36
|
+
transcribeFile(options: TranscribeFileOptions): Promise<string>;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { TranscriptionServiceOpenAI, TranscriptionServiceOpenAIConfig };
|
|
40
|
+
//# sourceMappingURL=transcription-service-openai.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcription-service-openai.d.mts","names":[],"sources":["../../src/transcription/transcription-service-openai.ts"],"mappings":";;;;;;AASA;UAAiB,gCAAA;;EAEf,MAAA,EAAQ,MAAA;EAAR;EAEA,KAAA;EAAA;;;;EAKA,QAAA;EAUW;AAGb;;;EARE,MAAA;EAwB8B;;;;EAnB9B,WAAA;AAAA;AAAA,cAGW,0BAAA,SAAmC,oBAAA;EAAA,QACtC,MAAA;EAAA,QACA,KAAA;EAAA,QACA,QAAA;EAAA,QACA,MAAA;EAAA,QACA,WAAA;cAEI,MAAA,EAAQ,gCAAA;EASd,cAAA,CAAe,OAAA,EAAS,qBAAA,GAAwB,OAAA;AAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TranscriptionService } from "@copilotkit/runtime/v2";
|
|
2
|
+
import OpenAI from "openai";
|
|
3
|
+
|
|
4
|
+
//#region src/transcription/transcription-service-openai.ts
|
|
5
|
+
var TranscriptionServiceOpenAI = class extends TranscriptionService {
|
|
6
|
+
openai;
|
|
7
|
+
model;
|
|
8
|
+
language;
|
|
9
|
+
prompt;
|
|
10
|
+
temperature;
|
|
11
|
+
constructor(config) {
|
|
12
|
+
super();
|
|
13
|
+
this.openai = config.openai ?? new OpenAI();
|
|
14
|
+
this.model = config.model ?? "whisper-1";
|
|
15
|
+
this.language = config.language;
|
|
16
|
+
this.prompt = config.prompt;
|
|
17
|
+
this.temperature = config.temperature;
|
|
18
|
+
}
|
|
19
|
+
async transcribeFile(options) {
|
|
20
|
+
return (await this.openai.audio.transcriptions.create({
|
|
21
|
+
file: options.audioFile,
|
|
22
|
+
model: this.model,
|
|
23
|
+
...this.language && { language: this.language },
|
|
24
|
+
...this.prompt && { prompt: this.prompt },
|
|
25
|
+
...this.temperature !== void 0 && { temperature: this.temperature }
|
|
26
|
+
})).text;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { TranscriptionServiceOpenAI };
|
|
32
|
+
//# sourceMappingURL=transcription-service-openai.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcription-service-openai.mjs","names":[],"sources":["../../src/transcription/transcription-service-openai.ts"],"sourcesContent":["import {\n TranscribeFileOptions,\n TranscriptionService,\n} from \"@copilotkit/runtime/v2\";\nimport OpenAI from \"openai\";\n\n/**\n * Configuration options for the OpenAI transcription service.\n */\nexport interface TranscriptionServiceOpenAIConfig {\n /** OpenAI client instance. */\n openai: OpenAI;\n /** Whisper model to use. Defaults to \"whisper-1\". */\n model?: string;\n /**\n * Language of the audio in ISO-639-1 format (e.g., \"en\", \"de\", \"fr\").\n * Providing the language improves accuracy and latency.\n */\n language?: string;\n /**\n * Optional text to guide the model's style or continue a previous segment.\n * Should match the audio language.\n */\n prompt?: string;\n /**\n * Sampling temperature between 0 and 1.\n * Lower values are more deterministic, higher values more creative.\n */\n temperature?: number;\n}\n\nexport class TranscriptionServiceOpenAI extends TranscriptionService {\n private openai: OpenAI;\n private model: string;\n private language?: string;\n private prompt?: string;\n private temperature?: number;\n\n constructor(config: TranscriptionServiceOpenAIConfig) {\n super();\n this.openai = config.openai ?? new OpenAI();\n this.model = config.model ?? \"whisper-1\";\n this.language = config.language;\n this.prompt = config.prompt;\n this.temperature = config.temperature;\n }\n\n async transcribeFile(options: TranscribeFileOptions): Promise<string> {\n const response = await this.openai.audio.transcriptions.create({\n file: options.audioFile,\n model: this.model,\n ...(this.language && { language: this.language }),\n ...(this.prompt && { prompt: this.prompt }),\n ...(this.temperature !== undefined && { temperature: this.temperature }),\n });\n return response.text;\n }\n}\n"],"mappings":";;;;AA+BA,IAAa,6BAAb,cAAgD,qBAAqB;CACnE,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,YAAY,QAA0C;AACpD,SAAO;AACP,OAAK,SAAS,OAAO,UAAU,IAAI,QAAQ;AAC3C,OAAK,QAAQ,OAAO,SAAS;AAC7B,OAAK,WAAW,OAAO;AACvB,OAAK,SAAS,OAAO;AACrB,OAAK,cAAc,OAAO;;CAG5B,MAAM,eAAe,SAAiD;AAQpE,UAPiB,MAAM,KAAK,OAAO,MAAM,eAAe,OAAO;GAC7D,MAAM,QAAQ;GACd,OAAO,KAAK;GACZ,GAAI,KAAK,YAAY,EAAE,UAAU,KAAK,UAAU;GAChD,GAAI,KAAK,UAAU,EAAE,QAAQ,KAAK,QAAQ;GAC1C,GAAI,KAAK,gBAAgB,UAAa,EAAE,aAAa,KAAK,aAAa;GACxE,CAAC,EACc"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@copilotkit/voice",
|
|
3
|
+
"version": "0.0.0-a2ui-v0-9-latest-20260408115931",
|
|
4
|
+
"description": "Voice services for CopilotKit (transcription, text-to-speech, etc.)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.cts",
|
|
9
|
+
"unpkg": "./dist/index.umd.js",
|
|
10
|
+
"jsdelivr": "./dist/index.umd.js",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
15
|
+
},
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"openai": "^5.9.0",
|
|
23
|
+
"@copilotkit/runtime": "0.0.0-a2ui-v0-9-latest-20260408115931"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^22.15.3",
|
|
27
|
+
"tsdown": "^0.20.3",
|
|
28
|
+
"typescript": "5.8.2",
|
|
29
|
+
"vitest": "^3.0.5",
|
|
30
|
+
"@copilotkit/typescript-config": "0.0.0-a2ui-v0-9-latest-20260408115931"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsdown",
|
|
37
|
+
"dev": "tsdown --watch",
|
|
38
|
+
"check-types": "tsc --noEmit",
|
|
39
|
+
"test": "vitest run",
|
|
40
|
+
"test:watch": "vitest",
|
|
41
|
+
"test:coverage": "vitest run --coverage",
|
|
42
|
+
"publint": "publint .",
|
|
43
|
+
"attw": "attw --pack . --profile node16"
|
|
44
|
+
}
|
|
45
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TranscribeFileOptions,
|
|
3
|
+
TranscriptionService,
|
|
4
|
+
} from "@copilotkit/runtime/v2";
|
|
5
|
+
import OpenAI from "openai";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Configuration options for the OpenAI transcription service.
|
|
9
|
+
*/
|
|
10
|
+
export interface TranscriptionServiceOpenAIConfig {
|
|
11
|
+
/** OpenAI client instance. */
|
|
12
|
+
openai: OpenAI;
|
|
13
|
+
/** Whisper model to use. Defaults to "whisper-1". */
|
|
14
|
+
model?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Language of the audio in ISO-639-1 format (e.g., "en", "de", "fr").
|
|
17
|
+
* Providing the language improves accuracy and latency.
|
|
18
|
+
*/
|
|
19
|
+
language?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Optional text to guide the model's style or continue a previous segment.
|
|
22
|
+
* Should match the audio language.
|
|
23
|
+
*/
|
|
24
|
+
prompt?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Sampling temperature between 0 and 1.
|
|
27
|
+
* Lower values are more deterministic, higher values more creative.
|
|
28
|
+
*/
|
|
29
|
+
temperature?: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class TranscriptionServiceOpenAI extends TranscriptionService {
|
|
33
|
+
private openai: OpenAI;
|
|
34
|
+
private model: string;
|
|
35
|
+
private language?: string;
|
|
36
|
+
private prompt?: string;
|
|
37
|
+
private temperature?: number;
|
|
38
|
+
|
|
39
|
+
constructor(config: TranscriptionServiceOpenAIConfig) {
|
|
40
|
+
super();
|
|
41
|
+
this.openai = config.openai ?? new OpenAI();
|
|
42
|
+
this.model = config.model ?? "whisper-1";
|
|
43
|
+
this.language = config.language;
|
|
44
|
+
this.prompt = config.prompt;
|
|
45
|
+
this.temperature = config.temperature;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async transcribeFile(options: TranscribeFileOptions): Promise<string> {
|
|
49
|
+
const response = await this.openai.audio.transcriptions.create({
|
|
50
|
+
file: options.audioFile,
|
|
51
|
+
model: this.model,
|
|
52
|
+
...(this.language && { language: this.language }),
|
|
53
|
+
...(this.prompt && { prompt: this.prompt }),
|
|
54
|
+
...(this.temperature !== undefined && { temperature: this.temperature }),
|
|
55
|
+
});
|
|
56
|
+
return response.text;
|
|
57
|
+
}
|
|
58
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@copilotkit/typescript-config/base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
"rootDir": "src",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"sourceMap": true
|
|
9
|
+
},
|
|
10
|
+
"include": ["src/**/*"],
|
|
11
|
+
"exclude": ["dist", "node_modules"]
|
|
12
|
+
}
|
package/tsdown.config.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { defineConfig } from "tsdown";
|
|
2
|
+
|
|
3
|
+
const isWatch = process.argv.includes("--watch");
|
|
4
|
+
|
|
5
|
+
export default defineConfig([
|
|
6
|
+
{
|
|
7
|
+
entry: ["src/index.ts"],
|
|
8
|
+
format: ["esm", "cjs"],
|
|
9
|
+
dts: !isWatch,
|
|
10
|
+
sourcemap: true,
|
|
11
|
+
clean: !isWatch,
|
|
12
|
+
target: "es2022",
|
|
13
|
+
outDir: "dist",
|
|
14
|
+
unbundle: true,
|
|
15
|
+
exports: true,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
entry: ["src/index.ts"],
|
|
19
|
+
format: ["umd"],
|
|
20
|
+
globalName: "CopilotKitVoice",
|
|
21
|
+
sourcemap: true,
|
|
22
|
+
target: "es2018",
|
|
23
|
+
outDir: "dist",
|
|
24
|
+
external: [],
|
|
25
|
+
codeSplitting: false,
|
|
26
|
+
outputOptions(options) {
|
|
27
|
+
options.entryFileNames = "[name].umd.js";
|
|
28
|
+
options.globals = {
|
|
29
|
+
"@copilotkit/runtime": "CopilotKitRuntime",
|
|
30
|
+
openai: "openai",
|
|
31
|
+
};
|
|
32
|
+
return options;
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
]);
|