Skip to main content

Speech Generation

Available Models

The full list of models can be viewed on the Models page or retrieved dynamically via API endpoints: https://openai.bothub.chat/v1/models and https://bothub.chat/api/v2/replicate/v1/models

BotHub supports speech generation via an OpenAI-compatible API. You can convert text to audio, select a voice, audio file format, and playback speed.

Speech generation uses the Text-to-Speech (TTS) family of models:

  • tts-1 — standard model with low latency
  • tts-1-hd — improved model with higher audio quality

Available Voices​

When generating speech, you can choose one of the built-in voices: alloy, echo, fable, onyx, nova, shimmer.


Supported Audio Formats​

The API supports audio generation in several formats: mp3, opus, aac, flac.


Main Request Parameters​

The following parameters are used when creating audio:

ParameterTypeDescription
modelstringSpeech generation model (tts-1 or tts-1-hd)
voicestringVoice for speech synthesis
inputstringText to convert to speech
response_formatstringOutput audio format
speednumberPlayback speed (0.25 – 4.0)

Speech Generation Example​

import OpenAI from 'openai';
import fs from 'fs';

const openai = new OpenAI({
apiKey: 'YOUR_BOTHUB_API_KEY',
baseURL: 'https://openai.bothub.chat/v1'
});

async function main() {
const response = await openai.audio.speech.create({
model: 'tts-1-hd',
voice: 'nova',
input: 'Hello! This is an example of speech generation via BotHub.',
response_format: 'mp3',
speed: 0.9
});

const buffer = Buffer.from(await response.arrayBuffer());

await fs.promises.writeFile('output.mp3', buffer);

console.log('Audio file saved successfully.');
}

main();

Recommendations​

Usage Recommendations
  • For most scenarios, it is recommended to use tts-1 if generation speed is important.
  • Use tts-1-hd if audio quality is the priority.
  • The mp3 format is suitable for most applications and provides a good balance between quality and file size.
  • A speed value greater than 1.0 accelerates playback, while a value below 1.0 makes the speech slower and smoother.
Official OpenAI Documentation

You can read more about the Text-to-Speech API in the official OpenAI documentation:

https://developers.openai.com/api/docs/guides/text-to-speech