Skip to main content
POST
/
text-to-speech
/
speech
JavaScript
import Telnyx from 'telnyx';

const client = new Telnyx({
  apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});

const response = await client.textToSpeech.generateSpeech({ text: 'text', voice: 'voice' });

console.log(response);

const content = await response.blob();
console.log(content);
{}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
voice
string
required

The voice ID in the format Provider.ModelId.VoiceId.

Examples:

  • AWS.Polly.Joanna-Neural
  • Azure.en-US-AvaMultilingualNeural
  • ElevenLabs.eleven_multilingual_v2.Rachel
  • Telnyx.KokoroTTS.af

Use the GET /text-to-speech/voices endpoint to get a complete list of available voices.

text
string
required

The text to convert to speech

Response

Audio data generated from the provided text

Raw audio data in MP3 format