> For the complete documentation index, see [llms.txt](https://docs.wisej.com/ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wisej.com/ai/components/api/smartadapter/wisej.ai.adapters.smartaudiottsadapter.md).

# SmartAudioTTSAdapter

Namespace: **Wisej.AI.Adapters**

Assembly: **Wisej.AI** (3.5.0.0)

* [SmartAdapter](/ai/components/api/smartadapter.md)
  * [SmartAudioTTSAdapter](/ai/components/api/smartadapter/wisej.ai.adapters.smartaudiottsadapter.md)

Converts the [Text](https://docs.wisej.com/api?q=wisej.web.control.text) of the associated [Audio](https://docs.wisej.com/api?q=wisej.web.audio) control into lifelike speech.

{% tabs %}
{% tab title="C#" %}

```csharp
public class SmartAudioTTSAdapter : SmartAdapter
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class SmartAudioTTSAdapter
    Inherits SmartAdapter
```

{% endtab %}
{% endtabs %}

This class works with the OpenAI TTS platform to generate audio from text.\
To use this adapter, set the Text property of the [Audio](https://docs.wisej.com/api?q=wisej.web.audio) control to the desired text. If [AutoRun](/ai/components/api/smartadapter.md#autorun) is true, the audio is generated automatically when the text changes. The input text is limited to 4096 characters.\
If [AutoRun](/ai/components/api/smartadapter.md#autorun) is false, call [RunAsync](/ai/components/api/smartadapter.md#runasync-control) with the [Audio](https://docs.wisej.com/api?q=wisej.web.audio) control to generate the audio.\
The generated audio file is saved in the [AudioFilesPath](#audiofilespath) directory at the root of the project. The file name is a combination of the [Audio](https://docs.wisej.com/api?q=wisej.web.audio) control's [Name](https://docs.wisej.com/api?q=wisej.web.control.name) and a unique hash code, with the extension specified by [AudioFormat](#audioformat).

## Constructors

### ![](/files/ptrKjmmRoQB76pvrIqh0) SmartAudioTTSAdapter()

Initializes a new instance of [SmartAudioTTSAdapter](/ai/components/api/smartadapter/wisej.ai.adapters.smartaudiottsadapter.md).

## Properties

### ![](/files/ptrKjmmRoQB76pvrIqh0) AudioFilesPath

[String](https://docs.microsoft.com/dotnet/api/system.string): Gets or sets the path where audio files are stored. (Default: `"~AI\AudioFiles"`)

The path should be relative to the application's root folder to allow the audio control to download the audio as a regular URL.

### ![](/files/ptrKjmmRoQB76pvrIqh0) AudioFormat

[String](https://docs.microsoft.com/dotnet/api/system.string): Gets or sets the audio format for the generated speech. (Default: `"mp3"`)

The default format is "mp3". Other available formats include "opus", "aac", "flac", and "pcm".

### ![](/files/ptrKjmmRoQB76pvrIqh0) Speed

[Single](https://docs.microsoft.com/dotnet/api/system.single): Gets or sets the speed of the generated audio. (Default: `1`)

The speed can range from 0.25 to 4.0, with 1.0 as the default value.

### ![](/files/ptrKjmmRoQB76pvrIqh0) Voice

[String](https://docs.microsoft.com/dotnet/api/system.string): Gets or sets the voice to use for speech synthesis. (Default: `"Alloy"`)

The available voices are optimized for English. Supported voices include: Alloy (default), Echo, Fable, Onyx, Nova, and Shimmer. New voices can be used as they become available.

## Methods

### ![](/files/KL0Ik37djZRr8a07Wopd) OnControlCreated(control)

| Parameter   | Type                                                      | Description |
| ----------- | --------------------------------------------------------- | ----------- |
| **control** | [Control](https://docs.wisej.com/api?q=wisej.web.control) |             |

### ![](/files/KL0Ik37djZRr8a07Wopd) OnControlDisposed(control)

| Parameter   | Type                                                      | Description |
| ----------- | --------------------------------------------------------- | ----------- |
| **control** | [Control](https://docs.wisej.com/api?q=wisej.web.control) |             |

### ![](/files/KL0Ik37djZRr8a07Wopd) RunAsyncCore(control)

Asynchronously generates audio from the text of the specified control.

| Parameter   | Type                                                      | Description                                          |
| ----------- | --------------------------------------------------------- | ---------------------------------------------------- |
| **control** | [Control](https://docs.wisej.com/api?q=wisej.web.control) | The control containing the text to convert to audio. |

**Returns:** [Task\<Message>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task representing the asynchronous operation, with a [Message](/ai/components/api/smartsession/wisej.ai.smartsession.message.md) result containing the response.

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown if [AudioFormat](#audioformat) or [Voice](#voice) is null or empty.

## Implements

| Name                                                                              | Description                                |
| --------------------------------------------------------------------------------- | ------------------------------------------ |
| [IToolProvider](/ai/components/api/smarttool/wisej.ai.smarttool.itoolprovider.md) | Represents a provider that supplies tools. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.wisej.com/ai/components/api/smartadapter/wisej.ai.adapters.smartaudiottsadapter.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
