Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'blob' is not a valid value for binaryType #17005

Open
SalamanderXing opened this issue Feb 3, 2025 · 0 comments
Open

'blob' is not a valid value for binaryType #17005

SalamanderXing opened this issue Feb 3, 2025 · 0 comments
Labels
bug Something isn't working web:blob

Comments

@SalamanderXing
Copy link

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:

bun install @cartesia/cartesia-js

Run the following code with Bun:

import { CartesiaClient } from "@cartesia/cartesia-js";

const cartesia = new CartesiaClient({
  apiKey: process.env.CARTESIA_API_KEY,
});

// Initialize the WebSocket. Make sure the output format you specify is supported.
const websocket = cartesia.tts.websocket({
  container: "raw",
  encoding: "pcm_f32le",
  sampleRate: 44100,
});
// const websocket = cartesia.tts.websocket({
//   container: "raw",
//   encoding: "mp3",
//   sampleRate: 44100,
// });

try {
  await websocket.connect();
} catch (error) {
  console.error(`Failed to connect to Cartesia: ${error}`);
  throw error;
}

// Create a stream.
const response = await websocket.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.
for await (const message of response.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.

@SalamanderXing SalamanderXing added bug Something isn't working needs triage labels Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working web:blob
Projects
None yet
Development

No branches or pull requests

2 participants