@elevenlabs/elevenlabs-js 2.24.0 → 2.24.1
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/README.md +3 -3
- package/dist/wrapper/realtime/connection.d.ts +18 -1
- package/dist/wrapper/realtime/connection.js +13 -0
- package/dist/wrapper/realtime/scribe.d.ts +5 -0
- package/dist/wrapper/realtime/scribe.js +3 -0
- package/package.json +1 -1
- package/wrapper/realtime/connection.d.ts +18 -1
- package/wrapper/realtime/connection.js +13 -0
- package/wrapper/realtime/scribe.d.ts +5 -0
- package/wrapper/realtime/scribe.js +3 -0
package/README.md
CHANGED
|
@@ -99,7 +99,7 @@ stream(audioStream);
|
|
|
99
99
|
## Retries
|
|
100
100
|
|
|
101
101
|
This Node SDK is instrumented with automatic retries with exponential backoff. A request will be
|
|
102
|
-
retried as long as the request is deemed
|
|
102
|
+
retried as long as the request is deemed retry-able and the number of retry attempts has not grown larger
|
|
103
103
|
than the configured retry limit (default: 2).
|
|
104
104
|
|
|
105
105
|
A request is deemed able to retry when any of the following HTTP status codes is returned:
|
|
@@ -122,7 +122,7 @@ const response = await elevenlabs.voices.search(
|
|
|
122
122
|
|
|
123
123
|
## Timeouts
|
|
124
124
|
|
|
125
|
-
The SDK defaults to a 60 second
|
|
125
|
+
The SDK defaults to a 60 second timeout. Use the `timeoutInSeconds` option to
|
|
126
126
|
configure this behavior.
|
|
127
127
|
|
|
128
128
|
```ts
|
|
@@ -134,7 +134,7 @@ const response = await elevenlabs.voices.search(
|
|
|
134
134
|
);
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
-
## Runtime
|
|
137
|
+
## Runtime compatibility
|
|
138
138
|
|
|
139
139
|
The SDK defaults to `node-fetch` but will use the global fetch client if present. The SDK
|
|
140
140
|
works in the following runtimes:
|
|
@@ -28,6 +28,7 @@ export interface Config {
|
|
|
28
28
|
min_silence_duration_ms?: number;
|
|
29
29
|
model_id?: string;
|
|
30
30
|
disable_logging?: boolean;
|
|
31
|
+
include_timestamps?: boolean;
|
|
31
32
|
}
|
|
32
33
|
export interface SessionStartedMessage {
|
|
33
34
|
message_type: "session_started";
|
|
@@ -48,7 +49,19 @@ export interface CommittedTranscriptWithTimestampsMessage {
|
|
|
48
49
|
language_code?: string;
|
|
49
50
|
words?: WordsItem[];
|
|
50
51
|
}
|
|
51
|
-
export
|
|
52
|
+
export interface ErrorMessage {
|
|
53
|
+
message_type: "error";
|
|
54
|
+
error: string;
|
|
55
|
+
}
|
|
56
|
+
export interface AuthErrorMessage {
|
|
57
|
+
message_type: "auth_error";
|
|
58
|
+
error: string;
|
|
59
|
+
}
|
|
60
|
+
export interface QuotaExceededErrorMessage {
|
|
61
|
+
message_type: "quota_exceeded";
|
|
62
|
+
error: string;
|
|
63
|
+
}
|
|
64
|
+
export type WebSocketMessage = SessionStartedMessage | PartialTranscriptMessage | CommittedTranscriptMessage | CommittedTranscriptWithTimestampsMessage | ErrorMessage | AuthErrorMessage | QuotaExceededErrorMessage;
|
|
52
65
|
/**
|
|
53
66
|
* Events emitted by the RealtimeConnection.
|
|
54
67
|
*/
|
|
@@ -63,6 +76,10 @@ export declare enum RealtimeEvents {
|
|
|
63
76
|
COMMITTED_TRANSCRIPT_WITH_TIMESTAMPS = "committed_transcript_with_timestamps",
|
|
64
77
|
/** Emitted when an error occurs */
|
|
65
78
|
ERROR = "error",
|
|
79
|
+
/** Emitted when an auth error occurs */
|
|
80
|
+
AUTH_ERROR = "auth_error",
|
|
81
|
+
/** Emitted when a quota exceeded error occurs */
|
|
82
|
+
QUOTA_EXCEEDED = "quota_exceeded",
|
|
66
83
|
/** Emitted when the WebSocket connection is opened */
|
|
67
84
|
OPEN = "open",
|
|
68
85
|
/** Emitted when the WebSocket connection is closed */
|
|
@@ -21,6 +21,10 @@ var RealtimeEvents;
|
|
|
21
21
|
RealtimeEvents["COMMITTED_TRANSCRIPT_WITH_TIMESTAMPS"] = "committed_transcript_with_timestamps";
|
|
22
22
|
/** Emitted when an error occurs */
|
|
23
23
|
RealtimeEvents["ERROR"] = "error";
|
|
24
|
+
/** Emitted when an auth error occurs */
|
|
25
|
+
RealtimeEvents["AUTH_ERROR"] = "auth_error";
|
|
26
|
+
/** Emitted when a quota exceeded error occurs */
|
|
27
|
+
RealtimeEvents["QUOTA_EXCEEDED"] = "quota_exceeded";
|
|
24
28
|
/** Emitted when the WebSocket connection is opened */
|
|
25
29
|
RealtimeEvents["OPEN"] = "open";
|
|
26
30
|
/** Emitted when the WebSocket connection is closed */
|
|
@@ -99,6 +103,15 @@ class RealtimeConnection {
|
|
|
99
103
|
case "committed_transcript_with_timestamps":
|
|
100
104
|
this.eventEmitter.emit(RealtimeEvents.COMMITTED_TRANSCRIPT_WITH_TIMESTAMPS, data);
|
|
101
105
|
break;
|
|
106
|
+
case "error":
|
|
107
|
+
this.eventEmitter.emit(RealtimeEvents.ERROR, data);
|
|
108
|
+
break;
|
|
109
|
+
case "auth_error":
|
|
110
|
+
this.eventEmitter.emit(RealtimeEvents.AUTH_ERROR, data);
|
|
111
|
+
break;
|
|
112
|
+
case "quota_exceeded":
|
|
113
|
+
this.eventEmitter.emit(RealtimeEvents.QUOTA_EXCEEDED, data);
|
|
114
|
+
break;
|
|
102
115
|
}
|
|
103
116
|
});
|
|
104
117
|
this.websocket.on("error", (error) => {
|
|
@@ -49,6 +49,11 @@ interface BaseOptions {
|
|
|
49
49
|
* Can sometimes improve transcription performance if known beforehand.
|
|
50
50
|
*/
|
|
51
51
|
languageCode?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Whether to receive a committed_transcript_with_timestamps event which includes word-level timestamps.
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
includeTimestamps?: boolean;
|
|
52
57
|
}
|
|
53
58
|
export interface AudioOptions extends BaseOptions {
|
|
54
59
|
audioFormat: AudioFormat;
|
|
@@ -136,6 +136,9 @@ class ScribeRealtime {
|
|
|
136
136
|
if (options.languageCode !== undefined) {
|
|
137
137
|
params.append("language_code", options.languageCode);
|
|
138
138
|
}
|
|
139
|
+
if (options.includeTimestamps !== undefined) {
|
|
140
|
+
params.append("include_timestamps", options.includeTimestamps.toString());
|
|
141
|
+
}
|
|
139
142
|
const queryString = params.toString();
|
|
140
143
|
return queryString ? `${baseUri}?${queryString}` : baseUri;
|
|
141
144
|
});
|
package/package.json
CHANGED
|
@@ -28,6 +28,7 @@ export interface Config {
|
|
|
28
28
|
min_silence_duration_ms?: number;
|
|
29
29
|
model_id?: string;
|
|
30
30
|
disable_logging?: boolean;
|
|
31
|
+
include_timestamps?: boolean;
|
|
31
32
|
}
|
|
32
33
|
export interface SessionStartedMessage {
|
|
33
34
|
message_type: "session_started";
|
|
@@ -48,7 +49,19 @@ export interface CommittedTranscriptWithTimestampsMessage {
|
|
|
48
49
|
language_code?: string;
|
|
49
50
|
words?: WordsItem[];
|
|
50
51
|
}
|
|
51
|
-
export
|
|
52
|
+
export interface ErrorMessage {
|
|
53
|
+
message_type: "error";
|
|
54
|
+
error: string;
|
|
55
|
+
}
|
|
56
|
+
export interface AuthErrorMessage {
|
|
57
|
+
message_type: "auth_error";
|
|
58
|
+
error: string;
|
|
59
|
+
}
|
|
60
|
+
export interface QuotaExceededErrorMessage {
|
|
61
|
+
message_type: "quota_exceeded";
|
|
62
|
+
error: string;
|
|
63
|
+
}
|
|
64
|
+
export type WebSocketMessage = SessionStartedMessage | PartialTranscriptMessage | CommittedTranscriptMessage | CommittedTranscriptWithTimestampsMessage | ErrorMessage | AuthErrorMessage | QuotaExceededErrorMessage;
|
|
52
65
|
/**
|
|
53
66
|
* Events emitted by the RealtimeConnection.
|
|
54
67
|
*/
|
|
@@ -63,6 +76,10 @@ export declare enum RealtimeEvents {
|
|
|
63
76
|
COMMITTED_TRANSCRIPT_WITH_TIMESTAMPS = "committed_transcript_with_timestamps",
|
|
64
77
|
/** Emitted when an error occurs */
|
|
65
78
|
ERROR = "error",
|
|
79
|
+
/** Emitted when an auth error occurs */
|
|
80
|
+
AUTH_ERROR = "auth_error",
|
|
81
|
+
/** Emitted when a quota exceeded error occurs */
|
|
82
|
+
QUOTA_EXCEEDED = "quota_exceeded",
|
|
66
83
|
/** Emitted when the WebSocket connection is opened */
|
|
67
84
|
OPEN = "open",
|
|
68
85
|
/** Emitted when the WebSocket connection is closed */
|
|
@@ -21,6 +21,10 @@ var RealtimeEvents;
|
|
|
21
21
|
RealtimeEvents["COMMITTED_TRANSCRIPT_WITH_TIMESTAMPS"] = "committed_transcript_with_timestamps";
|
|
22
22
|
/** Emitted when an error occurs */
|
|
23
23
|
RealtimeEvents["ERROR"] = "error";
|
|
24
|
+
/** Emitted when an auth error occurs */
|
|
25
|
+
RealtimeEvents["AUTH_ERROR"] = "auth_error";
|
|
26
|
+
/** Emitted when a quota exceeded error occurs */
|
|
27
|
+
RealtimeEvents["QUOTA_EXCEEDED"] = "quota_exceeded";
|
|
24
28
|
/** Emitted when the WebSocket connection is opened */
|
|
25
29
|
RealtimeEvents["OPEN"] = "open";
|
|
26
30
|
/** Emitted when the WebSocket connection is closed */
|
|
@@ -99,6 +103,15 @@ class RealtimeConnection {
|
|
|
99
103
|
case "committed_transcript_with_timestamps":
|
|
100
104
|
this.eventEmitter.emit(RealtimeEvents.COMMITTED_TRANSCRIPT_WITH_TIMESTAMPS, data);
|
|
101
105
|
break;
|
|
106
|
+
case "error":
|
|
107
|
+
this.eventEmitter.emit(RealtimeEvents.ERROR, data);
|
|
108
|
+
break;
|
|
109
|
+
case "auth_error":
|
|
110
|
+
this.eventEmitter.emit(RealtimeEvents.AUTH_ERROR, data);
|
|
111
|
+
break;
|
|
112
|
+
case "quota_exceeded":
|
|
113
|
+
this.eventEmitter.emit(RealtimeEvents.QUOTA_EXCEEDED, data);
|
|
114
|
+
break;
|
|
102
115
|
}
|
|
103
116
|
});
|
|
104
117
|
this.websocket.on("error", (error) => {
|
|
@@ -49,6 +49,11 @@ interface BaseOptions {
|
|
|
49
49
|
* Can sometimes improve transcription performance if known beforehand.
|
|
50
50
|
*/
|
|
51
51
|
languageCode?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Whether to receive a committed_transcript_with_timestamps event which includes word-level timestamps.
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
includeTimestamps?: boolean;
|
|
52
57
|
}
|
|
53
58
|
export interface AudioOptions extends BaseOptions {
|
|
54
59
|
audioFormat: AudioFormat;
|
|
@@ -136,6 +136,9 @@ class ScribeRealtime {
|
|
|
136
136
|
if (options.languageCode !== undefined) {
|
|
137
137
|
params.append("language_code", options.languageCode);
|
|
138
138
|
}
|
|
139
|
+
if (options.includeTimestamps !== undefined) {
|
|
140
|
+
params.append("include_timestamps", options.includeTimestamps.toString());
|
|
141
|
+
}
|
|
139
142
|
const queryString = params.toString();
|
|
140
143
|
return queryString ? `${baseUri}?${queryString}` : baseUri;
|
|
141
144
|
});
|