#!/usr/bin/env node /** * Example: Search Voices * * This example demonstrates how to search for voices by language and gender. */ import { Supertone } from "@supertone/supertone"; import * as dotenv from "dotenv"; // Load environment variables dotenv.config(); const API_KEY = process.env.SUPERTONE_API_KEY; async function main() { if (!API_KEY) { console.error("āŒ SUPERTONE_API_KEY not found in .env file"); process.exit(1); } try { // Initialize the client const client = new Supertone({ apiKey: API_KEY }); console.log("šŸ” Searching for female English voices..."); // Search voices const response = await client.voices.searchVoices({ language: "en", gender: "female", pageSize: 10, }); // Display results console.log("\nāœ… Search Results:"); console.log(` Found: ${response.items?.length || 0} voices`); if (response.items && response.items.length > 0) { console.log("\nšŸŽ¤ Matching Voices:"); for (const voice of response.items) { console.log(`\n ${voice.name}`); console.log(` ID: ${voice.voiceId}`); console.log(` Language: ${voice.language}`); console.log(` Gender: ${voice.gender}`); } } else { console.log("\nšŸ“ No voices found matching the criteria"); } } catch (error: any) { console.error("āŒ Error:", error.message); process.exit(1); } } main();