🗣️ Thai Text-to-Speech (TTS)
🗣️ ระบบแปลงข้อความภาษาไทยเป็นเสียงพูด
Welcome to Thai Text-to-Speech API, an AI product developed by iApp Technology Co., Ltd. Our API converts Thai and English text into natural-sounding speech with high accuracy and speed. The service supports mixed Thai-English sentences and offers multiple voice options.
Visit our API Portal to test the Text to Speech API with your own text.
Getting Started
-
Prerequisites
- An API key from iApp Technology
- Text input in Thai and/or English
- Maximum text length: No specific limit
- Supported output format: MP3
-
Quick Start
- Fast processing (less than 1 second)
- Natural speech generation
- Support for Thai-English mixed text
-
Key Features
- Natural speech synthesis
- Mixed language support (Thai-English)
- Emoji support
- Number, date, and currency value conversion
- Multiple voice options
- Fast processing time
-
Security & Compliance
- GDPR and PDPA compliant
- No data retention after processing
Please visit API Portal to view your existing API key or request a new one.
Code Examples
Sample Request:
- เสียงเด็กผู้ชายน้องไข่ต้ม
curl --location --request GET 'https://api.iapp.co.th/thai-tts-kaitom/tts?text=สวัสดีครับ'
--header 'apikey: {YOUR_API_KEY}'
- เสียง คุณซี ฉัตรปวีณ์ ตรีชัชวาลวงศ์ (@ceemeagain)
curl --location --request GET 'https://api.iapp.co.th/thai-tts-cee/tts?text=สวัสดีค่ะเสียงซีสังเคราะห์มาแล้วค่ะ'
--header 'apikey: {YOUR_API_KEY}'
Sample Response:
Audio file output (MP3 format). The output audio file can be previewed as below:
-
เสียงเด็กผู้ชายน้องไข่ต้ม
-
เสียง คุณซี ฉัตรปวีณ์ ตรีชัชวาลวงศ์ (@ceemeagain)
Replace the text parameter in the URL with your desired text to preview different audio outputs. You'll need to add your API key as a header to make it work.
Features & Capabilities
Core Features
- Natural speech generation
- Mixed Thai-English text support
- Emoji conversion
- Number and date formatting
- Multiple voice options
- Fast processing
Supported Fields
- Thai text
- English text
- Emojis
- Numbers
- Dates
- Currency values
API Reference
Text-to-Speech Endpoint (Kaitom Voice)
- Endpoint:
GET
https://api.iapp.co.th/thai-tts-kaitom/tts
- Required Parameters:
- apikey: Your API key (header)
- text: Text to convert to speech (query)
Text-to-Speech Endpoint (Cee Voice)
- Endpoint:
GET
https://api.iapp.co.th/thai-tts-cee/tts
- Required Parameters:
- apikey: Your API key (header)
- text: Text to convert to speech (query)
Code Examples
Python
import requests
url = "https://api.iapp.co.th/thai-tts-kaitom/tts"
headers = {"apikey": "YOUR_API_KEY"}
params = {"text": "สวัสดีครับ"}
response = requests.get(url, headers=headers, params=params)
with open("output.mp3", "wb") as f:
f.write(response.content)
JavaScript
const axios = require("axios")
const fs = require("fs")
let config = {
method: "get",
url: "https://api.iapp.co.th/thai-tts-kaitom/tts",
params: { text: "สวัสดีครับ" },
headers: { apikey: "YOUR_API_KEY" },
responseType: "arraybuffer",
}
axios(config)
.then((response) => {
fs.writeFileSync("output.mp3", response.data)
})
.catch((error) => console.log(error))
PHP
<?php
$url = "https://api.iapp.co.th/thai-tts-kaitom/tts?text=สวัสดีครับ";
$headers = array('apikey: YOUR_API_KEY');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
file_put_contents("output.mp3", $response);
curl_close($ch);
?>
Swift
import Foundation
let url = URL(string: "https://api.iapp.co.th/thai-tts-kaitom/tts?text=สวัสดีครับ&apikey={YOUR_API_KEY}")!
var request = URLRequest(url: url, timeoutInterval: Double.infinity)
request.httpMethod = "GET"
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print("Error:", String(describing: error))
return
}
// Save the data to an MP3 file
let fileManager = FileManager.default
let outputPath = fileManager.temporaryDirectory.appendingPathComponent("output.mp3")
do {
try data.write(to: outputPath)
print("Audio file saved to:", outputPath.path)
} catch {
print("Failed to save file:", error)
}
}
task.resume()
Kotlin
import okhttp3.OkHttpClient
import okhttp3.Request
import java.io.File
import java.io.FileOutputStream
fun main() {
val client = OkHttpClient()
val request = Request.Builder()
.url("https://api.iapp.co.th/thai-tts-kaitom/tts?text=สวัสดีครับ&apikey={YOUR_API_KEY}")
.build()
val response = client.newCall(request).execute()
if (response.isSuccessful) {
// Get response body as bytes
val responseBody = response.body?.bytes()
if (responseBody != null) {
// Save to a file
val outputFile = File("output.mp3")
FileOutputStream(outputFile).use { fos ->
fos.write(responseBody)
println("Audio file saved to: ${outputFile.absolutePath}")
}
} else {
println("Response body is empty.")
}
} else {
println("Request failed with status code: ${response.code}")
}
}
Java
import okhttp3.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://api.iapp.co.th/thai-tts-kaitom/tts?text=สวัสดีครับ&apikey={YOUR_API_KEY}")
.method("GET", body)
.build();
Response response = client.newCall(request).execute();
if (response.isSuccessful()) {
// Get the response body as bytes
byte[] responseBody = response.body().bytes();
// Save the response to a file
File outputFile = new File("output.mp3");
try (FileOutputStream fos = new FileOutputStream(outputFile)) {
fos.write(responseBody);
System.out.println("Audio file saved to: " + outputFile.getAbsolutePath());
} catch (IOException e) {
System.err.println("Failed to save the file: " + e.getMessage());
}
} else {
System.err.println("Request failed with status code: " + response.code());
}
// Close the response
response.close();
}
}
Dart
import 'dart:io';
import 'package:http/http.dart' as http;
void main() async {
// Create the GET request
var request = http.Request(
'GET',
Uri.parse(
'https://api.iapp.co.th/thai-tts-kaitom/tts?text=สวัสดีครับ&apikey={YOUR_API_KEY}'),
);
// Send the request
http.StreamedResponse response = await request.send();
if (response.statusCode == 200) {
// Save the response to a file
final file = File('output.mp3');
final bytes = await response.stream.toBytes();
await file.writeAsBytes(bytes);
print('Audio file saved to: ${file.path}');
} else {
print('Request failed: ${response.reasonPhrase}');
}
}
Limitations and Best Practices
Limitations
- Thai and English language support only
- Two voice options available:
- Kaitom (male voice)
- Cee (female celebrity voice)
Best Practices
- Use proper punctuation
- Keep sentences natural and conversational
- Test with small text segments first
- Consider context for natural speech flow
Accuracy & Performance
Overall Accuracy
- Natural speech quality
- Accurate pronunciation for both Thai and English
- Proper handling of numbers and special characters
Processing Speed
- Less than 1 second per request
- Consistent performance regardless of text length
Factors Affecting Quality
- Text formatting
- Punctuation
- Language mixing
- Special character usage