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.
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
Copy
import { JigsawStack } from "jigsawstack";import fs from "fs";const jigsaw = JigsawStack({ apiKey: "your-api-key",});// Read the audio fileconst audioFile = fs.readFileSync("./speaker.wav");// Upload the fileconst uploadResult = await jigsaw.store.upload(audioFile, { filename: "speaker",});// Retrieve the file keyconst fileKey = uploadResult.key;// Use the file key for Text to Speechconst response = await jigsaw.audio.text_to_speech({ text: "Hello, how are you doing?", voice_clone_id: fileKey,});const data = await response.blob();
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.