@jambonz/speech-utils 0.2.26 → 0.2.27
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/lib/synth-audio.js +10 -2
- package/package.json +1 -1
- package/test/synth.js +1 -1
package/lib/synth-audio.js
CHANGED
|
@@ -1329,7 +1329,7 @@ const synthCartesia = async(logger, {
|
|
|
1329
1329
|
try {
|
|
1330
1330
|
const client = new CartesiaClient({ apiKey: api_key });
|
|
1331
1331
|
const sampleRate = 48000;
|
|
1332
|
-
const
|
|
1332
|
+
const mp3Stream = await client.tts.bytes({
|
|
1333
1333
|
modelId: model_id,
|
|
1334
1334
|
transcript: text,
|
|
1335
1335
|
voice: {
|
|
@@ -1363,8 +1363,16 @@ const synthCartesia = async(logger, {
|
|
|
1363
1363
|
sampleRate
|
|
1364
1364
|
},
|
|
1365
1365
|
});
|
|
1366
|
+
|
|
1367
|
+
// bytes() returns a ReadableStream - collect all chunks
|
|
1368
|
+
const chunks = [];
|
|
1369
|
+
for await (const chunk of mp3Stream) {
|
|
1370
|
+
chunks.push(chunk);
|
|
1371
|
+
}
|
|
1372
|
+
const audioBuffer = Buffer.concat(chunks);
|
|
1373
|
+
|
|
1366
1374
|
return {
|
|
1367
|
-
audioContent:
|
|
1375
|
+
audioContent: audioBuffer,
|
|
1368
1376
|
extension: 'mp3',
|
|
1369
1377
|
sampleRate
|
|
1370
1378
|
};
|
package/package.json
CHANGED
package/test/synth.js
CHANGED
|
@@ -716,7 +716,7 @@ test('Cartesia speech synth tests', async(t) => {
|
|
|
716
716
|
text,
|
|
717
717
|
renderForCaching: true
|
|
718
718
|
});
|
|
719
|
-
t.ok(!opts.servedFromCache, `successfully
|
|
719
|
+
t.ok(!opts.servedFromCache, `successfully cartesia eleven audio to ${opts.filePath}`);
|
|
720
720
|
|
|
721
721
|
} catch (err) {
|
|
722
722
|
console.error(JSON.stringify(err));
|