> For the complete documentation index, see [llms.txt](https://docs.graphlit.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.graphlit.dev/api-guides/use-cases/content/content-publish-audio.md).

# 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)

```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)

***
