## Direct retrieval

### cURL

```bash
curl -X GET "https://api.upliftai.org/v1/synthesis/stream-audio/media_abc123xyz?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -o output.mp3
```

```html
<!-- Direct embedding in HTML -->
<audio controls>
  <source src="https://api.upliftai.org/v1/synthesis/stream-audio/media_abc123xyz?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." type="audio/mp3">
</audio>
```

```python
import requests

url = "https://api.upliftai.org/v1/synthesis/stream-audio/{mediaId}"

response = requests.get(url)

print(response.text)
```

```javascript
const options = {method: 'GET'};

fetch('https://api.upliftai.org/v1/synthesis/stream-audio/{mediaId}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [\
  CURLOPT_URL => "https://api.upliftai.org/v1/synthesis/stream-audio/{mediaId}",\
  CURLOPT_RETURNTRANSFER => true,\
  CURLOPT_ENCODING => "",\
  CURLOPT_MAXREDIRS => 10,\
  CURLOPT_TIMEOUT => 30,\
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\
  CURLOPT_CUSTOMREQUEST => "GET",\
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
?>
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

url := "https://api.upliftai.org/v1/synthesis/stream-audio/{mediaId}"

req, _ := http.NewRequest("GET", url, nil)

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}
```

```java
HttpResponse<String> response = Unirest.get("https://api.upliftai.org/v1/synthesis/stream-audio/{mediaId}")
  .asString();
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.upliftai.org/v1/synthesis/stream-audio/{mediaId}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
```

### Response Codes

- 200: Audio file retrieved successfully
- 401: Invalid or expired token
- 404: Media not found or expired

### Example Responses

```json
{
  "message": "Invalid or expired token"
}
```

```json
{
  "message": "Media not found or expired"
}
```

### Path Parameters

| Parameter | Type   | Required | Description                                     |
|-----------|--------|----------|-------------------------------------------------|
| mediaId   | string | Yes      | The media ID returned from the async TTS request |

Example:

`"media_abc123xyz"`

### Query Parameters

| Parameter | Type   | Required | Description                    |
|-----------|--------|----------|--------------------------------|
| token     | string | Yes      | JWT token for authentication    |

Example:

`"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."`

### Additional Reference

- [Async Streaming Text to Speech](https://docs.upliftai.org/api-reference/endpoint/text-to-speech-stream-async)
- [Create Phrase Replacement Config](https://docs.upliftai.org/api-reference/endpoint/create-phrase-replacement-config)
