You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{CartesiaClient}from"@cartesia/cartesia-js";constcartesia=newCartesiaClient({apiKey: process.env.CARTESIA_API_KEY,});// Initialize the WebSocket. Make sure the output format you specify is supported.constwebsocket=cartesia.tts.websocket({container: "raw",encoding: "pcm_f32le",sampleRate: 44100,});// const websocket = cartesia.tts.websocket({// container: "raw",// encoding: "mp3",// sampleRate: 44100,// });try{awaitwebsocket.connect();}catch(error){console.error(`Failed to connect to Cartesia: ${error}`);throwerror;}// Create a stream.constresponse=awaitwebsocket.send({modelId: "sonic-english",voice: {mode: "id",id: "a0e99841-438c-4a64-b679-ae501e7d6091",},transcript: "Hello, world!",// The WebSocket sets output_format on your behalf.});// Access the raw messages from the WebSocket.response.on("message",(message)=>{// Raw message.console.log("Received message:",message);});// You can also access messages using a for-await-of loop.forawait(constmessageofresponse.events("message")){// Raw message.console.log("Received message:",message);}
What is the expected behavior?
running the same file with Node:
node experiments/cartesia.ts
(node:5611) ExperimentalWarning: Type Stripping is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Received message: {"type":"chunk","context_id":"chatty-paths-tan","status_code":206,"done":false,"data":"10PEuWAUT7kAj2m3QDGROKA29jjQIAU5gMgDOQCt6zgAXK84YA3NOFD1DDnwdh85sFYtOXAPPjkAcE45ECNCOfCQQDmwJUs50GxdORB9eTnIToA5OK+HORBukzn4epg5UDeXOQjQmDlI0ZY5+OmhOSj5rTl3/Ls5t3nFOYfbxTm36cc5J47JOacUyTmHPsc5Jy7JOefGzDmnF9o5BybnOcdU7DmnFPE5d8jvORfz8zn/LPk5t8v6OTvYATrD7Ag6l5sOOmMVFDrf5hY6s24UOlcEEjobPRE6XzwROp+1EjqXhRc692obOidVGzpPlRs6xwobOgdoGDrrLBQ6T48P.....
What do you see instead?
bun experiments/cartesia.ts
368 | if (this._closeCalled) {
369 | return;
370 | }
371 | this._debug("connect", { url, protocols: this._protocols });
372 | this._ws = this._protocols ? new WebSocket(url, this._protocols) : new WebSocket(url);
373 | this._ws.binaryType = this._binaryType;
^
SyntaxError: 'blob' is not a valid value for binaryType; binaryType remains unchanged.
at <anonymous> (/Users/salamanderxing/Documents/aikosmo/node_modules/@cartesia/cartesia-js/core/websocket/ws.js:373:18)
^C⏎
Additional information
You need a CARTESIA_API_KEY (you can get it for free: https://cartesia.ai/) in your environment but it should be possible to reproduce the error without it as well.
The text was updated successfully, but these errors were encountered:
What version of Bun is running?
1.2.2
What platform is your computer?
Darwin 24.3.0 arm64 arm
What steps can reproduce the bug?
Install:
Run the following code with Bun:
What is the expected behavior?
running the same file with Node:
What do you see instead?
Additional information
You need a CARTESIA_API_KEY (you can get it for free: https://cartesia.ai/) in your environment but it should be possible to reproduce the error without it as well.
The text was updated successfully, but these errors were encountered: