Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Text to speech
speak
const result = await saturn.speak({ text: 'Hello, welcome to Saturn.', }); console.log(result.data.audioUrl); // → URL to audio file
interface SpeakResponse { data: { audioUrl: string; // URL to the audio file duration: number; // Audio duration in seconds format: string; // Audio format (mp3, wav, etc.) }; metadata: { chargedUsdCents: number; provider: string; latencyMs: number; auditId: string; }; }
const result = await saturn.speak({ text: 'This is a professional announcement.', voice: 'rachel', // ElevenLabs voice name });
async function narrateArticle(articleUrl: string) { // Read the article const article = await saturn.read({ url: articleUrl }); // Generate speech const audio = await saturn.speak({ text: article.data.content, }); return audio.data.audioUrl; }
async function createAudioBook(chapters: string[]) { const audioUrls = []; for (const chapter of chapters) { const result = await saturn.speak({ text: chapter }); audioUrls.push(result.data.audioUrl); } return audioUrls; }
import fs from 'fs'; import fetch from 'node-fetch'; const result = await saturn.speak({ text: 'Hello world', }); // Download and save const response = await fetch(result.data.audioUrl); const buffer = await response.buffer(); fs.writeFileSync('speech.mp3', buffer);
function chunkText(text: string, maxLength: number = 5000): string[] { const chunks: string[] = []; let current = ''; for (const sentence of text.split(/(?<=[.!?])\s+/)) { if ((current + sentence).length > maxLength) { chunks.push(current.trim()); current = sentence; } else { current += ' ' + sentence; } } if (current.trim()) { chunks.push(current.trim()); } return chunks; }