@livekit/agents-plugin-openai 0.9.3 → 1.0.0-next.0
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/dist/index.cjs +16 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/llm.cjs +156 -197
- package/dist/llm.cjs.map +1 -1
- package/dist/llm.d.cts +27 -8
- package/dist/llm.d.ts +27 -8
- package/dist/llm.d.ts.map +1 -1
- package/dist/llm.js +164 -188
- package/dist/llm.js.map +1 -1
- package/dist/models.cjs +14 -0
- package/dist/models.cjs.map +1 -1
- package/dist/models.d.cts +11 -6
- package/dist/models.d.ts +11 -6
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +6 -0
- package/dist/models.js.map +1 -1
- package/dist/realtime/api_proto.cjs.map +1 -1
- package/dist/realtime/api_proto.d.cts +15 -0
- package/dist/realtime/api_proto.d.ts +15 -0
- package/dist/realtime/api_proto.d.ts.map +1 -1
- package/dist/realtime/api_proto.js.map +1 -1
- package/dist/realtime/realtime_model.cjs +1057 -820
- package/dist/realtime/realtime_model.cjs.map +1 -1
- package/dist/realtime/realtime_model.d.cts +126 -160
- package/dist/realtime/realtime_model.d.ts +126 -160
- package/dist/realtime/realtime_model.d.ts.map +1 -1
- package/dist/realtime/realtime_model.js +1067 -825
- package/dist/realtime/realtime_model.js.map +1 -1
- package/dist/tts.cjs +5 -5
- package/dist/tts.cjs.map +1 -1
- package/dist/tts.d.cts +2 -1
- package/dist/tts.d.ts +2 -1
- package/dist/tts.d.ts.map +1 -1
- package/dist/tts.js +6 -6
- package/dist/tts.js.map +1 -1
- package/package.json +9 -7
- package/src/index.ts +19 -5
- package/src/llm.ts +227 -228
- package/src/models.ts +83 -5
- package/src/realtime/api_proto.ts +15 -1
- package/src/realtime/realtime_model.ts +1305 -996
- package/src/tts.ts +6 -6
package/src/tts.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
import { AudioByteStream, tts } from '@livekit/agents';
|
|
4
|
+
import { AudioByteStream, shortuuid, tts } from '@livekit/agents';
|
|
5
5
|
import type { AudioFrame } from '@livekit/rtc-node';
|
|
6
|
-
import { randomUUID } from 'crypto';
|
|
7
6
|
import { OpenAI } from 'openai';
|
|
8
7
|
import type { TTSModels, TTSVoices } from './models.js';
|
|
9
8
|
|
|
@@ -81,16 +80,17 @@ export class TTS extends tts.TTS {
|
|
|
81
80
|
|
|
82
81
|
export class ChunkedStream extends tts.ChunkedStream {
|
|
83
82
|
label = 'openai.ChunkedStream';
|
|
83
|
+
private stream: Promise<any>;
|
|
84
84
|
|
|
85
85
|
// set Promise<T> to any because OpenAI returns an annoying Response type
|
|
86
86
|
constructor(tts: TTS, text: string, stream: Promise<any>) {
|
|
87
87
|
super(text, tts);
|
|
88
|
-
this
|
|
88
|
+
this.stream = stream;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
async
|
|
92
|
-
const buffer = await stream.then((r) => r.arrayBuffer());
|
|
93
|
-
const requestId =
|
|
91
|
+
protected async run() {
|
|
92
|
+
const buffer = await this.stream.then((r) => r.arrayBuffer());
|
|
93
|
+
const requestId = shortuuid();
|
|
94
94
|
const audioByteStream = new AudioByteStream(OPENAI_TTS_SAMPLE_RATE, OPENAI_TTS_CHANNELS);
|
|
95
95
|
const frames = audioByteStream.write(buffer);
|
|
96
96
|
|