> For the complete documentation index, see [llms.txt](https://ftech.gitbook.io/ftts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ftech.gitbook.io/ftts/android-ftts-sdk/2.-ftts-sdk-features.md).

# 2. FTTS SDK features

## Init gateway

Contact us for get `app_id` & `secret_key`

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

```java
TTSManager.initGateway(appId, secretKey, new IInitGatewayCallback() {
    @Override
    public void onSuccess() {

    }

    @Override
    public void onFail(@Nullable AppException error) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```java
TTSManager.initGateway(appId, secretKey, object : IInitGatewayCallback {
    override fun onSuccess() {
    
    }

    override fun onFail(error: AppException?) {

    }
})
```

{% endtab %}
{% endtabs %}

## Register SDK Callback

**After registration, the SDK will return the corresponding status in the callback**

| Status    | Description                            |
| --------- | -------------------------------------- |
| onStart   | Called at start record                 |
| onPlaying | Called while audio playing             |
| onSuccess | Called when return result              |
| onFail    | Called when an error occurs in process |

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

```java
TTSManager.registerTTSCallback(new ISTTCallback() {
    @Override
    public void onStart() {
        
    }

    @Override
    public void onPlaying() {

    }

    @Override
    public void onFail(@Nullable AppException error) {

    }

    @Override
    public void onSuccess(@NonNull String result) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```java
TTSManager.registerTTSCallback(object : ISTTCallback {
    override fun onStart() {

    }

    override fun onPlaying() {
    
    }

    override fun onFail(error: AppException?) {

    }

    override fun onSuccess(urlAudio: String) {

    })
})
```

{% endtab %}
{% endtabs %}

## **Get language config**

* Get list language config used to tts param
* When sucess, result is `listLanguage`, it will be called on `onSuccess()` in callback
* When fail, it will called on `onFail()` in callback

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

```java
TTSManager.getLanguageConfig(new ILanguageConfigCallback() {
    @Override
    public void onSuccess(@NonNull List<LanguageConfigData> listLanguage) {
        
    }

    @Override
    public void onFail(@Nullable AppException error) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```java
TTSManager.getLanguageConfig(object : ILanguageConfigCallback {
    override fun onSuccess(listLanguage: List<LanguageConfigData>) {

    }

    override fun onFail(error: AppException?) {
    
    }
})
```

{% endtab %}
{% endtabs %}

## **Start TTS**

* Used to start TTS
* When successful start, it will be called on `onStart()` in callback
* If `isAutoPlayAudio = true`, when have result sdk will play audio and called on `onPlaying()` in callback, after play audio completed, `audioUrl` will be return on `onSuccess` in callback.
* If `isAutoPlayAudio = false`, when have result `audioUrl` will be return on `onSuccess` in callback.
* When fails, it will be processed at callback `onFail()` in callback.

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

```java
TTSManager.startTTS(language, voice, content, true);
```

{% endtab %}

{% tab title="Kotlin" %}

```java
TTSManager.startTTS(language, voice, content, true)
```

{% endtab %}
{% endtabs %}


---

# 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://ftech.gitbook.io/ftts/android-ftts-sdk/2.-ftts-sdk-features.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.
