Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrgl authored Dec 12, 2024
1 parent d09bb9d commit 9310acc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ Instantiate and use the client with the following:
```typescript
import { CartesiaClient } from "@cartesia/cartesia-js";

const client = new CartesiaClient({ apiKey: "YOUR_API_KEY_HEADER" });
await client.tts.bytes({
// Set up the client.
const client = new CartesiaClient({ apiKey: "YOUR_API_KEY" });

// Call the TTS API's bytes endpoint, which returns binary audio data as an ArrayBuffer.
const response = await client.tts.bytes({
modelId: "sonic-english",
transcript: "Hello, world!",
voice: {
Expand All @@ -40,6 +43,9 @@ await client.tts.bytes({
encoding: "pcm_f32le",
},
});

// Write the response to a file.
fs.writeFileSync("sonic.wav", new Uint8Array(response));
```

### TTS over WebSocket
Expand Down

0 comments on commit 9310acc

Please sign in to comment.