hume 0.9.14 → 0.9.15
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/.mock/definition/tts/__package__.yml +82 -4
- package/api/resources/empathicVoice/resources/chatGroups/client/Client.js +4 -4
- package/api/resources/empathicVoice/resources/chats/client/Client.js +3 -3
- package/api/resources/empathicVoice/resources/configs/client/Client.js +9 -9
- package/api/resources/empathicVoice/resources/customVoices/client/Client.js +6 -6
- package/api/resources/empathicVoice/resources/prompts/client/Client.js +9 -9
- package/api/resources/empathicVoice/resources/tools/client/Client.js +9 -9
- package/api/resources/expressionMeasurement/resources/batch/client/Client.js +6 -6
- package/api/resources/tts/client/Client.d.ts +11 -0
- package/api/resources/tts/client/Client.js +124 -2
- package/api/resources/tts/resources/voices/client/Client.js +1 -1
- package/api/resources/tts/types/Snippet.d.ts +0 -2
- package/core/index.d.ts +1 -0
- package/core/index.js +1 -0
- package/core/streaming-fetcher/Stream.d.ts +48 -0
- package/core/streaming-fetcher/Stream.js +170 -0
- package/core/streaming-fetcher/index.d.ts +1 -0
- package/core/streaming-fetcher/index.js +5 -0
- package/dist/api/resources/empathicVoice/resources/chatGroups/client/Client.js +4 -4
- package/dist/api/resources/empathicVoice/resources/chats/client/Client.js +3 -3
- package/dist/api/resources/empathicVoice/resources/configs/client/Client.js +9 -9
- package/dist/api/resources/empathicVoice/resources/customVoices/client/Client.js +6 -6
- package/dist/api/resources/empathicVoice/resources/prompts/client/Client.js +9 -9
- package/dist/api/resources/empathicVoice/resources/tools/client/Client.js +9 -9
- package/dist/api/resources/expressionMeasurement/resources/batch/client/Client.js +6 -6
- package/dist/api/resources/tts/client/Client.d.ts +11 -0
- package/dist/api/resources/tts/client/Client.js +124 -2
- package/dist/api/resources/tts/resources/voices/client/Client.js +1 -1
- package/dist/api/resources/tts/types/Snippet.d.ts +0 -2
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/streaming-fetcher/Stream.d.ts +48 -0
- package/dist/core/streaming-fetcher/Stream.js +170 -0
- package/dist/core/streaming-fetcher/index.d.ts +1 -0
- package/dist/core/streaming-fetcher/index.js +5 -0
- package/dist/serialization/resources/tts/types/Snippet.d.ts +0 -1
- package/dist/serialization/resources/tts/types/Snippet.js +0 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/reference.md +163 -0
- package/serialization/resources/tts/types/Snippet.d.ts +0 -1
- package/serialization/resources/tts/types/Snippet.js +0 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
+
var m = o[Symbol.asyncIterator], i;
|
|
14
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
+
};
|
|
18
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
19
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
20
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
21
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
22
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
23
|
+
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
24
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
25
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
26
|
+
function fulfill(value) { resume("next", value); }
|
|
27
|
+
function reject(value) { resume("throw", value); }
|
|
28
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.readableStreamAsyncIterable = exports.Stream = void 0;
|
|
32
|
+
const runtime_1 = require("../runtime");
|
|
33
|
+
const DATA_PREFIX = "data:";
|
|
34
|
+
class Stream {
|
|
35
|
+
constructor({ stream, parse, eventShape, signal }) {
|
|
36
|
+
this.controller = new AbortController();
|
|
37
|
+
this.stream = stream;
|
|
38
|
+
this.parse = parse;
|
|
39
|
+
if (eventShape.type === "sse") {
|
|
40
|
+
this.prefix = DATA_PREFIX;
|
|
41
|
+
this.messageTerminator = "\n";
|
|
42
|
+
this.streamTerminator = eventShape.streamTerminator;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
this.messageTerminator = eventShape.messageTerminator;
|
|
46
|
+
}
|
|
47
|
+
signal === null || signal === void 0 ? void 0 : signal.addEventListener("abort", () => this.controller.abort());
|
|
48
|
+
}
|
|
49
|
+
iterMessages() {
|
|
50
|
+
return __asyncGenerator(this, arguments, function* iterMessages_1() {
|
|
51
|
+
var e_1, _a;
|
|
52
|
+
this.controller.signal;
|
|
53
|
+
const stream = readableStreamAsyncIterable(this.stream);
|
|
54
|
+
let buf = "";
|
|
55
|
+
let prefixSeen = false;
|
|
56
|
+
try {
|
|
57
|
+
for (var stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield __await(stream_1.next()), !stream_1_1.done;) {
|
|
58
|
+
const chunk = stream_1_1.value;
|
|
59
|
+
buf += this.decodeChunk(chunk);
|
|
60
|
+
let terminatorIndex;
|
|
61
|
+
// Parse the chunk into as many messages as possible
|
|
62
|
+
while ((terminatorIndex = buf.indexOf(this.messageTerminator)) >= 0) {
|
|
63
|
+
// Extract the line from the buffer
|
|
64
|
+
let line = buf.slice(0, terminatorIndex + 1);
|
|
65
|
+
buf = buf.slice(terminatorIndex + 1);
|
|
66
|
+
// Skip empty lines
|
|
67
|
+
if (line.length === 0) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
// Skip the chunk until the prefix is found
|
|
71
|
+
if (!prefixSeen && this.prefix != null) {
|
|
72
|
+
const prefixIndex = line.indexOf(this.prefix);
|
|
73
|
+
if (prefixIndex === -1) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
prefixSeen = true;
|
|
77
|
+
line = line.slice(prefixIndex + this.prefix.length);
|
|
78
|
+
}
|
|
79
|
+
// If the stream terminator is present, return
|
|
80
|
+
if (this.streamTerminator != null && line.includes(this.streamTerminator)) {
|
|
81
|
+
return yield __await(void 0);
|
|
82
|
+
}
|
|
83
|
+
// Otherwise, yield message from the prefix to the terminator
|
|
84
|
+
const message = yield __await(this.parse(JSON.parse(line)));
|
|
85
|
+
yield yield __await(message);
|
|
86
|
+
prefixSeen = false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
91
|
+
finally {
|
|
92
|
+
try {
|
|
93
|
+
if (stream_1_1 && !stream_1_1.done && (_a = stream_1.return)) yield __await(_a.call(stream_1));
|
|
94
|
+
}
|
|
95
|
+
finally { if (e_1) throw e_1.error; }
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
[Symbol.asyncIterator]() {
|
|
100
|
+
return __asyncGenerator(this, arguments, function* _a() {
|
|
101
|
+
var e_2, _b;
|
|
102
|
+
try {
|
|
103
|
+
for (var _c = __asyncValues(this.iterMessages()), _d; _d = yield __await(_c.next()), !_d.done;) {
|
|
104
|
+
const message = _d.value;
|
|
105
|
+
yield yield __await(message);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
109
|
+
finally {
|
|
110
|
+
try {
|
|
111
|
+
if (_d && !_d.done && (_b = _c.return)) yield __await(_b.call(_c));
|
|
112
|
+
}
|
|
113
|
+
finally { if (e_2) throw e_2.error; }
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
decodeChunk(chunk) {
|
|
118
|
+
let decoded = "";
|
|
119
|
+
// If TextDecoder is present, use it
|
|
120
|
+
if (typeof TextDecoder !== "undefined") {
|
|
121
|
+
const decoder = new TextDecoder("utf8");
|
|
122
|
+
decoded += decoder.decode(chunk);
|
|
123
|
+
}
|
|
124
|
+
// Buffer is present in Node.js environment
|
|
125
|
+
else if (runtime_1.RUNTIME.type === "node" && typeof chunk != "undefined") {
|
|
126
|
+
decoded += Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
127
|
+
}
|
|
128
|
+
return decoded;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.Stream = Stream;
|
|
132
|
+
/**
|
|
133
|
+
* Browser polyfill for ReadableStream
|
|
134
|
+
*/
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
136
|
+
function readableStreamAsyncIterable(stream) {
|
|
137
|
+
if (stream[Symbol.asyncIterator]) {
|
|
138
|
+
return stream;
|
|
139
|
+
}
|
|
140
|
+
const reader = stream.getReader();
|
|
141
|
+
return {
|
|
142
|
+
next() {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
try {
|
|
145
|
+
const result = yield reader.read();
|
|
146
|
+
if (result === null || result === void 0 ? void 0 : result.done) {
|
|
147
|
+
reader.releaseLock();
|
|
148
|
+
} // release lock when stream becomes closed
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
catch (e) {
|
|
152
|
+
reader.releaseLock(); // release lock when stream becomes errored
|
|
153
|
+
throw e;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
return() {
|
|
158
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
const cancelPromise = reader.cancel();
|
|
160
|
+
reader.releaseLock();
|
|
161
|
+
yield cancelPromise;
|
|
162
|
+
return { done: true, value: undefined };
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
[Symbol.asyncIterator]() {
|
|
166
|
+
return this;
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
exports.readableStreamAsyncIterable = readableStreamAsyncIterable;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Stream } from "./Stream";
|
|
@@ -30,7 +30,6 @@ exports.Snippet = void 0;
|
|
|
30
30
|
const core = __importStar(require("../../../../core"));
|
|
31
31
|
exports.Snippet = core.serialization.object({
|
|
32
32
|
audio: core.serialization.string(),
|
|
33
|
-
audioFormat: core.serialization.property("audio_format", core.serialization.string()),
|
|
34
33
|
generationId: core.serialization.property("generation_id", core.serialization.string()),
|
|
35
34
|
id: core.serialization.string(),
|
|
36
35
|
text: core.serialization.string(),
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.9.
|
|
1
|
+
export declare const SDK_VERSION = "0.9.15";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
package/reference.md
CHANGED
|
@@ -168,6 +168,169 @@ await client.tts.synthesizeFile({
|
|
|
168
168
|
</dl>
|
|
169
169
|
</details>
|
|
170
170
|
|
|
171
|
+
<details><summary><code>client.tts.<a href="/src/api/resources/tts/client/Client.ts">synthesizeFileStreaming</a>({ ...params }) -> stream.Readable</code></summary>
|
|
172
|
+
<dl>
|
|
173
|
+
<dd>
|
|
174
|
+
|
|
175
|
+
#### 📝 Description
|
|
176
|
+
|
|
177
|
+
<dl>
|
|
178
|
+
<dd>
|
|
179
|
+
|
|
180
|
+
<dl>
|
|
181
|
+
<dd>
|
|
182
|
+
|
|
183
|
+
Streams synthesized speech using the specified voice. If no voice is provided, a novel voice will be generated dynamically. Optionally, additional context can be included to influence the speech's style and prosody.
|
|
184
|
+
|
|
185
|
+
</dd>
|
|
186
|
+
</dl>
|
|
187
|
+
</dd>
|
|
188
|
+
</dl>
|
|
189
|
+
|
|
190
|
+
#### 🔌 Usage
|
|
191
|
+
|
|
192
|
+
<dl>
|
|
193
|
+
<dd>
|
|
194
|
+
|
|
195
|
+
<dl>
|
|
196
|
+
<dd>
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
await client.tts.synthesizeFileStreaming({
|
|
200
|
+
utterances: [
|
|
201
|
+
{
|
|
202
|
+
text: "Beauty is no quality in things themselves: It exists merely in the mind which contemplates them.",
|
|
203
|
+
description:
|
|
204
|
+
"Middle-aged masculine voice with a clear, rhythmic Scots lilt, rounded vowels, and a warm, steady tone with an articulate, academic quality.",
|
|
205
|
+
},
|
|
206
|
+
],
|
|
207
|
+
context: {
|
|
208
|
+
generationId: "09ad914d-8e7f-40f8-a279-e34f07f7dab2",
|
|
209
|
+
},
|
|
210
|
+
format: {
|
|
211
|
+
type: "mp3",
|
|
212
|
+
},
|
|
213
|
+
numGenerations: 1,
|
|
214
|
+
});
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
</dd>
|
|
218
|
+
</dl>
|
|
219
|
+
</dd>
|
|
220
|
+
</dl>
|
|
221
|
+
|
|
222
|
+
#### ⚙️ Parameters
|
|
223
|
+
|
|
224
|
+
<dl>
|
|
225
|
+
<dd>
|
|
226
|
+
|
|
227
|
+
<dl>
|
|
228
|
+
<dd>
|
|
229
|
+
|
|
230
|
+
**request:** `Hume.PostedTts`
|
|
231
|
+
|
|
232
|
+
</dd>
|
|
233
|
+
</dl>
|
|
234
|
+
|
|
235
|
+
<dl>
|
|
236
|
+
<dd>
|
|
237
|
+
|
|
238
|
+
**requestOptions:** `Tts.RequestOptions`
|
|
239
|
+
|
|
240
|
+
</dd>
|
|
241
|
+
</dl>
|
|
242
|
+
</dd>
|
|
243
|
+
</dl>
|
|
244
|
+
|
|
245
|
+
</dd>
|
|
246
|
+
</dl>
|
|
247
|
+
</details>
|
|
248
|
+
|
|
249
|
+
<details><summary><code>client.tts.<a href="/src/api/resources/tts/client/Client.ts">synthesizeJsonStreaming</a>({ ...params }) -> core.Stream<Hume.Snippet></code></summary>
|
|
250
|
+
<dl>
|
|
251
|
+
<dd>
|
|
252
|
+
|
|
253
|
+
#### 📝 Description
|
|
254
|
+
|
|
255
|
+
<dl>
|
|
256
|
+
<dd>
|
|
257
|
+
|
|
258
|
+
<dl>
|
|
259
|
+
<dd>
|
|
260
|
+
|
|
261
|
+
Streams synthesized speech using the specified voice. If no voice is provided, a novel voice will be generated dynamically. Optionally, additional context can be included to influence the speech's style and prosody.
|
|
262
|
+
|
|
263
|
+
The response is a stream of JSON objects including audio encoded in base64.
|
|
264
|
+
|
|
265
|
+
</dd>
|
|
266
|
+
</dl>
|
|
267
|
+
</dd>
|
|
268
|
+
</dl>
|
|
269
|
+
|
|
270
|
+
#### 🔌 Usage
|
|
271
|
+
|
|
272
|
+
<dl>
|
|
273
|
+
<dd>
|
|
274
|
+
|
|
275
|
+
<dl>
|
|
276
|
+
<dd>
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
await client.tts.synthesizeJsonStreaming({
|
|
280
|
+
utterances: [
|
|
281
|
+
{
|
|
282
|
+
text: "Beauty is no quality in things themselves: It exists merely in the mind which contemplates them.",
|
|
283
|
+
description:
|
|
284
|
+
"Middle-aged masculine voice with a clear, rhythmic Scots lilt, rounded vowels, and a warm, steady tone with an articulate, academic quality.",
|
|
285
|
+
},
|
|
286
|
+
],
|
|
287
|
+
context: {
|
|
288
|
+
utterances: [
|
|
289
|
+
{
|
|
290
|
+
text: "How can people see beauty so differently?",
|
|
291
|
+
description:
|
|
292
|
+
"A curious student with a clear and respectful tone, seeking clarification on Hume's ideas with a straightforward question.",
|
|
293
|
+
},
|
|
294
|
+
],
|
|
295
|
+
},
|
|
296
|
+
format: {
|
|
297
|
+
type: "mp3",
|
|
298
|
+
},
|
|
299
|
+
});
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
</dd>
|
|
303
|
+
</dl>
|
|
304
|
+
</dd>
|
|
305
|
+
</dl>
|
|
306
|
+
|
|
307
|
+
#### ⚙️ Parameters
|
|
308
|
+
|
|
309
|
+
<dl>
|
|
310
|
+
<dd>
|
|
311
|
+
|
|
312
|
+
<dl>
|
|
313
|
+
<dd>
|
|
314
|
+
|
|
315
|
+
**request:** `Hume.PostedTts`
|
|
316
|
+
|
|
317
|
+
</dd>
|
|
318
|
+
</dl>
|
|
319
|
+
|
|
320
|
+
<dl>
|
|
321
|
+
<dd>
|
|
322
|
+
|
|
323
|
+
**requestOptions:** `Tts.RequestOptions`
|
|
324
|
+
|
|
325
|
+
</dd>
|
|
326
|
+
</dl>
|
|
327
|
+
</dd>
|
|
328
|
+
</dl>
|
|
329
|
+
|
|
330
|
+
</dd>
|
|
331
|
+
</dl>
|
|
332
|
+
</details>
|
|
333
|
+
|
|
171
334
|
## Tts Voices
|
|
172
335
|
|
|
173
336
|
<details><summary><code>client.tts.voices.<a href="/src/api/resources/tts/resources/voices/client/Client.ts">create</a>({ ...params }) -> Hume.ReturnVoice</code></summary>
|
|
@@ -30,7 +30,6 @@ exports.Snippet = void 0;
|
|
|
30
30
|
const core = __importStar(require("../../../../core"));
|
|
31
31
|
exports.Snippet = core.serialization.object({
|
|
32
32
|
audio: core.serialization.string(),
|
|
33
|
-
audioFormat: core.serialization.property("audio_format", core.serialization.string()),
|
|
34
33
|
generationId: core.serialization.property("generation_id", core.serialization.string()),
|
|
35
34
|
id: core.serialization.string(),
|
|
36
35
|
text: core.serialization.string(),
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.9.
|
|
1
|
+
export declare const SDK_VERSION = "0.9.15";
|
package/version.js
CHANGED