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

# Download Audio File

> Generate audio and trigger a file download in the browser.

```typescript theme={null}
async function ttsDownloadFile(client: Cartesia): Promise<void> {
  /** Generate audio and trigger a file download in the browser. */
  const response = await client.tts.generate({
    model_id: 'sonic-3.5',
    transcript: 'This audio will be downloaded as a file.',
    voice: { mode: 'id', id: '6ccbfb76-1fc6-48f7-b71d-91ac6298247b' },
    output_format: { container: 'wav', encoding: 'pcm_s16le', sample_rate: 44100 },
  });

  const blob = await response.blob();
  const url = URL.createObjectURL(blob);

  const a = document.createElement('a');
  a.href = url;
  a.download = 'speech.wav';
  a.click();

  URL.revokeObjectURL(url);
}
```

From [cartesia-js/examples/browser\_examples.ts:54](https://github.com/cartesia-ai/cartesia-js/blob/main/examples/browser_examples.ts#L54)

## Run this example

This example runs in the browser. See the [Next.js example](/examples/nextjs) for a working setup.
