Text to speech

1. List all voices

Replace YOUR_ANYCAP_KEY with your Anycap connection key. Each entry in items includes a name, language and id. Choose a voice and copy its id.

BASH
curl 'https://api.anycap.io/v1/audio/voices' \  -H 'Authorization: Bearer YOUR_ANYCAP_KEY'

2. Submit speech with the selected voice

Set input.speaker to the selected id and input.prompt to your script. The example uses Xiaohe 2.0. Use a new idempotency_key for each new job and reuse it when retrying the same request. Copy job.id from the response.

BASH
curl -X POST 'https://api.anycap.io/v1/generations' \  -H 'Authorization: Bearer YOUR_ANYCAP_KEY' \  -H 'Content-Type: application/json' \  -d '{  "type": "audio",  "model": "seed-tts-2.0",  "input": {    "prompt": "Welcome to the voice preview.",    "speaker": "zh_female_xiaohe_uranus_bigtts"  },  "idempotency_key": "tts-example-001"}'

3. Check the job and retrieve the MP3

Replace JOB_ID with job.id from the previous step. Repeat this query while generation is in progress. When state is completed, open audio_url to play or download the MP3.

BASH
curl 'https://api.anycap.io/v1/audio/generations/JOB_ID?result=true' \  -H 'Authorization: Bearer YOUR_ANYCAP_KEY'

On failure, inspect error_code for the machine-readable code and error_message for the available reason. Voice access and script limits depend on the source. Billing uses reported characters, including punctuation and spaces.