Publish Content as Audio
User Intent
"How do I convert text to speech? Show me audio generation."
Operation
SDK Method: publishText()
Use Case: Text-to-speech conversion with ElevenLabs or OpenAI
Code Example (TypeScript)
import { Graphlit } from 'graphlit-client';
import { ContentPublishingServiceTypes, ContentPublishingFormats, ElevenLabsModels, TextTypes } from 'graphlit-client/dist/generated/graphql-types';
const graphlit = new Graphlit();
// Generate audio from text
const result = await graphlit.publishText(
'Hello, this is a text-to-speech demo using Graphlit.', // text
TextTypes.Plain, // textType
{
type: ContentPublishingServiceTypes.ElevenLabsAudio,
format: ContentPublishingFormats.Mp3,
elevenLabs: {
model: ElevenLabsModels.FlashV2_5,
voice: 'HqW11As4VRPkApNPkAZp' // ElevenLabs voice ID
}
}, // connector
'Generated Audio', // name (optional)
undefined, // workflow (optional)
true // isSynchronous
);
const contentId = result.publishText?.contents?.[0]?.id;
// Retrieve the content to get audio URL
const content = await graphlit.getContent(contentId!);
console.log('Audio URL:', content.content?.uri);Voice Options
ElevenLabs: Use voice IDs from ElevenLabs (higher quality) OpenAI TTS: Use OpenAI voice names (alloy, echo, fable, onyx, nova, shimmer)
Last updated
Was this helpful?