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

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.graphlit.dev/api-guides/use-cases/content/content-publish-audio.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
