Overview

The Text to Speech API converts written text into natural-sounding speech output. You can use predefined speaker accents or clone a voice from an audio sample to create personalized speech output.

  • Support for multiple languages and accents
  • Voice cloning from audio samples
  • High-quality, natural-sounding output
  • Simple integration options

API Endpoint

POST /v1/ai/tts

Quick Start

Javascript
import { JigsawStack } from "jigsawstack";

const jigsaw = JigsawStack({
  apiKey: "your-api-key",
});

const response = await jigsaw.audio.text_to_speech({
  text: "Hello, how are you doing?",
  accent: "en-US-female-27",
});

const data = await response.blob();

See Speaker Voice Accents for the complete list of supported speaker voice accents.

Response

The API returns the generated audio file directly in the response body as binary data, typically in MP3 format.

Using Text to Speech Effectively

  • Keep text natural: Write text that sounds natural when spoken aloud
  • Consider punctuation: Use commas and periods to create natural pauses
  • Test different accents: Try different voice options to find the best fit for your use case
  • For voice cloning: Use high-quality audio samples with minimal background noise

Examples

Using Speaker Clone URL
import { JigsawStack } from "jigsawstack";

const jigsaw = JigsawStack({
  apiKey: "your-api-key",
});

const response = await jigsaw.audio.text_to_speech({
  text: "Hello, how are you doing?",
  speaker_clone_url: "https://example.com/path/to/voice-sample.mp3",
});

const data = await response.blob();
Using File Store Key
import { JigsawStack } from "jigsawstack";
import fs from "fs";

const jigsaw = JigsawStack({
  apiKey: "your-api-key",
});

// Read the audio file
const audioFile = fs.readFileSync("./speaker.wav");

// Upload the file
const uploadResult = await jigsaw.store.upload(audioFile, {
  filename: "speaker",
});

// Retrieve the file key
const fileKey = uploadResult.key;

// Use the file key for Text to Speech
const response = await jigsaw.audio.text_to_speech({
  text: "Hello, how are you doing?",
  speaker_clone_file_store_key: fileKey,
});

const data = await response.blob();