Tahirin-kevitra
Ampidiro ny TTS.ai ao anatin'ny rindranasanao amin'ny alalan'ny REST API-ntsika. Lamina mifanaraka amin'ny OpenAI ho an'ny fifindra-monina mora.
Topy maso
The TTS.ai API provides programmatic access to all platform features: text-to-speech synthesis, speech-to-text transcription, voice cloning, audio enhancement, and more. The API uses standard REST conventions with JSON request/response bodies.
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
URL fototra
Mifandraika amin'ity URL fototra ity avokoa ny endpoint rehetra. Ohatra, ny endpoint TTS dia:
Fetra amin'ny tahan'ny
Miovaova arakaraka ny drafitra ny fetra amin'ny tahan'ny API:
| Fandaminana | Fanontaniana/minitra | Concurrent | Halavan'ny lahabolana ambony indrindra |
|---|---|---|---|
| Pro | 60 | 5 | Marika 5,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 | Unit |
|---|---|---|
| TTS (Modely maimaimpoana: Piper, VITS, MeloTTS) | credits | isan'ny marika 1000 |
| TTS (Modely mahazatra: Kokoro, CosyVoice 2, sns.) | Credits | isan'ny marika 1000 |
| TTS (Modely Premium: Tortoise, Chatterbox, sns.) | Credits | isan'ny marika 1000 |
| Hanova teny ho lahabolana | Credits | isan'ny minitran'ny feo |
| Fandraisana an-tsoratra feo | Credits | isan'ny marika 1000 |
| Mpanova feo | Credits | isan'ny minitran'ny feo |
| Fanatsarana ny feo | Credits | isan'ny minitran'ny feo |
| Fanafoanana ny feo / Fampisarahana ny feo | 3-4 credits | isan'ny minitran'ny feo |
| Fandikan-teny | Credits | isan'ny minitran'ny feo |
| Resadresaka an-peo | Credits | isaky ny fihodinana |
| 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 | Fanoritsoritana |
|---|---|---|---|
| model | string | Eny | IDn'ny modely (ohatra, kokoro, chatterbox, piper) |
| text | string | Eny | Ny lahabolana hanovaina ho feo (mahatratra marika 5.000 ho an'ny Pro, 50.000 ho an'ny Enterprise) |
| voice | string | Eny | IDn'ny feo (ampiasao ny /v1/voices/ hanehoana ireo feo misy) |
| format | string | Tsia | Lamin'ny famoahana: mp3 (tsotra), wav, flac, ogg |
| speed | float | Tsia | Fampitomboana ny hafainganan'ny fitenenana. 1.0 no sanda tsotra. Fepetra: 0.5 ka hatramin'ny 2.0 |
| language | string | Tsia | Fangon'ny teny (ohatra, en, es). Hita hoazy raha tsy voalaza. |
| stream | boolean | Tsia | Alefaso ny valin'ny streaming. Tsotra: false |
Fanontaniana 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
Returns the audio file as binary data with appropriate Content-Type header (audio/mpeg, audio/wav, etc.).
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 | Fanoritsoritana |
|---|---|---|---|
| file | file | Eny | Raki-peo (MP3, WAV, FLAC, OGG, M4A, MP4, WebM). 100MB farafahakeliny. |
| model | string | Tsia | Modelin'ny STT: whisper (tsotra), faster-whisper, sensevoice |
| language | string | Tsia | Fangon'ny teny. auto ho an'ny famantarana hoazy (tsotra). |
| timestamps | boolean | Tsia | Ataovy tafiditra ny famaritana ny fotoana amin'ny ambaratongan'ny teny. Famaritana tsotra: false |
| diarize | boolean | Tsia | 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 | Fanoritsoritana |
|---|---|---|---|
| reference_audio | file | Eny | Feon'ilay feon-teny (10-30 segondra no toro-hevitra). 20MB farafahakeliny. |
| text | string | Eny | Soratra holazaina amin'ny feon'ny dika mitovy. |
| model | string | Tsia | Modelin'ny clone: chatterbox (tsotra), cosyvoice2, gpt-sovits
|
| format | string | Tsia | Lamin'ny famoahana: mp3 (tsotra), wav, flac |
| language | string | Tsia | Fangon'ny teny tanjona. Tsy maintsy raisin'ny modely voafaritra an-tànana izy io. |
Valiny
Mamerina 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 | 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 | Tsia | Modelin'ny fanovana feo: openvoice (tsotra), knn-vc |
| format | string | Tsia | Lamin'ny famoahana: wav (tsotra), mp3, flac |
Fanontaniana 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
Mamerina ny rakitra audio nanovaina ho data binary.
Fandikan-teny
Adikao amin'ny teny iray mankany amin'ny teny iray hafa ny feo voalaza. Mitambatra amin'ny antso tokana ny fanehoana ny feo amin'ny soratra, ny fandikan-teny, ary ny fanehoana ny soratra amin'ny feo.
Ny vatan'ilay fangatahana (multipart/form-data)
| Famaritana | Karazana | Tsy maintsy | Fanoritsoritana |
|---|---|---|---|
| file | file | Eny | Raki-peo loharano amin'ny teny niaviany. 100MB farafahakeliny. |
| target_language | string | Eny | Fangon'ny teny iantefana (ohatra, es, fr, de, ja) |
| voice | string | Tsia | Feo ho an'ny famoahana fandikan-teny. Ho voafaritra hoazy raha tsy voalaza. |
| preserve_voice | boolean | Tsia | Manandrana mitahiry ny mpiteny voalohany |
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 fitenenana, ny fihetseham-po, na ny fanehoana raha toa ka tsy miova ny votoaty. Manampy amin'ny fanatsarana ny feo, ny hafainganam-pandeha, ary ny fanehoana.
Ny vatan'ilay fangatahana (multipart/form-data)
| Famaritana | Karazana | Tsy maintsy | Fanoritsoritana |
|---|---|---|---|
| file | file | Eny | Raki-peo loharano. 50MB farafahakeliny. |
| voice | string | Eny | IDn'ny feon'ny tanjona ho an'ny feon'ny famoahana |
| model | string | Tsia | Modely: openvoice (tsotra), chatterbox
|
| emotion | string | Tsia | Fihetseham-po kendrena: tsy miangatra, faly, mampalahelo, tezitra, mihetsi-po |
| speed | float | Tsia | Fandrindrana ny hafainganan'ny sary. 1.0 no sanda tsotra. Isa: 0.5 ka hatramin'ny 2.0 |
Valiny
Mamerina 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 | Mampitombo 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 tsipika: 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 azo esorina |
| type string | echo or reverb (default: both) |
| intensity integer | 1-5 (default: 3) |
Manadihady ny feo mba hahitana ny kitendry, ny BPM, ary ny famantarana 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 eo anelanelan'ny lamina.
| 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 | Fanoritsoritana |
|---|---|---|---|
| audio | file | Tsia* | Fidirana feo (na audio na text no ilaina) |
| text | string | Tsia* | Fampidirana lahabolana (na audio na text no ilaina) |
| voice | string | Tsia | Feo ho an'ny valin'ny AI. Tsotra: af_bella |
| tts_model | string | Tsia | Modelin'ny TTS ho an'ny valinteny. Lasitra: kokoro |
| system_prompt | string | Tsia | Fampilazan'ny rafitra safidy ho an'ny AI |
| conversation_id | string | Tsia | 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
}
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.
Famaritana ny fanontaniana
| 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 credits for this request.",
"credits_required": 4,
"credits_available": 2
}
}
| Fivoaran'ny HTTP | Error Code | Fanoritsoritana |
|---|---|---|
| 400 | bad_request |
Tsy mitombina ny parameter'ny fangatahana. Jereo ao amin'ny hafatra tsy fetezana ny antsipiriany. |
| 401 | unauthorized |
Famaha API tsy misy na diso. |
| 402 | insufficient_credits |
Tsy ampy ny credits. 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 loham-pejin'ny fetra. |
| 500 | internal_error |
Tsy fetezan'ny mpizara. Andramo indray aorian'izay. |
| 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 anatin'ny rindranasanao.