> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dedaluslabs.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Audio

> Speech-to-text, translation, and text-to-speech with the Dedalus SDK

Build voice workflows with one SDK: transcribe audio, translate it to English, and synthesize speech.

<Tip>
  Use `openai/gpt-4o-transcribe` for transcription and `openai/gpt-4o-mini-tts` for speech
  generation.
</Tip>

## Speech to Text

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from dedalus_labs import AsyncDedalus

  client = AsyncDedalus()

  with open("audio.mp3", "rb") as audio_file:
      transcription = await client.audio.transcriptions.create(
          model="openai/gpt-4o-transcribe",
          file=audio_file,
      )

  print(transcription.text)
  ```

  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import Dedalus from "dedalus-labs";
  import fs from "node:fs";

  const client = new Dedalus();

  const transcription = await client.audio.transcriptions.create({
  	model: "openai/gpt-4o-transcribe",
  	file: fs.createReadStream("audio.mp3"),
  });

  console.log(transcription.text);
  ```
</CodeGroup>

## Audio Translation

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from dedalus_labs import AsyncDedalus

  client = AsyncDedalus()

  with open("spanish-audio.mp3", "rb") as audio_file:
      translation = await client.audio.translations.create(
          model="openai/gpt-4o-mini-transcribe",
          file=audio_file,
      )

  print(translation.text)
  ```

  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import Dedalus from "dedalus-labs";
  import fs from "node:fs";

  const client = new Dedalus();

  const translation = await client.audio.translations.create({
  	model: "openai/gpt-4o-mini-transcribe",
  	file: fs.createReadStream("spanish-audio.mp3"),
  });

  console.log(translation.text);
  ```
</CodeGroup>

## Text to Speech

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from dedalus_labs import AsyncDedalus

  client = AsyncDedalus()

  speech = await client.audio.speech.create(
      model="openai/gpt-4o-mini-tts",
      voice="alloy",
      input="Hello from Dedalus",
  )

  speech.stream_to_file("speech.mp3")
  ```

  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import Dedalus from "dedalus-labs";
  import fs from "node:fs";

  const client = new Dedalus();

  const response = await client.audio.speech.create({
  	model: "openai/gpt-4o-mini-tts",
  	voice: "alloy",
  	input: "Hello from Dedalus",
  });

  fs.writeFileSync("speech.mp3", Buffer.from(await response.arrayBuffer()));
  ```
</CodeGroup>

## API endpoints

<CardGroup cols={3}>
  <Card title="Speech" href="/api/audio-speech">
    POST /v1/audio/speech
  </Card>

  <Card title="Transcriptions" href="/api/audio-transcriptions">
    POST /v1/audio/transcriptions
  </Card>

  <Card title="Translations" href="/api/audio-translations">
    POST /v1/audio/translations
  </Card>
</CardGroup>
