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
Quick Start
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
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();
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?",
voice_clone_id: fileKey,
});
const data = await response.blob();
Voice Clone Management
JigsawStack provides functionalities to create, list, and delete voice clones for Text to Speech. These voice clones can be reused across multiple text-to-speech requests.
Create Voice Clone
Create a new voice clone from an audio sample.
import { JigsawStack } from "jigsawstack";
const jigsaw = JigsawStack({
apiKey: "your-api-key",
});
// Using a URL
const response = await jigsaw.audio.create_clone({
url: "https://example.com/path/to/voice-sample.mp3",
name: "My Custom Voice",
});
// OR using a file store key
const response = await jigsaw.audio.create_clone({
file_store_key: "your-file-store-key",
name: "My Custom Voice",
});
console.log(response);
// Sample response:
// {
// "voice_id": "2c57465d-1ffb-42f7-909a-d587bc9f977e",
// "name": "My Custom Voice",
// "created_at": "2025-05-22T20:49:05.03065+00:00"
// }
List Voice Clones
Retrieve a list of all your voice clones.
import { JigsawStack } from "jigsawstack";
const jigsaw = JigsawStack({
apiKey: "your-api-key",
});
// Get all voice clones (default pagination)
const response = await jigsaw.audio.list_clones();
// With pagination
const response = await jigsaw.audio.list_clones({
limit: 10, // Number of items per page
page: 1, // Page number (starting from 1)
});
console.log(response);
// Sample response:
// {
// "voice_clones": [
// {
// "id": "2c57465d-1ffb-42f7-909a-d587bc9f977e",
// "name": "My Custom Voice",
// "created_at": "2025-05-22T20:49:05.03065+00:00"
// },
// // ... more clones
// ],
// "page": 1,
// "limit": 10,
// "has_more": false
// }
Delete Voice Clone
Delete a voice clone when you no longer need it.
import { JigsawStack } from "jigsawstack";
const jigsaw = JigsawStack({
apiKey: "your-api-key",
});
// Delete a voice clone using its ID
const response = await jigsaw.audio.delete_clone("2c57465d-1ffb-42f7-909a-d587bc9f977e");
console.log(response);
// Sample response:
// {
// "status": "success",
// "message": "Voice clone deleted successfully"
// }
Using Voice Clones for Text to Speech
Once you’ve created a voice clone, you can use it for text-to-speech by referencing its ID.
import { JigsawStack } from "jigsawstack";
const jigsaw = JigsawStack({
apiKey: "your-api-key",
});
const response = await jigsaw.audio.text_to_speech({
text: "Hello, this is my cloned voice speaking.",
voice_clone_id: "2c57465d-1ffb-42f7-909a-d587bc9f977e",
});
const data = await response.blob();