Tahirin-kevitra
Ampidiro ao anatin'ny rindranasanao ny TTS.ai amin'ny alalan'ny API REST-ntsika. Lamina mifanaraka amin'ny OpenAI ho an'ny fifindra-monina mora.
Topy maso
Ny TTS.ai API dia manome fidirana amin'ny alalan'ny rindrambaiko amin'ireo endriky ny sehatra rehetra: fandikana lahatsoratra ho teny, fandikana teny ho teny, fandikana feo, fanatsarana ny feo, ary maro hafa.
Famaha API
Maka ny famaha API avy amin'ny Fandrindrana ny kaonty. Azo ampiasaina amin'ny programa Pro sy Enterprise.
URL fototra
https://api.tts.ai/v1/
Fanamarinana
Ny token'ny mpitondra amin'ny alalana Authorization loham-pejy
Fanamarinana
Ny fangatahana API rehetra dia mila fanamarinana amin'ny alalan'ny token Bearer ao amin'ny Authorization loham-pejy.
Authorization: Bearer sk-tts-your-api-key-here
SDK
Ny SDK ofisialy dia manamora ny fampidirana ny TTS.ai ao anatin'ny rindran'asao. Ireo roa ireo dia loharano misokatra ary azo jerena ao amin'ny GitHub.
Python
pip install ttsai
from tts_ai import TTSClient
client = TTSClient(api_key="sk-tts-...")
audio = client.generate(
text="Hello world!",
model="kokoro"
)
client.save(audio, "output.wav")
JavaScript / Node.js
npm install @ttsainpm/ttsai
const { TTSClient } = require('@ttsainpm/ttsai');
const client = new TTSClient({
apiKey: 'sk-tts-...'
});
const audio = await client.generate({
input: 'Hello world!',
model: 'kokoro'
});
await client.saveToFile(audio, 'output.wav');
URL fototra
Mifandray amin'ity URL fototra ity ny endpoint rehetra. Ohatra, ny endpoint TTS dia:
Fetra amin'ny tahan'ny fidirana
Miovaova arakaraka ny drafitra ny fetra amin'ny tahan'ny API:
| _Fomba | Fanontaniana/minitra | Mifanaraka | Halavan'ny lahabolana ambony indrindra |
|---|---|---|---|
| Free | 10 | 2 | Marika 500 |
| Mpandefa | 30 | 3 | Marika 100.000 |
| Pro | 60 | 5 | Marika 100.000 |
| Enterprise | 300 | 20 | Marika 50.000 |
Ao anatin'ny valintenin'ny tsirairay ny loham-pejy momba ny fetrany: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset.
Fandoavana trosa
| Sampan'asa | Sanda | _Indraindray |
|---|---|---|
| TTS (Modely maimaimpoana: Piper, VITS, MeloTTS) | Marika 1,000 | isan'ny marika 1000 |
| TTS (Modely mahazatra: Kokoro, CosyVoice 2, sns.) | 2,000 characters | isan'ny marika 1000 |
| TTS (Modely Premium: Tortoise, Chatterbox, sns.) | Marika 4,000 | isan'ny marika 1000 |
| Hanova teny ho lahabolana | 2,000 characters | isan'ny minitra |
| Fandraisana an-tsoratra feo | Marika 4,000 | isan'ny marika 1000 |
| Mpanova feo | 3,000 marika | isan'ny minitra |
| Fanatsarana ny feo | 2,000 characters | isan'ny minitra |
| Fandraisana feo / Fampisarahana feo | 3,000-4,000 characters | isan'ny minitra |
| Fandikan-teny | Marika 5,000 | isan'ny minitra |
| Resadresaka an-peo | 3,000 marika | isan-tokony |
| Key Finder & BPM | Free | -- |
| Mpanova feo | Free | -- |
Soratra mankany amin'ny feo
Manova ny lahabolana ho feo. Mamaly ny raki-peo amin'ny lamina takiana.
Ny vatan'ilay fangatahana
| Famaritana | Karazana | Tsy maintsy atao | Fanoritsoritana |
|---|---|---|---|
| model | string | Eny | IDn'ny modely (ohatra, kokoro, chatterbox, piper) |
| text | string | Eny | Lahabolana hanovaina ho teny miresaka (marika 100.000 farafahakeliny isaky ny fangatahana) |
| voice | string | Eny | IDn'ny feo (ampiasao ny /v1/voices/ hanehoana ireo feo misy) |
| format | string | Tsy misy | Lamin'ny famoahana: mp3 (tsotra), wav, flac, ogg |
| speed | float | Tsy misy | Fampitomboana ny hafainganan'ny fitenenana. 1.0 ny sanda tsotra. Isa: 0.5 ka hatramin'ny 2.0 |
| language | string | Tsy misy | Fangon'ny teny (ohatra, en, es). Hita hoazy raha tsy voalaza. |
| stream | boolean | Tsy misy | Alefaso ny valin'ny streaming. Fandraisana tsotra: false |
Ohatra
curl -X POST https://api.tts.ai/v1/tts/ \
-H "Authorization: Bearer sk-tts-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "kokoro",
"text": "Hello from TTS.ai! This is a test.",
"voice": "af_bella",
"format": "mp3"
}' \
--output output.mp3
Valiny
Mandefa ilay rakitra audio amin'ny endrika data binary miaraka amin'ny loham-pejy Content-Type mety (audio/mpeg, audio/wav, sns.).
Content-Type: audio/mpeg
Content-Length: 48256
X-Credits-Used: 2
X-Credits-Remaining: 498
Hanova teny ho lahabolana
Manova feo ho lasa lahabolana. Mandray an-tànana ny teny 99 miaraka amin'ny famantarana hoazy.
Ny vatan'ilay fangatahana (multipart/form-data)
| Famaritana | Karazana | Tsy maintsy atao | Fanoritsoritana |
|---|---|---|---|
| file | file | Eny | Raki-peo (MP3, WAV, FLAC, OGG, M4A, MP4, WebM). 100MB farafahakeliny. |
| model | string | Tsy misy | Modelin'ny STT: whisper (tsotra), faster-whisper, sensevoice |
| language | string | Tsy misy | Fangon'ny teny. auto ho an'ny famantarana hoazy (tsotra). |
| timestamps | boolean | Tsy misy | Ataovy tafiditra ny famaritana ny fotoana amin'ny ambaratongan'ny teny. Famaritana tsotra: false |
| diarize | boolean | Tsy misy | Alefaso ny fanoratana amin'ny diary ny mpandahateny. Tsotra: false |
Valiny
{
"text": "Hello, this is a transcription test.",
"language": "en",
"duration": 3.5,
"segments": [
{
"start": 0.0,
"end": 1.8,
"text": "Hello, this is",
"speaker": "SPEAKER_00"
},
{
"start": 1.8,
"end": 3.5,
"text": "a transcription test.",
"speaker": "SPEAKER_00"
}
]
}
Fandraisana an-tsoratra feo
Mamorona kabary amin'ny alalan'ny feo nalaina. Akaro ny feo sy ny lahabolana voalaza.
Ny vatan'ilay fangatahana (multipart/form-data)
| Famaritana | Karazana | Tsy maintsy atao | Fanoritsoritana |
|---|---|---|---|
| reference_audio | file | Eny | Feo-peo fototra (10-30 segondra no toro-hevitra). 20MB farafahakeliny. |
| text | string | Eny | Soratra holazaina amin'ny feo voakidy. |
| model | string | Tsy misy | Modelin'ny klona: chatterbox (tsotra), cosyvoice2, gpt-sovits
|
| format | string | Tsy misy | Lamin'ny famoahana: mp3 (tsotra), wav, flac |
| language | string | Tsy misy | Fangon'ny teny iantefana. Tsy maintsy raisin'ny modely voafaritra an-tànana izany. |
Valiny
Mamaly ny rakitra audio amin'ny endrika data binary, mitovy amin'ny farany TTS.
Mpanova feo
Manova ny feo ho toy ny feo hafa. Akaro ny feo loharano ary safidio ny feon'ny tanjona.
Ny vatan'ilay fangatahana (multipart/form-data)
| Famaritana | Karazana | Tsy maintsy atao | Fanoritsoritana |
|---|---|---|---|
| file | file | Eny | Raki-peo loharano (MP3, WAV, FLAC). 50MB farafahakeliny. |
| target_voice | string | Eny | Ny ID-n'ny feon'ny tanjona hanovaina (ampiasao ny /v1/voices/ hanehoana ny lisitry ny feon'ny mpampiasa) |
| model | string | Tsy misy | Modelin'ny fanovana feo: openvoice (tsotra), knn-vc |
| format | string | Tsy misy | Lamin'ny famoahana: wav (tsotra), mp3, flac |
Ohatra
curl -X POST https://api.tts.ai/v1/voice-convert/ \
-H "Authorization: Bearer sk-tts-your-key" \
-F "file=@source_audio.mp3" \
-F "target_voice=af_bella" \
-F "model=openvoice" \
-o converted.wav
Valiny
Mamaly ny rakitra audio nanovaina ho data binary.
Fandikan-teny
Manova feo avy amin'ny teny iray ho amin'ny teny iray hafa. Mampifandray ny fiteny ho an-tsoratra, ny fandikan-teny, ary ny lahabolana ho an-tsoratra anatin'ny antso iray.
Ny vatan'ilay fangatahana (multipart/form-data)
| Famaritana | Karazana | Tsy maintsy atao | Fanoritsoritana |
|---|---|---|---|
| file | file | Eny | Rakitra audio loharano amin'ny teny niaviany. 100MB farafahakeliny. |
| target_language | string | Eny | Fangon'ny teny iantefana (ohatra, es, fr, de, ja) |
| voice | string | Tsy misy | Feo ho an'ny famoahana fandikan-teny. Safidio hoazy raha tsy voalaza. |
| preserve_voice | boolean | Tsy misy | Manandrana mametra ny toetran'ny feony. Famaritana tsotra: false |
Valiny
{
"original_text": "Hello, how are you?",
"translated_text": "Hola, como estas?",
"source_language": "en",
"target_language": "es",
"audio_url": "https://api.tts.ai/v1/results/translate_abc123.mp3",
"credits_used": 5
}
Teny amin'ny Teny
Manova ny fomba fiteny, ny fihetseham-po, na ny fanehoana raha toa ka tsy miova ny votoaty. Mety ampiasaina amin'ny fanatsarana ny feo, ny fivoahana, ary ny fitenenana.
Ny vatan'ilay fangatahana (multipart/form-data)
| Famaritana | Karazana | Tsy maintsy atao | Fanoritsoritana |
|---|---|---|---|
| file | file | Eny | Raki-peo loharano. 50MB farafahakeliny. |
| voice | string | Eny | IDn'ny feo iantefana ho an'ny feon'ny famoahana |
| model | string | Tsy misy | Modely: openvoice (tsotra), chatterbox
|
| emotion | string | Tsy misy | Fihetseham-po kendrena: tsy miangatra, faly, mampalahelo, tezitra, mihetsi-po |
| speed | float | Tsy misy | Fandrindrana ny hafainganan'ny fandefasana. 1.0 no sanda tsotra. Isa: 0.5 ka hatramin'ny 2.0 |
Valiny
Mamaly ny rakitra audio nanovaina ho data binary.
Fitaovana audio
Fiandohan'ny fikarakarana ny feo ho an'ny fanatsarana, fanafoanana ny feo, fizarazarana ny fototra, ary maro hafa.
Manatsara ny kalitaon'ny feo: manafoana ny tabataba, manatsara ny fahazavana, fanatsarana ny vahaolana.
| file file | Raki-peo hanatsarana |
| denoise boolean | Alefaso ny fanafoanana ny feo (tsotra: marina) |
| enhance_clarity boolean | Manatsara ny fahamendrehan'ny feo (tsotra: marina) |
| super_resolution boolean | Mampandeha ny kalitaon'ny feo (tsotra: diso) |
| strength integer | 1-3 (maivana, antonony, mafy). Lasitra: 2 |
Mizara ny feo avy amin'ny fitaovana (fanafoanana ny feo) na mizara amin'ny tahony.
| file file | Raki-peo hozaraina |
| model string | demucs (default) na spleeter |
| stems integer | Isan'ny andry: 2, 4, 5, na 6 (tsotra: 2) |
| format string | Lamin'ny famoahana: wav, mp3, flac |
Manaisotra ny echo sy ny reverb amin'ny fandraiketana feo.
| file file | Raki-peo hosokafana |
| type string | echo or reverb (default: both) |
| intensity integer | 1-5 (default: 3) |
Manadihady ny feo mba hahitana ny kitendry, ny BPM, ary ny fanamarinana ny fotoana.
| file file | Raki-peo hozaraina |
{
"key": "C",
"scale": "Major",
"bpm": 120.0,
"time_signature": "4/4",
"camelot": "8B",
"compatible_keys": ["C Major", "G Major", "F Major", "A Minor"]
}
Manova ny feo amin'ny lamin'ny feo maro.
| file file | Raki-peo hanovaina |
| format string | Lamin'ny tanjona: mp3, wav, flac, ogg, m4a, aac |
| bitrate integer | Bitraten'ny famoahana (kbps): 64, 128, 192, 256, 320 |
| sample_rate integer | Isan'ny santionany: 22050, 44100, 48000 |
| channels string | mono na stereo |
Resadresaka an-peo
Mandefa feo na soratra ary mahazo valinteny avy amin'ny AI miaraka amin'ny fitenenana novokarina.
Ny vatan'ilay fangatahana (multipart/form-data na JSON)
| Famaritana | Karazana | Tsy maintsy atao | Fanoritsoritana |
|---|---|---|---|
| audio | file | Tsy misy* | Fidirana feo (na audio na text no ilaina) |
| text | string | Tsy misy* | Fampidirana lahabolana (na audio na text no ilaina) |
| voice | string | Tsy misy | Feo ho an'ny valin'ny AI. Tsotra: af_bella |
| tts_model | string | Tsy misy | Modelin'ny TTS ho an'ny valinteny. Lasitra: kokoro |
| system_prompt | string | Tsy misy | Fampandrenesana safidy ho an'ny AI |
| conversation_id | string | Tsy misy | Manohy resadresaka efa misy |
Valiny
{
"conversation_id": "conv_abc123",
"user_text": "What is the capital of France?",
"ai_text": "The capital of France is Paris.",
"audio_url": "https://api.tts.ai/v1/audio/tmp/resp_xyz.mp3",
"credits_used": 3
}
Batch TTS
Mandefa lahabolana maro ho an'ny famoronana TTS mifanaraka. Azo atao ny mandray antso webhook rehefa vita ny asa rehetra.
Famaritana
| Mpizahaky ny macro | Karazana | Fanoritsoritana |
|---|---|---|
| texts | array | Array of objects: {text, model, voice}. Max 50 items. |
| webhook_url | string | Optional URL to POST results when batch completes. |
Valiny
{
"batch_id": "abc123",
"total": 3,
"completed": 0,
"status": "processing"
}
Fivoaran'ny fitsapankevitra amin'ny alalan'ny GET /v1/tts/batch/result/?batch_id=abc123
Fampidirana feo
Mamaritra mialoha ny fampidirana feo avy amin'ny feo mpisolo. Ampiasao ny embed_id averina amin'ny fangatahana fandikana feo manaraka mba hamoronana haingana.
Famaritana
| Mpizahaky ny macro | Karazana | Fanoritsoritana |
|---|---|---|
| file | file | Reference audio file (WAV, MP3, FLAC). |
| model | string | Cloning model (default: chatterbox). Supported: chatterbox, cosyvoice2, openvoice, gpt-sovits, spark, indextts2, qwen3-tts. |
Valiny
{
"embed_id": "emb_abc123",
"model": "chatterbox",
"duration_ms": 450
}
Fanamarinana ny fahasalamana
Mijery ny toetr'ilay mpizara GPU, ny modely nakarina, ary ny haben'ny filaharana. Tsy mila fanamarinana. Voatahiry mandritra ny 30 segondra.
Valiny
{
"status": "online",
"latency_ms": 45,
"queue_size": 3,
"models_loaded": ["kokoro", "chatterbox", "cosyvoice2"]
}
Lisitry ny modely
Manome lisitr'ireo modely misy rehetra miaraka amin'ny fahaizany.
Valiny
{
"models": [
{
"id": "kokoro",
"name": "Kokoro",
"type": "tts",
"tier": "standard",
"languages": ["en", "ja", "ko", "zh", "fr"],
"supports_cloning": false,
"supports_streaming": true,
"credits_per_1k_chars": 2
},
{
"id": "chatterbox",
"name": "Chatterbox",
"type": "tts",
"tier": "premium",
"languages": ["en"],
"supports_cloning": true,
"supports_streaming": true,
"credits_per_1k_chars": 4
}
]
}
Lisitry ny feo
Manome lisitr'ireo feo misy rehetra, azo sivana araka ny modely na ny teny.
Mpizahaky ny fanatanterahana
| Famaritana | Karazana | Fanoritsoritana |
|---|---|---|
| model | string | Sivana araka ny ID modely (ohatra, kokoro) |
| language | string | Sivana araka ny famantaran'ny teny (ohatra, en) |
| gender | string | Sivana araka ny karazany: lahy, vavy, tsy miangatra
|
Valiny
{
"voices": [
{
"id": "af_bella",
"name": "Bella",
"model": "kokoro",
"language": "en",
"gender": "female",
"preview_url": "https://api.tts.ai/v1/voices/preview/af_bella.mp3"
}
],
"total": 142
}
Ohatran'ny soratra
Soratra mankany amin'ny feo
import requests
API_KEY = "sk-tts-your-key"
# Text to Speech
response = requests.post(
"https://api.tts.ai/v1/tts/",
headers={"Authorization": f"Bearer {API_KEY}"},
json={
"model": "kokoro",
"text": "Hello from TTS.ai!",
"voice": "af_bella",
"format": "mp3"
}
)
with open("output.mp3", "wb") as f:
f.write(response.content)
print(f"Credits used: {response.headers.get('X-Credits-Used')}")
Hanova teny ho lahabolana
# Speech to Text
with open("recording.mp3", "rb") as f:
response = requests.post(
"https://api.tts.ai/v1/stt/",
headers={"Authorization": f"Bearer {API_KEY}"},
files={"file": f},
data={"model": "faster-whisper", "timestamps": "true"}
)
result = response.json()
print(result["text"])
Fandraisana an-tsoratra feo
# Voice Cloning
with open("reference.wav", "rb") as ref:
response = requests.post(
"https://api.tts.ai/v1/tts/clone/",
headers={"Authorization": f"Bearer {API_KEY}"},
files={"reference_audio": ref},
data={
"text": "This speech uses a cloned voice.",
"model": "chatterbox"
}
)
with open("cloned_output.mp3", "wb") as f:
f.write(response.content)
Soratra mankany amin'ny feo
const API_KEY = 'sk-tts-your-key';
// Text to Speech
const response = await fetch('https://api.tts.ai/v1/tts/', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'kokoro',
text: 'Hello from TTS.ai!',
voice: 'af_bella',
format: 'mp3'
})
});
const audioBlob = await response.blob();
const audioUrl = URL.createObjectURL(audioBlob);
const audio = new Audio(audioUrl);
audio.play();
Hanova teny ho lahabolana
// Speech to Text
const formData = new FormData();
formData.append('file', audioFile);
formData.append('model', 'faster-whisper');
const response = await fetch('https://api.tts.ai/v1/stt/', {
method: 'POST',
headers: { 'Authorization': `Bearer ${API_KEY}` },
body: formData
});
const result = await response.json();
console.log(result.text);
Soratra mankany amin'ny feo
# Text to Speech
curl -X POST https://api.tts.ai/v1/tts/ \
-H "Authorization: Bearer sk-tts-your-key" \
-H "Content-Type: application/json" \
-d '{"model":"kokoro","text":"Hello!","voice":"af_bella","format":"mp3"}' \
-o output.mp3
Hanova teny ho lahabolana
# Speech to Text
curl -X POST https://api.tts.ai/v1/stt/ \
-H "Authorization: Bearer sk-tts-your-key" \
-F "file=@recording.mp3" \
-F "model=faster-whisper" \
-F "timestamps=true"
Fandraisana an-tsoratra feo
# Voice Cloning
curl -X POST https://api.tts.ai/v1/tts/clone/ \
-H "Authorization: Bearer sk-tts-your-key" \
-F "reference_audio=@reference.wav" \
-F "text=This uses a cloned voice." \
-F "model=chatterbox" \
-o cloned.mp3
Fanatsarana ny feo
# Audio Enhancement
curl -X POST https://api.tts.ai/v1/audio/enhance/ \
-H "Authorization: Bearer sk-tts-your-key" \
-F "file=@noisy_audio.mp3" \
-F "denoise=true" \
-F "enhance_clarity=true" \
-o enhanced.mp3
Famaha tsy fetezana
Ny tsy fetezana rehetra dia mamoaka valinteny JSON misy error field.
{
"error": {
"code": "insufficient_credits",
"message": "You do not have enough characters for this request.",
"characters_required": 4000,
"characters_available": 2000
}
}
| Fivoaran'ny HTTP | Famaha tsy fetezana | Fanoritsoritana |
|---|---|---|
| 400 | bad_request |
Tsy mety ny mpizondron'ilay fangatahana. Jereo ny hafatra tsy fetezana raha mila fanazavana fanampiny. |
| 401 | unauthorized |
Famaha API tsy misy na diso. |
| 402 | insufficient_credits |
Tsy ampy ny marika. Mividy bebe kokoa ao amin'ny /pricing/. |
| 403 | forbidden |
Tsy misy fidirana amin'ny API amin'ny drafitrao. |
| 404 | not_found |
Tsy hita ny modely na ny feo. |
| 413 | file_too_large |
Mihoatra ny fetra ny haben'ilay rakitra nalefa. |
| 429 | rate_limited |
Maro loatra ireo fangatahana. Jereo ny lohateny famaritana ny fetra. |
| 500 | internal_error |
Tsy fetezan'ny mpizara. Andramo indray atsy ho atsy. |
| 503 | model_loading |
Maka ilay modely. Andramo indray aorian'ny segondra vitsy. |
Webhooks
Ho an'ny asa maharitra (fizarazarana fototra, batch TTS), dia afaka manome tsindry webhook_url ianao. Rehefa vita ilay asa, dia handefa ny vokatra any amin'ny URL-nao izahay.
{
"event": "task.completed",
"task_id": "task_abc123",
"status": "success",
"result_url": "https://api.tts.ai/v1/results/task_abc123",
"credits_used": 12,
"created_at": "2025-01-15T10:30:00Z",
"completed_at": "2025-01-15T10:30:45Z"
}
Vonona ny hanangana?
Maka ny famaha API-nao ary manomboka mampiditra ny TTS.ai ao amin'ny rindranasanao.