Skip to main content

Overview

60db’s Text-to-Speech (TTS) API converts written text into natural-sounding speech using advanced AI models. Our TTS engine supports multiple voices, languages, and customization options.

Features

Multiple Voices

Choose from 50+ pre-built voices or create custom voices

Real-time Streaming

Stream audio in real-time for low-latency applications

Voice Customization

Adjust speed, pitch, and other parameters

High Quality

Crystal-clear audio with natural intonation

Basic Usage

import { SixtyDBClient } from '@60db-own/60db-js';

const client = new SixtyDBClient('your-api-key');

const audio = await client.textToSpeech({
  text: 'Hello, world!',
  voice_id: 'default-voice',
  enhance: true,
  speed: 1.0
});

Voice Parameters

Speed

Control the speaking rate of the generated audio:
const audio = await client.textToSpeech({
  text: 'This will be spoken faster',
  speed: 1.5  // Range: 0.5 to 2.0
});
  • 0.5: Half speed (slow)
  • 1.0: Normal speed (default)
  • 2.0: Double speed (fast)

Pitch

Adjust the pitch of the voice:
const audio = await client.textToSpeech({
  text: 'This will have a higher pitch',
  pitch: 1.3  // Range: 0.5 to 2.0
});

Enhancement

Enable audio enhancement for better quality:
const audio = await client.textToSpeech({
  text: 'Enhanced audio quality',
  enhance: true  // Default: true
});

Output Formats

Supported audio formats:
FormatQualityFile SizeUse Case
MP3GoodSmallWeb, mobile apps
WAVExcellentLargeProfessional audio
OGGGoodSmallWeb streaming
FLACLosslessMediumHigh-quality archival
const audio = await client.textToSpeech({
  text: 'Hello, world!',
  output_format: 'wav'  // mp3, wav, ogg, flac
});

Streaming Mode

For long-form content or real-time applications, use streaming:
await client.textToSpeechStream(
  {
    text: 'This is a longer text that will be streamed...',
    voice_id: 'default-voice'
  },
  {
    onChunk: (chunk) => {
      // Play audio chunk immediately
      playAudioChunk(chunk);
    },
    onComplete: () => {
      console.log('Streaming complete');
    },
    onError: (error) => {
      console.error('Error:', error);
    }
  }
);

Benefits of Streaming

  • Lower Latency: Start playing audio before generation completes
  • Memory Efficient: Process chunks instead of entire file
  • Better UX: Progressive audio playback
  • Real-time Applications: Ideal for chatbots and voice assistants

Best Practices

  • Use proper punctuation for natural pauses
  • Break long texts into paragraphs
  • Use SSML tags for advanced control (coming soon)
  • Test multiple voices for your use case
  • Consider accent and gender for your audience
  • Use custom voices for brand consistency
  • Cache frequently used audio
  • Use streaming for content > 500 characters
  • Batch requests when possible
  • Enable enhancement for production use
  • Use WAV format for highest quality
  • Test with different speed settings

Use Cases

Voice Assistants

// Real-time voice assistant
async function speakResponse(text) {
  await client.textToSpeechStream(
    { text, voice_id: 'assistant-voice' },
    {
      onChunk: (chunk) => playAudio(chunk),
      onComplete: () => listenForUserInput()
    }
  );
}

Content Narration

// Generate audiobook chapter
const audio = await client.textToSpeech({
  text: chapterText,
  voice_id: 'narrator-voice',
  speed: 0.95,
  output_format: 'mp3'
});

saveToFile(`chapter-${chapterNum}.mp3`, audio);

Accessibility

// Make web content accessible
async function readAloud(element) {
  const text = element.textContent;
  const audio = await client.textToSpeech({
    text,
    voice_id: 'clear-voice',
    enhance: true
  });
  
  playAudio(audio);
}

API Reference

For detailed API documentation, see: