- Python
- TypeScript
def voices_list(client: Cartesia) -> None:
"""List voices with pagination."""
print("loading page 1...")
page = client.voices.list()
voices = list(page.data)
# loaded 1 page
print("loaded", len(voices))
for i in range(2, 4):
if not page.has_next_page():
break
print(f"loading page {i}...")
page = page.get_next_page()
voices.extend(page.data)
print("loaded", len(voices))
print([voices[0], "..."])
async function voicesList(client: Cartesia): Promise<void> {
console.log('loading page 1...');
let page = await client.voices.list();
const voices = [...page.data];
console.log('loaded', voices.length);
for (let i = 2; i < 4; i++) {
if (!page.hasNextPage()) break;
console.log(`loading page ${i}...`);
page = await page.getNextPage();
voices.push(...page.data);
console.log('loaded', voices.length);
}
console.log([voices[0], '...']);
}
Run this example
- Python
- TypeScript
git clone --branch v3.2.0 https://github.com/cartesia-ai/cartesia-python
cd cartesia-python
uv sync
CARTESIA_API_KEY=YOUR_KEY uv run examples/examples.py voices_list
git clone --branch v3.2.0 https://github.com/cartesia-ai/cartesia-js
cd cartesia-js
pnpm i
CARTESIA_API_KEY=YOUR_KEY pnpm tsn examples/node_examples.ts voicesList