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

# Playing & saving audio

> Turn the WAV bytes into files, playback, and other formats.

`tts.create()` (and `POST /v1/tts`) return raw **WAV** bytes — 24 kHz, 16-bit PCM, mono. Here's how to use them in each environment.

## Node — save to a file

```ts theme={null}
import { Geko } from "@gekoai/sdk";
import { writeFile } from "node:fs/promises";

const geko = new Geko({ apiKey: process.env.GEKO_API_KEY });
const audio = await geko.tts.create({ text: "Сәлем", voice: "Aigerim" });

await writeFile("hello.wav", Buffer.from(audio));
```

`audio` is an `ArrayBuffer`; `Buffer.from(audio)` wraps it without copying the underlying bytes.

## Node — play it

```ts theme={null}
import { spawn } from "node:child_process";
// after writing hello.wav:
spawn(process.platform === "darwin" ? "afplay" : "aplay", ["hello.wav"]);
```

## Browser — play from bytes

Fetch the audio from **your own server endpoint** (never call Geko directly from the browser — see [Use it in your app](/guides/frameworks)), then:

```ts theme={null}
const res = await fetch("/api/tts", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({ text: "Сәлем", voice: "Aigerim" }),
});
const bytes = await res.arrayBuffer();

const url = URL.createObjectURL(new Blob([bytes], { type: "audio/wav" }));
new Audio(url).play();
// revoke when done: URL.revokeObjectURL(url)
```

## curl — straight to disk

```bash theme={null}
curl -X POST https://geko--tokay-serve-web.modal.run/v1/tts \
  -H "Authorization: Bearer $GEKO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"Сәлем","voice":"Aigerim"}' \
  --output hello.wav
```

## Need MP3 / Opus?

The API returns WAV today (MP3/Opus are on the [roadmap](/roadmap)). Convert locally with `ffmpeg` in the meantime:

```bash theme={null}
ffmpeg -i hello.wav -b:a 128k hello.mp3      # MP3
ffmpeg -i hello.wav -c:a libopus hello.opus  # Opus
```

## Telephony (8 kHz µ-law)

For Twilio / SIP you'll want 8 kHz µ-law. Until it's a native output option, transcode:

```bash theme={null}
ffmpeg -i hello.wav -ar 8000 -ac 1 -f mulaw hello.ulaw
```

## Next steps

<CardGroup cols={2}>
  <Card title="Streaming" icon="waveform-lines" href="/guides/streaming">
    Play WAV chunks as they arrive instead of waiting.
  </Card>

  <Card title="Use it in your app" icon="react" href="/guides/frameworks">
    Proxy synthesis through your own server for the browser.
  </Card>

  <Card title="Voice agents" icon="phone" href="/guides/voice-agents">
    Feed audio into a real-time voice loop.
  </Card>

  <Card title="Limits & constraints" icon="gauge-high" href="/limits">
    Output formats and how to get MP3 / µ-law.
  </Card>
</CardGroup>
