Skip to main content
async function voicesListToDOM(client: Cartesia): Promise<void> {
  /** Fetch voices and display them in a <ul> element. */
  const ul = document.createElement('ul');

  for await (const voice of client.voices.list({ limit: 20 })) {
    const li = document.createElement('li');
    li.textContent = `${voice.name} (${voice.language})`;
    ul.appendChild(li);
  }

  document.body.appendChild(ul);
}
From cartesia-js/examples/browser_examples.ts:169

Run this example

This example runs in the browser. See the Next.js example for a working setup.