> For the complete documentation index, see [llms.txt](https://40factory.gitbook.io/wilson/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://40factory.gitbook.io/wilson/3.12/rest-api/chat/edit-chat-1.md).

# Text-to-speech

This endpoint allows to transform text message linked to a chat by the \<chat\_id> into an audio.

## Request <a href="#request" id="request"></a>

### Url

```
POST 
https://wilson.40mat.com/apif/v2/chat/<chat_id>/text-to-speech
```

### Headers

<pre><code><strong>AUTH
</strong>Bearer "eyJ0eXAiOiJKV1QiLCJub25jZSI6IndUZXphSTNjdTNVYj..."
</code></pre>

### Parameters

```
No parameters are required for this endpoint.
```

### Body

```json
{
  "text": "Hello, how you can help me?"
}
```

The request body is in JSON format contain following properties:

* `text` (string): Text to transform in audio.

***

## Response&#x20;

The response is an audio file as bytearray.

***

## Code example

{% tabs %}
{% tab title="Python" %}

```python
import requests

url = "https://wilson.40mat.com/apif/v2/chat/<chat_id>/text-to-speech"

payload = {
  "text": "Hello, how you can help me?"
}

headers = {
  'Authorization': '••••••'
}

response = requests.request("POST", url, headers=headers, json=payload)

print(response.text)
```

{% endtab %}

{% tab title="cURL" %}

```powershell
curl --location 'https://wilson.40mat.com/apif/v2/chat/<chat_id>/text-to-speech' \
--header 'Authorization: ••••••' \
--data '{
  "text": "Hello, how you can help me?"
}'
```

{% endtab %}
{% endtabs %}
