@elevenlabs/client 0.11.2 → 0.12.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/.turbo/turbo-build.log +24 -12
- package/.turbo/turbo-generate-version.log +1 -1
- package/README.md +5 -0
- package/dist/BaseConversation.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/lib.cjs +1 -1
- package/dist/lib.cjs.map +1 -1
- package/dist/lib.modern.js +1 -1
- package/dist/lib.modern.js.map +1 -1
- package/dist/lib.module.js +1 -1
- package/dist/lib.module.js.map +1 -1
- package/dist/lib.umd.js +1 -1
- package/dist/lib.umd.js.map +1 -1
- package/dist/scribe/connection.d.ts +59 -12
- package/dist/scribe/index.d.ts +2 -1
- package/dist/utils/events.d.ts +3 -2
- package/dist/utils/input.d.ts +1 -0
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { SessionStartedMessage, PartialTranscriptMessage, CommittedTranscriptMessage, CommittedTranscriptWithTimestampsMessage, ScribeErrorMessage, ScribeAuthErrorMessage, ScribeQuotaExceededErrorMessage } from "@elevenlabs/types";
|
|
2
|
-
export type { SessionStartedMessage, PartialTranscriptMessage, CommittedTranscriptMessage, CommittedTranscriptWithTimestampsMessage, ScribeErrorMessage, ScribeAuthErrorMessage, ScribeQuotaExceededErrorMessage, };
|
|
3
|
-
export type WebSocketMessage = SessionStartedMessage | PartialTranscriptMessage | CommittedTranscriptMessage | CommittedTranscriptWithTimestampsMessage | ScribeErrorMessage | ScribeAuthErrorMessage | ScribeQuotaExceededErrorMessage;
|
|
1
|
+
import type { SessionStartedMessage, PartialTranscriptMessage, CommittedTranscriptMessage, CommittedTranscriptWithTimestampsMessage, ScribeErrorMessage, ScribeAuthErrorMessage, ScribeQuotaExceededErrorMessage, ScribeCommitThrottledErrorMessage, ScribeTranscriberErrorMessage, ScribeUnacceptedTermsErrorMessage, ScribeRateLimitedErrorMessage, ScribeInputErrorMessage, ScribeQueueOverflowErrorMessage, ScribeResourceExhaustedErrorMessage, ScribeSessionTimeLimitExceededErrorMessage, ScribeChunkSizeExceededErrorMessage, ScribeInsufficientAudioActivityErrorMessage } from "@elevenlabs/types";
|
|
2
|
+
export type { SessionStartedMessage, PartialTranscriptMessage, CommittedTranscriptMessage, CommittedTranscriptWithTimestampsMessage, ScribeErrorMessage, ScribeAuthErrorMessage, ScribeQuotaExceededErrorMessage, ScribeCommitThrottledErrorMessage, ScribeTranscriberErrorMessage, ScribeUnacceptedTermsErrorMessage, ScribeRateLimitedErrorMessage, ScribeInputErrorMessage, ScribeQueueOverflowErrorMessage, ScribeResourceExhaustedErrorMessage, ScribeSessionTimeLimitExceededErrorMessage, ScribeChunkSizeExceededErrorMessage, ScribeInsufficientAudioActivityErrorMessage, };
|
|
3
|
+
export type WebSocketMessage = SessionStartedMessage | PartialTranscriptMessage | CommittedTranscriptMessage | CommittedTranscriptWithTimestampsMessage | ScribeErrorMessage | ScribeAuthErrorMessage | ScribeQuotaExceededErrorMessage | ScribeCommitThrottledErrorMessage | ScribeTranscriberErrorMessage | ScribeUnacceptedTermsErrorMessage | ScribeRateLimitedErrorMessage | ScribeInputErrorMessage | ScribeQueueOverflowErrorMessage | ScribeResourceExhaustedErrorMessage | ScribeSessionTimeLimitExceededErrorMessage | ScribeChunkSizeExceededErrorMessage | ScribeInsufficientAudioActivityErrorMessage;
|
|
4
4
|
/**
|
|
5
5
|
* Events emitted by the RealtimeConnection.
|
|
6
6
|
*/
|
|
@@ -15,14 +15,58 @@ export declare enum RealtimeEvents {
|
|
|
15
15
|
COMMITTED_TRANSCRIPT_WITH_TIMESTAMPS = "committed_transcript_with_timestamps",
|
|
16
16
|
/** Emitted when an authentication error occurs */
|
|
17
17
|
AUTH_ERROR = "auth_error",
|
|
18
|
-
/** Emitted when an error occurs */
|
|
18
|
+
/** Emitted when an error occurs (also emitted for all specific error types) */
|
|
19
19
|
ERROR = "error",
|
|
20
20
|
/** Emitted when the WebSocket connection is opened */
|
|
21
21
|
OPEN = "open",
|
|
22
22
|
/** Emitted when the WebSocket connection is closed */
|
|
23
23
|
CLOSE = "close",
|
|
24
24
|
/** Emitted when a quota exceeded error occurs */
|
|
25
|
-
QUOTA_EXCEEDED = "quota_exceeded"
|
|
25
|
+
QUOTA_EXCEEDED = "quota_exceeded",
|
|
26
|
+
/** Emitted when commit is throttled */
|
|
27
|
+
COMMIT_THROTTLED = "commit_throttled",
|
|
28
|
+
/** Emitted when a transcriber error occurs */
|
|
29
|
+
TRANSCRIBER_ERROR = "transcriber_error",
|
|
30
|
+
/** Emitted when terms have not been accepted */
|
|
31
|
+
UNACCEPTED_TERMS = "unaccepted_terms",
|
|
32
|
+
/** Emitted when rate limited */
|
|
33
|
+
RATE_LIMITED = "rate_limited",
|
|
34
|
+
/** Emitted when there's an input error */
|
|
35
|
+
INPUT_ERROR = "input_error",
|
|
36
|
+
/** Emitted when the queue overflows */
|
|
37
|
+
QUEUE_OVERFLOW = "queue_overflow",
|
|
38
|
+
/** Emitted when resources are exhausted */
|
|
39
|
+
RESOURCE_EXHAUSTED = "resource_exhausted",
|
|
40
|
+
/** Emitted when session time limit is exceeded */
|
|
41
|
+
SESSION_TIME_LIMIT_EXCEEDED = "session_time_limit_exceeded",
|
|
42
|
+
/** Emitted when chunk size is exceeded */
|
|
43
|
+
CHUNK_SIZE_EXCEEDED = "chunk_size_exceeded",
|
|
44
|
+
/** Emitted when there's insufficient audio activity */
|
|
45
|
+
INSUFFICIENT_AUDIO_ACTIVITY = "insufficient_audio_activity"
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Map of event types to their payload types.
|
|
49
|
+
*/
|
|
50
|
+
export interface RealtimeEventMap {
|
|
51
|
+
[RealtimeEvents.SESSION_STARTED]: SessionStartedMessage;
|
|
52
|
+
[RealtimeEvents.PARTIAL_TRANSCRIPT]: PartialTranscriptMessage;
|
|
53
|
+
[RealtimeEvents.COMMITTED_TRANSCRIPT]: CommittedTranscriptMessage;
|
|
54
|
+
[RealtimeEvents.COMMITTED_TRANSCRIPT_WITH_TIMESTAMPS]: CommittedTranscriptWithTimestampsMessage;
|
|
55
|
+
[RealtimeEvents.ERROR]: ScribeErrorMessage;
|
|
56
|
+
[RealtimeEvents.AUTH_ERROR]: ScribeAuthErrorMessage;
|
|
57
|
+
[RealtimeEvents.QUOTA_EXCEEDED]: ScribeQuotaExceededErrorMessage;
|
|
58
|
+
[RealtimeEvents.COMMIT_THROTTLED]: ScribeCommitThrottledErrorMessage;
|
|
59
|
+
[RealtimeEvents.TRANSCRIBER_ERROR]: ScribeTranscriberErrorMessage;
|
|
60
|
+
[RealtimeEvents.UNACCEPTED_TERMS]: ScribeUnacceptedTermsErrorMessage;
|
|
61
|
+
[RealtimeEvents.RATE_LIMITED]: ScribeRateLimitedErrorMessage;
|
|
62
|
+
[RealtimeEvents.INPUT_ERROR]: ScribeInputErrorMessage;
|
|
63
|
+
[RealtimeEvents.QUEUE_OVERFLOW]: ScribeQueueOverflowErrorMessage;
|
|
64
|
+
[RealtimeEvents.RESOURCE_EXHAUSTED]: ScribeResourceExhaustedErrorMessage;
|
|
65
|
+
[RealtimeEvents.SESSION_TIME_LIMIT_EXCEEDED]: ScribeSessionTimeLimitExceededErrorMessage;
|
|
66
|
+
[RealtimeEvents.CHUNK_SIZE_EXCEEDED]: ScribeChunkSizeExceededErrorMessage;
|
|
67
|
+
[RealtimeEvents.INSUFFICIENT_AUDIO_ACTIVITY]: ScribeInsufficientAudioActivityErrorMessage;
|
|
68
|
+
[RealtimeEvents.OPEN]: undefined;
|
|
69
|
+
[RealtimeEvents.CLOSE]: CloseEvent;
|
|
26
70
|
}
|
|
27
71
|
/**
|
|
28
72
|
* Manages a real-time transcription WebSocket connection.
|
|
@@ -76,19 +120,19 @@ export declare class RealtimeConnection {
|
|
|
76
120
|
* @example
|
|
77
121
|
* ```typescript
|
|
78
122
|
* connection.on(RealtimeEvents.SESSION_STARTED, (data) => {
|
|
79
|
-
* console.log("Session started", data);
|
|
123
|
+
* console.log("Session started", data.session_id);
|
|
80
124
|
* });
|
|
81
125
|
*
|
|
82
126
|
* connection.on(RealtimeEvents.PARTIAL_TRANSCRIPT, (data) => {
|
|
83
|
-
* console.log("Partial:", data.
|
|
127
|
+
* console.log("Partial:", data.text);
|
|
84
128
|
* });
|
|
85
129
|
*
|
|
86
130
|
* connection.on(RealtimeEvents.COMMITTED_TRANSCRIPT, (data) => {
|
|
87
|
-
* console.log("Final:", data.
|
|
131
|
+
* console.log("Final:", data.text);
|
|
88
132
|
* });
|
|
89
133
|
* ```
|
|
90
134
|
*/
|
|
91
|
-
on(event:
|
|
135
|
+
on<E extends RealtimeEvents>(event: E, listener: RealtimeEventMap[E] extends undefined ? () => void : (data: RealtimeEventMap[E]) => void): void;
|
|
92
136
|
/**
|
|
93
137
|
* Removes an event listener for the specified event.
|
|
94
138
|
*
|
|
@@ -97,14 +141,14 @@ export declare class RealtimeConnection {
|
|
|
97
141
|
*
|
|
98
142
|
* @example
|
|
99
143
|
* ```typescript
|
|
100
|
-
* const handler = (data) => console.log(data);
|
|
144
|
+
* const handler = (data: PartialTranscriptMessage) => console.log(data.text);
|
|
101
145
|
* connection.on(RealtimeEvents.PARTIAL_TRANSCRIPT, handler);
|
|
102
146
|
*
|
|
103
147
|
* // Later, remove the listener
|
|
104
148
|
* connection.off(RealtimeEvents.PARTIAL_TRANSCRIPT, handler);
|
|
105
149
|
* ```
|
|
106
150
|
*/
|
|
107
|
-
off(event:
|
|
151
|
+
off<E extends RealtimeEvents>(event: E, listener: RealtimeEventMap[E] extends undefined ? () => void : (data: RealtimeEventMap[E]) => void): void;
|
|
108
152
|
/**
|
|
109
153
|
* Sends audio data to the transcription service.
|
|
110
154
|
*
|
|
@@ -112,6 +156,7 @@ export declare class RealtimeConnection {
|
|
|
112
156
|
* @param data.audioBase64 - Base64-encoded audio data
|
|
113
157
|
* @param data.commit - Whether to commit the transcription after this chunk. You likely want to use connection.commit() instead (default: false)
|
|
114
158
|
* @param data.sampleRate - Sample rate of the audio (default: configured sample rate)
|
|
159
|
+
* @param data.previousText - Send context to the model via base64 encoded audio or text from a previous transcription. Can only be sent alongside the first audio chunk. If sent in a subsequent chunk, an error will be returned.
|
|
115
160
|
*
|
|
116
161
|
* @throws {Error} If the WebSocket connection is not open
|
|
117
162
|
*
|
|
@@ -122,10 +167,11 @@ export declare class RealtimeConnection {
|
|
|
122
167
|
* audioBase64: base64EncodedAudio,
|
|
123
168
|
* });
|
|
124
169
|
*
|
|
125
|
-
* // Send audio chunk with custom sample rate
|
|
170
|
+
* // Send audio chunk with custom sample rate and previous text
|
|
126
171
|
* connection.send({
|
|
127
172
|
* audioBase64: base64EncodedAudio,
|
|
128
173
|
* sampleRate: 16000,
|
|
174
|
+
* previousText: "Previous transcription text",
|
|
129
175
|
* });
|
|
130
176
|
* ```
|
|
131
177
|
*/
|
|
@@ -133,6 +179,7 @@ export declare class RealtimeConnection {
|
|
|
133
179
|
audioBase64: string;
|
|
134
180
|
commit?: boolean;
|
|
135
181
|
sampleRate?: number;
|
|
182
|
+
previousText?: string;
|
|
136
183
|
}): void;
|
|
137
184
|
/**
|
|
138
185
|
* Commits the transcription, signaling that a segment of audio has been sent. This clears the buffer and triggers a COMMITTED_TRANSCRIPT event. Context from previous segments is kept.
|
package/dist/scribe/index.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ export { ScribeRealtime as Scribe } from "./scribe";
|
|
|
2
2
|
export { RealtimeConnection } from "./connection";
|
|
3
3
|
export { AudioFormat, CommitStrategy } from "./scribe";
|
|
4
4
|
export { RealtimeEvents } from "./connection";
|
|
5
|
+
export type { RealtimeEventMap } from "./connection";
|
|
5
6
|
export type { AudioOptions, MicrophoneOptions } from "./scribe";
|
|
6
|
-
export type { WebSocketMessage, SessionStartedMessage, PartialTranscriptMessage, CommittedTranscriptMessage, CommittedTranscriptWithTimestampsMessage, ScribeErrorMessage, ScribeAuthErrorMessage, ScribeQuotaExceededErrorMessage, } from "./connection";
|
|
7
|
+
export type { WebSocketMessage, SessionStartedMessage, PartialTranscriptMessage, CommittedTranscriptMessage, CommittedTranscriptWithTimestampsMessage, ScribeErrorMessage, ScribeAuthErrorMessage, ScribeQuotaExceededErrorMessage, ScribeCommitThrottledErrorMessage, ScribeTranscriberErrorMessage, ScribeUnacceptedTermsErrorMessage, ScribeRateLimitedErrorMessage, ScribeInputErrorMessage, ScribeQueueOverflowErrorMessage, ScribeResourceExhaustedErrorMessage, ScribeSessionTimeLimitExceededErrorMessage, ScribeChunkSizeExceededErrorMessage, ScribeInsufficientAudioActivityErrorMessage, } from "./connection";
|
package/dist/utils/events.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Outgoing } from "@elevenlabs/types";
|
|
2
|
-
import { AgentChatResponsePartClientEvent, AgentResponse, AgentResponseCorrection, AgentToolResponseClientEvent, AsrInitiationMetadataEvent as AsrMetadataEvent, Audio, ClientToolCallMessage, ConversationMetadata, ErrorMessage, Interruption, McpConnectionStatusClientEvent, McpToolCall, Ping, InternalTentativeAgentResponse as TentativeAgentResponseInternal, UserTranscript, VadScore } from "@elevenlabs/types/generated/types/asyncapi-types";
|
|
2
|
+
import { AgentChatResponsePartClientEvent, AgentResponse, AgentResponseCorrection, AgentToolResponseClientEvent, AsrInitiationMetadataEvent as AsrMetadataEvent, Audio, AgentToolRequestClientEvent, ClientToolCallMessage, ConversationMetadata, ErrorMessage, Interruption, McpConnectionStatusClientEvent, McpToolCall, Ping, InternalTentativeAgentResponse as TentativeAgentResponseInternal, UserTranscript, VadScore } from "@elevenlabs/types/generated/types/asyncapi-types";
|
|
3
3
|
export type UserTranscriptionEvent = UserTranscript;
|
|
4
4
|
export type AgentResponseEvent = AgentResponse;
|
|
5
5
|
export type AgentAudioEvent = Audio;
|
|
@@ -11,13 +11,14 @@ export type ClientToolCallEvent = ClientToolCallMessage;
|
|
|
11
11
|
export type VadScoreEvent = VadScore;
|
|
12
12
|
export type MCPToolCallClientEvent = McpToolCall;
|
|
13
13
|
export type AgentResponseCorrectionEvent = AgentResponseCorrection;
|
|
14
|
+
export type AgentToolRequestEvent = AgentToolRequestClientEvent;
|
|
14
15
|
export type AgentToolResponseEvent = AgentToolResponseClientEvent;
|
|
15
16
|
export type ConversationMetadataEvent = ConversationMetadata;
|
|
16
17
|
export type AsrInitiationMetadataEvent = AsrMetadataEvent;
|
|
17
18
|
export type MCPConnectionStatusEvent = McpConnectionStatusClientEvent;
|
|
18
19
|
export type AgentChatResponsePartEvent = AgentChatResponsePartClientEvent;
|
|
19
20
|
export type ErrorMessageEvent = ErrorMessage;
|
|
20
|
-
export type IncomingSocketEvent = UserTranscriptionEvent | AgentResponseEvent | AgentResponseCorrectionEvent | AgentAudioEvent | InterruptionEvent | InternalTentativeAgentResponseEvent | ConfigEvent | PingEvent | ClientToolCallEvent | VadScoreEvent | MCPToolCallClientEvent | AgentToolResponseEvent | ConversationMetadataEvent | AsrInitiationMetadataEvent | MCPConnectionStatusEvent | AgentChatResponsePartEvent | ErrorMessageEvent;
|
|
21
|
+
export type IncomingSocketEvent = UserTranscriptionEvent | AgentResponseEvent | AgentResponseCorrectionEvent | AgentAudioEvent | InterruptionEvent | InternalTentativeAgentResponseEvent | ConfigEvent | PingEvent | ClientToolCallEvent | VadScoreEvent | MCPToolCallClientEvent | AgentToolRequestEvent | AgentToolResponseEvent | ConversationMetadataEvent | AsrInitiationMetadataEvent | MCPConnectionStatusEvent | AgentChatResponsePartEvent | ErrorMessageEvent;
|
|
21
22
|
export type PongEvent = Outgoing.PongClientToOrchestratorEvent;
|
|
22
23
|
export type UserAudioEvent = Outgoing.UserAudio;
|
|
23
24
|
export type UserFeedbackEvent = Outgoing.UserFeedbackClientToOrchestratorEvent;
|
package/dist/utils/input.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare class Input {
|
|
|
11
11
|
inputStream: MediaStream;
|
|
12
12
|
private mediaStreamSource;
|
|
13
13
|
static create({ sampleRate, format, preferHeadphonesForIosDevices, inputDeviceId, workletPaths, libsampleratePath, }: FormatConfig & InputConfig & AudioWorkletConfig): Promise<Input>;
|
|
14
|
+
private static getDeviceIdConstraint;
|
|
14
15
|
private constructor();
|
|
15
16
|
close(): Promise<void>;
|
|
16
17
|
setMuted(isMuted: boolean): void;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "0.
|
|
1
|
+
export declare const PACKAGE_VERSION = "0.12.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elevenlabs/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "ElevenLabs JavaScript Client Library",
|
|
5
5
|
"main": "./dist/lib.umd.js",
|
|
6
6
|
"module": "./dist/lib.module.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"livekit-client": "^2.11.4",
|
|
42
|
-
"@elevenlabs/types": "0.
|
|
42
|
+
"@elevenlabs/types": "0.4.0"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"generate-version": "printf \"// This file is auto-generated during build\\nexport const PACKAGE_VERSION = \\\"%s\\\";\\n\" \"$npm_package_version\" > src/version.ts",
|