Compare commits

..
3 Commits
Author SHA1 Message Date
Dave Horton 5f7e7458bb 0.2.27 2025-11-17 07:26:45 -05:00
Dave Horton f6714fb9e1 Merge pull request #134 from jambonz/fix/1628
fixed cartesia collect audio from stream
2025-11-13 07:15:51 -05:00
Hoan HL c04ef29f7c fixed cartesia collect audio from stream 2025-11-13 14:10:00 +07:00
4 changed files with 14 additions and 6 deletions
+10 -2
View File
@@ -1329,7 +1329,7 @@ const synthCartesia = async(logger, {
try {
const client = new CartesiaClient({ apiKey: api_key });
const sampleRate = 48000;
const mp3 = await client.tts.bytes({
const mp3Stream = await client.tts.bytes({
modelId: model_id,
transcript: text,
voice: {
@@ -1363,8 +1363,16 @@ const synthCartesia = async(logger, {
sampleRate
},
});
// bytes() returns a ReadableStream - collect all chunks
const chunks = [];
for await (const chunk of mp3Stream) {
chunks.push(chunk);
}
const audioBuffer = Buffer.concat(chunks);
return {
audioContent: Buffer.from(mp3),
audioContent: audioBuffer,
extension: 'mp3',
sampleRate
};
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "@jambonz/speech-utils",
"version": "0.2.26",
"version": "0.2.27",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@jambonz/speech-utils",
"version": "0.2.26",
"version": "0.2.27",
"license": "MIT",
"dependencies": {
"23": "^0.0.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@jambonz/speech-utils",
"version": "0.2.26",
"version": "0.2.27",
"description": "TTS-related speech utilities for jambonz",
"main": "index.js",
"author": "Dave Horton",
+1 -1
View File
@@ -716,7 +716,7 @@ test('Cartesia speech synth tests', async(t) => {
text,
renderForCaching: true
});
t.ok(!opts.servedFromCache, `successfully playht eleven audio to ${opts.filePath}`);
t.ok(!opts.servedFromCache, `successfully cartesia eleven audio to ${opts.filePath}`);
} catch (err) {
console.error(JSON.stringify(err));