From 9310accb9897b5e8b199a115b896fba58a61bbf6 Mon Sep 17 00:00:00 2001 From: Kabir Goel Date: Thu, 12 Dec 2024 01:38:18 -0800 Subject: [PATCH] Update README.md --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b213cbb..de287cb 100644 --- a/README.md +++ b/README.md @@ -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: { @@ -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