EN ▾
Uncensored Text API for TTS PipelinesGet API key

AI Text to Speech Characters: Scripts With Distinct Voices

Updated

If you want several characters to sound different in audio, the work starts in the script, before any voice is synthesized. This guide shows how to generate speaker-tagged dialogue with the API and pass it to the TTS engine of your choice.

Three colored speech bubbles linked to waveform blocks above a data terminal, representing multi-character scripts
Key points
  • The API writes text only; you pair each speaker label with a voice in your own TTS tool.
  • A character sheet in the system prompt keeps each voice consistent across chapters.
  • JSON mode returns one object per line, which is easy to loop over in a TTS pipeline.
  • Fiction for lawful adult use is fine; sexual content involving minors is never allowed.

No card needed. After sign-up, claim $0.50 of free test credit with one click (once per person).

Get API key

How ai text to speech characters actually work

Most people searching for ai text to speech characters want one of two things: a voice that sounds like a specific character, or a long story where several characters speak and each one is recognizable. The first is a job for a speech model with voice cloning or a preset voice library. The second starts earlier, with the script itself.

This site does not generate audio. It gives you an OpenAI-compatible text API with one open-weight model, uncensored, that writes dialogue without content refusals for lawful adult use. You use it to produce the lines, the speaker labels and the delivery notes. Then a TTS engine such as the open-source F5-TTS, or any other tool that accepts text plus a reference voice, turns each line into sound.

Splitting the work this way has a practical benefit. Distinct voices in audio come mostly from distinct writing: sentence length, vocabulary, verbal habits, how a character interrupts or trails off. A flat script read by ten different voices still sounds flat. A sharp script read by two voices already feels like a cast.

Start with a character sheet

Before you ask for a single line of dialogue, write a short sheet for each character. Keep it under 80 words. The model reads it as part of the system prompt on every request, so it acts as the memory the model does not otherwise have.

FieldExampleWhy it matters
Speaker IDMARAStable label you map to a voice file
Speech patternShort clipped sentences, dry humorGives the TTS something to pace
VocabularyDock slang, never uses contractions with strangersMakes the text recognizable without audio
HabitsAnswers questions with a questionCreates rhythm contrast between speakers
Delivery defaultLow, calm, slow when angryFeeds your style or speed settings

Two characters who both talk in medium-length polite sentences will blur together, whatever voices you assign. Deliberately give one of them long run-on speech and the other clipped fragments. That difference survives text-to-speech better than any accent.

A script format your TTS pipeline can loop over

Free-form prose with quotation marks is hard to split reliably. Ask for structure instead. JSON mode (response_format set to json_object) returns a single JSON object, so wrap the lines in a key such as lines.

{
  "lines": [
    {"speaker": "NARRATOR", "text": "The ferry horn sounded twice.", "delivery": "neutral, slow"},
    {"speaker": "MARA", "text": "You're late. Again.", "delivery": "flat, dry"},
    {"speaker": "COLE", "text": "The tide was late. I just followed it.", "delivery": "amused, quick"}
  ]
}

Each object maps cleanly to one TTS call: look up the voice file for speaker, synthesize text, apply delivery as speed or style if your engine supports it, and concatenate the clips in order. If your engine ignores delivery hints, drop the field from the prompt to save tokens.

Generate the dialogue with Python

The code below uses the standard openai package. Only the base URL and key differ from a normal OpenAI setup. Replace YOUR_KEY with a key from the API key page.

import json
from openai import OpenAI

client = OpenAI(base_url="https://api.f5tts.top/v1", api_key="YOUR_KEY")

CAST = (
    "MARA: short clipped sentences, dry humor, answers questions with questions.\n"
    "COLE: talkative, long winding sentences, laughs at his own jokes.\n"
    "NARRATOR: calm, plain, past tense."
)

scene = "Mara waits at the dock for Cole, who is an hour late with the cargo."

resp = client.chat.completions.create(
    model="uncensored",
    temperature=0.9,
    response_format={"type": "json_object"},
    messages=[
        {"role": "system", "content": (
            "You write audio drama scripts. Return JSON: "
            '{"lines":[{"speaker":"","text":"","delivery":""}]}. '
            "Use only these speakers. One speaker per line. "
            "No stage directions inside text.\n\n" + CAST)},
        {"role": "user", "content": scene + " Write about 20 lines."},
    ],
)

script = json.loads(resp.choices[0].message.content)
for line in script["lines"]:
    print(line["speaker"], "|", line["text"])

A request like this uses roughly 150 prompt tokens and 600 output tokens, which costs a fraction of a cent. The pricing page has the per-token rates if you want to plan a longer project.

Keep voices consistent across chapters

The model does not remember earlier requests. Consistency across a 20-chapter audiobook comes from what you send each time.

  • Repeat the character sheet in the system prompt on every call. It is cheap compared with the cost of drift.
  • Send a running summary of the story so far, 200 to 400 words, plus the last 10 lines of the previous scene so the new scene picks up the tone.
  • Lower the temperature to around 0.7 for scenes where voices must stay tight, and raise it for brainstorming new banter.
  • Pass a seed when you want to reproduce a result while testing prompt changes. Seed is passed through to the model.
  • Add a short "voice test" check: a second call that asks the model to flag lines that sound like the wrong character, then regenerate only those.

The 100,000-token context window is large enough to hold a full outline, all character sheets and several previous scenes at once, so you rarely need to compress aggressively. Count tokens roughly as 1.3 per English word.

Mapping speakers to voices and fixing pitfalls

On the audio side, assign each speaker ID to a reference clip or preset voice and keep that table in one config file. Changing a voice later then means editing one line, not re-prompting the script.

Problems you will hit

  • Numbers and abbreviations. TTS engines read "St." and "3rd" inconsistently. Add a rule to the prompt: write numbers as words, expand abbreviations.
  • Stage directions in the text field. Phrases such as "she sighs" get spoken aloud. Keep actions in the delivery field or ban them in the system prompt.
  • Very long lines. Many TTS engines degrade on long inputs. Ask for lines under 40 words and split anything longer at sentence ends.
  • Two speakers in one line. The JSON schema above prevents it; free prose does not.
  • Invalid JSON. Rare in JSON mode, but wrap json.loads in a retry, since failed requests are not charged.

The docs page covers streaming, stop sequences and limits if you build this into a larger pipeline.

Three ways to use it: games, audiobooks, companions

Game dialogue

Ask for many short variations of one situation, such as a guard warning the player, and get them as a JSON array. Short lines synthesize quickly and suit engines that struggle with long inputs. Give each NPC a one-line voice rule, and request 10 variants per call so you can pick the best three.

Audiobooks

Work chapter by chapter. Feed the outline, the character sheets and a summary, then request narration and dialogue as separate speakers. Narration and dialogue usually want different voices and different pacing, so keeping them as separate speaker IDs saves editing later.

Companion and roleplay apps

If you build a chat app for adults where a character talks back, the loop is: user message, model reply, TTS on the reply. Stream the text, cut at sentence boundaries, and send each sentence to TTS as it completes so audio starts early. A quick test with curl shows the shape of the request:

curl https://api.f5tts.top/v1/chat/completions \
  -H "Authorization: Bearer YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"uncensored","stream":true,
       "messages":[{"role":"system","content":"You are Mara, a dry-witted dock worker. Reply in two sentences."},
                   {"role":"user","content":"Where have you been?"}]}'

Remember that a streamed request holds one of your concurrent slots until the stream ends. A full key allows 8 at once, so a companion app with many simultaneous users needs a queue.

What is and is not allowed

The model is tuned to write fiction without content refusals for lawful adult use, so dark themes, violence and mature drama in a story do not trigger a canned apology. That is the main reason to use it for characters instead of a filtered assistant.

One hard limit applies: no sexual content involving minors, in any framing. Requests that cross it are refused. Also note that a voice you clone from a real person's recording is a separate legal question that belongs to your TTS tool and your jurisdiction; get consent before cloning anyone.

Questions and answers

Does this API turn text into audio?

No. It is a text-only API. It writes the script, and you pass the lines to a separate text-to-speech engine for audio.

How many characters can I use in one script?

There is no fixed cap. In practice 3 to 6 named speakers per request keeps the character sheets short enough to follow reliably, and the 100,000-token window leaves plenty of room.

Can I stream the script as it is written?

Yes. Set stream to true and read the SSE chunks. With JSON mode it is simpler to wait for the full object, but plain-text line formats stream well.

How much does a full audiobook script cost?

Output is $0.50 per 1M tokens. A 60,000-word script is about 78,000 output tokens, so roughly $0.04 for the writing, plus prompt tokens at $0.15 per 1M.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.

Get API key