1

Overview

The voices endpoint provides a list of all available voices that can be used for text-to-speech conversion. Each voice includes:

  • Voice ID and name
  • Gender and locale
  • Preview audio URL
  • Additional metadata

Voice IDs are used in the speech generation endpoint to specify which voice to use for text-to-speech conversion.

2

Using the SDK

The Node.js SDK provides a simple way to list available voices:

const Suonora = require('suonora-sdk');

const suonora = new Suonora({
  apiKey: 'YOUR_API_KEY'
});

async function listVoices() {
  try {
    const voices = await suonora.getVoices();

    console.log('--- Available Voices ---');
    voices.forEach(voice => {
      console.log(`\nVoice: ${voice.name} (${voice.id})`);
      console.log(`Gender: ${voice.gender}`);
      console.log(`Locale: ${voice.locale}`);
      console.log(`Preview: ${voice.mp3_preview}`);
    });
  } catch (error) {
    console.error('Error listing voices:', error.message);
  }
}

listVoices();

The SDK handles authentication and error handling automatically. It’s the recommended way to interact with the Suonora API if you’re using Node.js.

3

REST API

You can list available voices using the REST API directly. Here are examples in different languages:

curl -X GET https://api.suonora.com/v1/voices/list \
  -H "Authorization: Bearer YOUR_API_KEY"
success
boolean
required

Indicates if the request was successful

voices
array
required

Array of available voice objects

Example Response

{
  "success": true,
  "voices": [
    {
      "id": "axel",
      "name": "Axel",
      "gender": "Male",
      "locale": "de-DE",
      "mp3_preview": "https://storage.googleapis.com/suonora-public/voices/Axel.mp3"
    }
  ]
}

Response Codes


Best Practices

  1. Voice Selection

    • Choose voices that match your content’s language and region
    • Consider the gender and style that best fits your use case
    • Preview voices before using them in production
  2. Caching

    • Cache the voice list to reduce API calls
    • Update the cache periodically to get new voices
    • Store voice IDs for quick reference
  3. Error Handling

    • Always check the success flag
    • Handle API errors gracefully
    • Implement retry logic for temporary failures

For production applications, consider implementing a voice selection interface that allows users to preview and choose voices based on their needs.