Papatono API
Ka whakaurua a TTS.ai ki ōna taupānga me a tātau REST API. He āhua ōrite OpenAI mō te hekenga ngāwari.
Whakamāramatanga
Ka homai e te TTS.ai API te āheitanga papatono ki ngā āhuahira papatono katoa: te whakakotahitanga kupu-ki-rongo, te whakawhitinga reo-ki-rongo, te tārua reo, te whakarei oro, me ētahi atu.
Papamahi API
Ki te whiwhi i tātou kī API mai i Ka taea te whakawātea te kāwanatanga o te kāwanatanga.. Kei te wātea i runga i ngā mahere Pro me Enterprise.
URL taketake
https://api.tts.ai/v1/
Ka whakaaetia
Mā te tohu kaihautū Authorization kaipupuru
Tuakiritanga
E hiahiatia ana e ngā tono API katoa te manatoko mā tētahi tohu Bearer i roto i te Authorization kaipupuru.
Authorization: Bearer sk-tts-your-api-key-here
URL taketake
E pā ana ngā wāhi mutunga katoa ki tēnei URL taketake. Hei tauira, ko te wāhi mutunga TTS:
Te mokatere o ngā tepe
He rerekē ngā tepe ine API e ai ki te mahere:
| Rārangi | E hiahiatia ana/min | E ōrite ana | Te roa rawa o te kupu |
|---|---|---|---|
| Pro | 60 | 5 | 5,000 ngā pūāhua |
| Kaupapa | 300 | 20 | 50,000 ngā pūāhua |
Kei roto i ia urupare nga taitapa tepe o te mokatere: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset.
Ko ngā utu pūtea
| Waihoki | Ko te utu | Waihoki |
|---|---|---|
| TTS (ngā tauira wātea: Piper, VITS, MeloTTS) | 1 pūpū | i ia 1,000 ngā tohu |
| TTS (ngā tauira paerewa: Kokoro, CosyVoice 2, etc.) | 2 ngā uara | i ia 1,000 ngā tohu |
| TTS (Wāhi tauira: Tortoise, Chatterbox, etc.) | 4 ngā uara | i ia 1,000 ngā tohu |
| Ka kōrerorerotia te kuputuhi | 2 ngā uara | i ia minu o te oro |
| Ko te tāruatanga reo | 4 ngā uara | i ia 1,000 ngā tohu |
| Kaitautoko reo | 3 ngā uara | i ia minu o te oro |
| Whakarei ake reo | 2 ngā uara | i ia minu o te oro |
| Ka tangohia te pūoro / Te whakawehenga pūoro | 3-4 ngā uara | i ia minu o te oro |
| Whakamāoritanga kōrero | 5 ngā uara | i ia minu o te oro |
| Pāpāho reo | 3 ngā uara | i ia huringa |
| Ka kitea te kī BPM | Waihoki | -- |
| Ka whakarerekētia te oro | Waihoki | -- |
Waihoki ki te kōrero
Ka tahuri te kupu ki te oro reo. Ka hoki te faila oro ki te hanga e hiahiatia ana.
Ka tono te tinana
| Parameter | Kāhua | E hiahiatia ana | Whakamāramatanga |
|---|---|---|---|
| model | string | He | Tau tauira (hei tauira, kokoro, chatterbox, piper) |
| text | string | He | Te kupu hei tahuri ki te kōrero (ki te 5,000 ngā pūāhua mō Pro, 50,000 mō Enterprise) |
| voice | string | He | Voice ID (ka whakamahia te /v1/voices/ hei whakarārangi i ngā reo e wātea ana) |
| format | string | Kāore | Kāhua huaputa: mp3 (matatū), wav, flac, ogg |
| speed | float | Kāore | Ka whakarea te tere kōrero. Papatono: 1.0. Rārangi: 0.5 ki 2.0 |
| language | string | Kāore | Ko te waehere reo (hei tauira, en, es). Ka kitea-māori mēnā ka waihotia. |
| stream | boolean | Kāore | Whakahaere i te urupare rerenga. Tūturu: whakahaere |
Ka tono tauira
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
Ka urupare
Ka whakahokia te pūkete oro hei raraunga ā-rua me te taitapa tika
Content-Type
(oro/mpeg
,oro/wav
, ērā atu mea).Content-Type: audio/mpeg
Content-Length: 48256
X-Credits-Used: 2
X-Credits-Remaining: 498
Ka kōrerorerotia te kuputuhi
Ka whakawhiti reo ki te kupu. E tautoko ana i ngā reo 99 me te kitenga aunoa.
Ka tono te tinana (multipart/form-data)
| Parameter | Kāhua | E hiahiatia ana | Whakamāramatanga |
|---|---|---|---|
| file | file | He | Ko te pūkete oro (MP3, WAV, FLAC, OGG, M4A, MP4, WebM). Tūtohu 100MB. |
| model | string | Kāore | Tauira STT: whisper (matatū), faster-whisper, sensevoice
|
| language | string | Kāore | Ko te waehere reo. auto mō te kitenga aunoa (whakahaere). |
| timestamps | boolean | Kāore | Kei roto ko ngā tohu wā o te taumata-wā. Tūturu: pūnaha |
| diarize | boolean | Kāore | Mā te whakahohe kaikōrero i te kaikōrero. Tūturu: whakahē |
Ka urupare
{
"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"
}
]
}
Ko te tāruatanga reo
Ka whakaputaina te kōrero i roto i tētahi reo tārua. Whakahauhau i tētahi oro tohutoro me te kupu.
Ka tono te tinana (multipart/form-data)
| Parameter | Kāhua | E hiahiatia ana | Whakamāramatanga |
|---|---|---|---|
| reference_audio | file | He | Ko te oro oro tohutoro (10-30 sekon i whakaritea). 20MB te nui rawa. |
| text | string | He | Ka kōrerotia te kupu i roto i te reo tārua. |
| model | string | Kāore | Kāhua tārua: chatterbox (matatū), cosyvoice2, gpt-sovits
|
| format | string | Kāore | Hanganga huaputa: mp3 (matatū), wav, flac |
| language | string | Kāore | Ko te waehere reo ūnga. Me tautokona e te tauira i kōwhiria. |
Ka urupare
Ka hoki te pūkete oro hei raraunga ā-rua, pērā ki te wāhi mutunga TTS.
Kaitautoko reo
Ka tahuri te oro hei oro pēnei i tētahi atu reo. Whakahauhau i te oro pūtake me te kōwhiri i tētahi reo ūnga.
Ka tono te tinana (multipart/form-data)
| Parameter | Kāhua | E hiahiatia ana | Whakamāramatanga |
|---|---|---|---|
| file | file | He | Ko te pūtake o te pūkete oro (MP3, WAV, FLAC). Tūtohu 50MB. |
| target_voice | string | He | Ko te tuakiri reo ūnga hei tahuri ki (ka whakamahia te /v1/voices/ hei whakarārangi i ngā reo e wātea ana) |
| model | string | Kāore | Tauira tahuri reo: openvoice (matatū), knn-vc |
| format | string | Kāore | Hanganga huaputa: wav (matatū), mp3, flac |
Ka tono tauira
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
Ka urupare
Ka hoki te faila oro i tahuri hei raraunga ā-rua.
Whakamāoritanga kōrero
Ka whakamāori i te oro i kōrerotia mai i tētahi reo ki tētahi atu. Ka whakakotahi i te kōrero ki te kupu, te whakamāoritanga, me te kupu-ki-te-kōrero i roto i tētahi kīanga kotahi.
Ka tono te tinana (multipart/form-data)
| Parameter | Kāhua | E hiahiatia ana | Whakamāramatanga |
|---|---|---|---|
| file | file | He | Ko te pūtake o te pūkete oro i roto i te reo taketake. 100MB te nui rawa. |
| target_language | string | He | Ko te waehere reo ūnga (hei tauira, es, fr, de, ja) |
| voice | string | Kāore | Ko te reo mō te huaputa whakamāoritia. Ka tīpakotia mēnā ka waihotia. |
| preserve_voice | boolean | Kāore | Ka ngana ki te pupuri i te kaikōrero taketake |
Ka urupare
{
"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
}
Whakawhitiwhiti ki te kōrero
Ka whakarerekē te kāhua kōrero, te āhuahira, te whakarato rānei i te wā e pupuri ana i ngā ihirangi. Ka whai painga mō te whakarerekētanga o te tono, te whakatere, me te whakamāramatanga.
Ka tono te tinana (multipart/form-data)
| Parameter | Kāhua | E hiahiatia ana | Whakamāramatanga |
|---|---|---|---|
| file | file | He | Ko te pūtake o te pūkete oro. Te nui rawa 50MB. |
| voice | string | He | Ko te tuakiri reo ūnga mō te kōrero huaputa |
| model | string | Kāore | Tauira: openvoice (matatū), chatterbox
|
| emotion | string | Kāore | Āhuatanga whāinga: |
| speed | float | Kāore | Ka whakaritea te tere. Papatono: 1.0. Rārangi: 0.5 ki 2.0 |
Ka urupare
Ka whakahokia te pūranga oro hei raraunga ā-rua.
Huakaʻi oro
Ko ngā wāhi mutunga o te tukanga oro mō te whakarei ake, te tango i te reo, te whakawehenga rākau, me ētahi atu.
Mā te whakarei ake i te āhuatanga oro: te whakarerekētanga, te whakarei ake i te mārama, te whakamāramatanga tino pai.
| file file | Ko te faila oro e whakarei ake ai |
| denoise boolean | Whakahaere i te whakakoretanga (whakahaere: pono) |
| enhance_clarity boolean | Whakarei ake i te mārama o te kōrero (whakarere: pono) |
| super_resolution boolean | Mā te whakapiki i te āhuatanga oro (whakahaere: hē) |
| strength integer | 1-3 (māmā, waenganui, kaha). Papatono: 2 |
Mā te wehe i ngā pūoro mai i ngā utauta pūoro (hoatu pūoro), ka wehe rānei ki ngā rākau.
| file file | Ko te pūkete oro e wehe ana |
| model string | demucs (Papatono) rānei spleeter |
| stems integer | Te tau o ngā rākau: 2, 4, 5, 6 rānei (whakahitu: 2) |
| format string | Hanganga huaputa: wav, mp3, flac |
Ka tangohia te whakairo me te whakairo mai i ngā pūkete oro.
| file file | Ko te faila oro e mahia ana |
| type string | echo or reverb (default: both) |
| intensity integer | 1-5 (default: 3) |
Ka tātari i te oro hei kite i te kī, te BPM, me te tohu wā.
| file file | Ko te pūkete oro hei tātari |
{
"key": "C",
"scale": "Major",
"bpm": 120.0,
"time_signature": "4/4",
"camelot": "8B",
"compatible_keys": ["C Major", "G Major", "F Major", "A Minor"]
}
Ka tahuri te oro i waenganui i ngā hanga.
| file file | Ko te faila oro e tahuri ana |
| format string | Hanganga ūnga: mp3, wav, flac, ogg, m4a, aac |
| bitrate integer | Ko te bitrate huaputa i roto i ngā kbps: 64, 128, 192, 256, 320 |
| sample_rate integer | Te mokatere tauira: 22050, 44100, 48000 |
| channels string | mono rānei stereo |
Pāpāho reo
Ka tukuna te oro, te kupu rānei me te whiwhi whakautu AI me te kōrero i whakakotahitia.
Ka tono te tinana (multipart/form-data rānei JSON)
| Parameter | Kāhua | E hiahiatia ana | Whakamāramatanga |
|---|---|---|---|
| audio | file | Kāore* | Ka hiahiatia te tāuru oro (oro, tuhi rānei) |
| text | string | Kāore* | Ka hiahiatia te tāuru kupu (audio, text rānei) |
| voice | string | Kāore | Whakapānga mō te urupare AI. Papatono: af_bella |
| tts_model | string | Kāore | Tauira TTS mō te urupare. Papatono: kokoro |
| system_prompt | string | Kāore | Ka tono te pūnaha kāwanatanga mō te AI |
| conversation_id | string | Kāore | Ka haere tonu tētahi kōrero tīariari |
Ka urupare
{
"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
}
Tautuhi ngā tauira
Ka hoki tētahi rārangi o ngā tauira katoa e wātea ana me ō rātou kaha.
Ka urupare
{
"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
}
]
}
Ko nga oro o te rārangi
Ka whakahokia tētahi rārangi o ngā reo katoa e wātea ana, e tātaritia ana e te tauira, e te reo rānei.
Pānga uiui
| Parameter | Kāhua | Whakamāramatanga |
|---|---|---|
| model | string | Tōrō e te tauira ID (hei tauira, kokoro) |
| language | string | Tōrō e te waehere reo (hei tauira, en) |
| gender | string | Tōrō e te ira tangata: tāne, whanaunga, kore
|
Ka urupare
{
"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
}
Ko ngā tauira waehere
Waihoki ki te kōrero
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')}")
Ka kōrerorerotia te kuputuhi
# 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"])
Ko te tāruatanga reo
# 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)
Waihoki ki te kōrero
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();
Ka kōrerorerotia te kuputuhi
// 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);
Waihoki ki te kōrero
# 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
Ka kōrerorerotia te kuputuhi
# 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"
Ko te tāruatanga reo
# 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
Whakarei ake reo
# 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
Ko ngā waehere hapa
Ka hoki ngā hapa katoa ki tētahi urupare JSON me tētahi error te āpure.
{
"error": {
"code": "insufficient_credits",
"message": "You do not have enough credits for this request.",
"credits_required": 4,
"credits_available": 2
}
}
| Kāwanatanga HTTP | Ko te waehere hapa | Whakamāramatanga |
|---|---|---|
| 400 | bad_request |
Parametera tono tē tika. Tirohia te karere hapa mō ngā taipitopito. |
| 401 | unauthorized |
Kua ngaro, kāore rānei i tika te kī API. |
| 402 | insufficient_credits |
Kāore i tino nui ngā pūtea. Kei te hoko anō i te /price/. |
| 403 | forbidden |
Kāore te āheitanga API i te wātea ki tōna mahere. |
| 404 | not_found |
Kāore i kitea te tauira, te reo rānei. |
| 413 | file_too_large |
Kua hipa te rārangi rahinga o te faila whakarewa. |
| 429 | rate_limited |
He maha rawa ngā tono. Tirohia ngā pūmatua tepe. |
| 500 | internal_error |
He hapa server. Ka ngana anō ā muri ake nei. |
| 503 | model_loading |
E kawe ana te tauira. Ka whakamātau anō i roto i ētahi waeine. |
Webhooks
Mō ngā taumahi roa (whakahaeretanga pūtake, TTS rōpū), ka taea e koe te hoatu tētahi tohuāhua webhook_url. Ina oti te taumahi, ka POST tātau i te hua ki tōtou URL.
{
"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"
}
E whakaritea ana?
Ki te whiwhi i tōkou kī API me te tīmata ki te whakauru i te TTS.ai ki roto i ōna taupānga.