Introduction
The TTS module is an Fcloud service developed by Ftech. The module allows customer converse text to speech through the application of electronic technology. To integrate and use this service, you must use Fcloud's SDK. And here are instructions for integrating the SDK.
Authentication
To call the APIs, we will have to init the SDK with the parameters ClientID and SecretKey taken when you create the Application on CMS for partners according to the following instructions:
- Log in to CMS Partner with the username/password provided (https://fcloud-partner-cms.ftech.ai)
- Buy a service package
- Create App
Server Integrator
After integrating the SDK, the Fcloud service supports server-server callbacks to help get request information as quickly and accurately as possible.
Web SDK
Android SDK
Install SDK Android
Setup gradle maven
- With Gradle v1.x - v5.x
Open
build.grade
file and addmaven
line like below
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' } <- add this line
}
}
- With Gradle v6.x+
Open
setting.gradle
file and addmaven
line like below
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' } <- add this line
}
}
Open file app/build.grade
then add sdk
dependencies {
...
implementation "com.github.FTechMobile:ftts-android:1.0.2"
}
Init in file Application
- Java
@Override
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
...
STTManager.init(getApplicationContext());
}
- Kotlin
override fun onCreate() {
super.onCreate()
...
TTSManager.init(this)
}
SDK Android Feature
Init
Param | Type | Description |
---|---|---|
appId | String | Application id |
secretKey | String | IOE secret key |
Java ``` java TTSManager.initGateway(appId, secretKey, new IInitGatewayCallback() { @Override public void onSuccess() {
}
@Override public void onFail(@Nullable AppException error) {
} }); ```
Kotlin ```kotlin TTSManager.initGateway(appId, secretKey, object : IInitGatewayCallback { override fun onSuccess() {
}
override fun onFail(error: AppException?) {
} }) ```
Register 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 |
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) {
} }); ```
Kotlin ```kotlin TTSManager.registerTTSCallback(object : ISTTCallback { override fun onStart() {
}
override fun onPlaying() {
}
override fun onFail(error: AppException?) {
}
override fun onSuccess(urlAudio: String) {
}) }) ```
Get language config
- Get list language config used to tts param
- When sucess, result is
listLanguage
, it will be called ononSuccess()
in callback When fail, it will called on
onFail()
in callbackJava ``` java TTSManager.getLanguageConfig(new ILanguageConfigCallback() { @Override public void onSuccess(@NonNull List
listLanguage) { }
@Override public void onFail(@Nullable AppException error) {
} }); ```
Kotlin ```kotlin TTSManager.getLanguageConfig(object : ILanguageConfigCallback { override fun onSuccess(listLanguage: List
) { }
override fun onFail(error: AppException?) {
} }) ```
Start
- 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 ononPlaying()
in callback, after play audio completed,audioUrl
will be return ononSuccess
in callback. When fails, it will be processed at callback
onFail()
in callback.Java
java TTSManager.startTTS(language, voice, content, true);
Kotlin
kotlin TTSManager.startTTS(language, voice, content, true)
IOS SDK
Install SDK IOS
Supports devices with Apple Neural Engine in iOS 14 and iPadOS 14 and requires a device with a TrueDepth camera on iOS 13 and iPadOS 13 and earlier.
Add package dependencies
SDK IOS Integration
Init
Param | Type | Description |
---|---|---|
appId | String | Application id |
key | String | Ekyc license key |
FTechTTSManager.instance().initSDK(appId: String, key: String) {
// onSuccess
} onFailure: { error in
// onFailure
}
Register callback
FTechTTSManager.instance().delegate = self
SDK IOS Feature
Implement FTechTTSMangerDelegate
extension ViewController: FTechTTSMangerDelegate {
func onSuccess(data: TTSResponse) {
}
func onFailure(error: FTError) {
}
}
Get language config
- Get list language config used to tts param
- When sucess, result is
listLanguage
, it will be called ononSuccess()
in callback - When fail, it will called on
onFailure()
in callback
FTechTTSManager.instance().getLanguageConfig {
// onSuccess
} onFailure: {
// onFailure
}
Start
- If
isAutoPlayAudio = true
, when have result sdk will play audio audioUrl will be return ononSuccess()
in callback. - If
isAutoPlayAudio = false
, when have result audioUrl will be return ononSuccess()
in callback. - When fails, it will be processed at callback
onFailure()
in callback.
FTechTTSManager.instance().startTTS(language: language,
voice: voice,
content: content,
isPlayAudio: true)
Errors
The Kittn API uses the following error codes:
Error Code | Meaning |
---|---|
400 | Bad Request -- Your request is invalid. |
401 | Unauthorized -- Your API key is wrong. |
403 | Forbidden -- The kitten requested is hidden for administrators only. |
404 | Not Found -- The specified kitten could not be found. |
405 | Method Not Allowed -- You tried to access a kitten with an invalid method. |
406 | Not Acceptable -- You requested a format that isn't json. |
429 | Too Many Requests -- You're requesting too many kittens! Slow down! |
500 | Internal Server Error -- We had a problem with our server. Try again later. |
503 | Service Unavailable -- We're temporarily offline for maintenance. Please try again later. |