Text-to-Speech Service
FastAPI service chuyển văn bản thành giọng nói. Engine chính: gTTS (Google Text-to-Speech). Hỗ trợ 28+ ngôn ngữ, CPU-based, port 8041.
Hoạt động
Thông tin:
gTTS engine mặc định. Có thể tích hợp Coqui TTS (GPU) hoặc Google Cloud TTS. Dùng chung engine TTS với DeepSeek OCR service.
Base URL
https://pnt.badt.vn/text
Authentication
Bearer token:
Authorization: Bearer <API_AI_TOKEN>
API Endpoints
POST
/tts/text
Core
Chuyển văn bản thành giọng nói (gTTS engine).
| Param | Type | Required | Description |
|---|---|---|---|
| text | string | Yes | Văn bản cần đọc (max 5000 ký tự) |
| language | string | No | Mã ngôn ngữ: vi, en, ja... (mặc định: vi) |
| speed | float | No | Tốc độ đọc (1.0 = normal) |
POST
/tts/file
File
Upload file (text/PDF) để chuyển thành audio.
| Param | Type | Required | Description |
|---|---|---|---|
| file | file | Yes | Text file hoặc PDF (multipart/form-data) |
| language | string | No | Mã ngôn ngữ |
GET
/tts/languages
Utility
Danh sách 28+ ngôn ngữ hỗ trợ (gTTS).
GET
/health
Utility
Health check service.
Request Example
curl -X POST https://pnt.badt.vn/text/tts/text \\
-H "Authorization: Bearer \$API_AI_TOKEN" \\
-H "Content-Type: application/json" \\
-d '{"text": "Xin chào, đây là giọng nói tiếng Việt", "language": "vi"}' \\
--output output.mp3
import requests
response = requests.post(
"https://pnt.badt.vn/text/tts/text",
headers={"Authorization": f"Bearer {API_AI_TOKEN}"},
json={"text": "Xin chào", "language": "vi"}
)
with open("output.mp3", "wb") as f:
f.write(response.content)
Thông số kỹ thuật
EnginegTTS (default), Coqui (GPU), Google Cloud
Port8041
ComputeCPU (GPU optional)
Languages28+ ngôn ngữ
OutputMP3
Max Text5000 ký tự/request