EN ▾

Voice to Voice LLM: Where a Text API Fits in the Chain

A voice to voice LLM setup is a chain: speech becomes text, a language model writes the reply, and a speech engine reads it aloud. This API is the middle link, a text-only model you call over an OpenAI-compatible endpoint.

Updated

Sound wave flowing into a glowing cube and out as a new sound wave, showing a voice to voice LLM pipeline

Key points

  1. Voice to voice usually means three stages: speech to text, the LLM, then text to speech
  2. This API handles only the text stage; it does not transcribe or synthesise audio
  3. Stream tokens and hand finished sentences to your speech engine to cut the wait
  4. One voice turn of 800 input and 150 output tokens costs about $0.000195

What voice to voice means in practice

People use the phrase voice to voice LLM for two different things. The first is a single model that takes audio in and gives audio out. The second, far more common in real projects, is a pipeline of three parts that you wire together yourself. This article is about the second kind, because that is where a hosted text model slots in.

The three stages look like this:

  1. Speech to text. A transcription engine turns the speaker's audio into a string.
  2. The language model. It reads the text, plus any history and instructions, and writes the reply.
  3. Text to speech. A synthesis engine turns the reply into audio, possibly in a cloned voice.

This API covers stage two only. It accepts text and returns text through POST /v1/chat/completions. It does not transcribe audio, does not synthesise speech and does not clone voices. You bring the other two stages from whichever tools you prefer, and this site's job is to be the thinking part in the middle.

Why use a separate text model in the middle

An all-in-one audio model is convenient, but splitting the chain gives you control over each part. You can swap the voice without touching the logic, test the reply text in a plain terminal before any audio is involved, and log every turn as readable text. Debugging a transcript is much easier than debugging a sound file.

It also lets you pick the language model for its behaviour. The model here is one open-weight model, run by an independent provider and tuned to answer without content refusals for lawful adult use. For a voice project that matters in practical ways: a character voice for fiction, a game NPC or a narration tool should stay in role instead of stopping mid-scene with a refusal. There is one hard limit that never changes: no sexual content involving minors.

Spoken replies also have special needs. They must be short, free of markdown, and easy to say aloud. A text model can be told all of that in the system prompt, which brings us to the next part.

Write replies that sound good out loud

Text written for the eye reads badly when spoken. Bullets turn into odd pauses, brackets confuse the speech engine, and long sentences run out of breath. Put the rules in the system prompt and the model will follow them most of the time.

from openai import OpenAI

client = OpenAI(
    base_url="https://api.voicecloningapi.com/v1",
    api_key="YOUR_API_KEY",
)

SYSTEM = (
    "You are the voice of a spoken assistant. Reply in plain sentences only. "
    "No lists, no markdown, no emoji, no brackets. Keep each reply under 60 words. "
    "Write numbers and symbols the way a person would say them."
)

def reply(history, heard):
    messages = [{"role": "system", "content": SYSTEM}] + history
    messages.append({"role": "user", "content": heard})
    resp = client.chat.completions.create(
        model="uncensored",
        messages=messages,
        max_tokens=150,
        temperature=0.7,
    )
    return resp.choices[0].message.content

The max_tokens cap is a safety net. If the prompt asks for 60 words, the model usually stops by itself, but a ceiling prevents a runaway paragraph from being read aloud for a minute. If you also clone voices, use only voices you have permission to use, and keep consent records with your project files.

Stream and speak sentence by sentence

The slowest feeling part of any voice loop is silence. If you wait for the whole reply before starting the speech engine, the listener hears nothing for the full generation time. The fix is streaming: set stream: true, collect tokens as they arrive, and send each finished sentence to text to speech while the model keeps writing.

import re

def speak(sentence):
    # send the sentence to your text-to-speech engine here
    print("SPEAK:", sentence)

def stream_reply(messages):
    stream = client.chat.completions.create(
        model="uncensored",
        messages=messages,
        stream=True,
        max_tokens=150,
    )
    buffer = ""
    for chunk in stream:
        if not chunk.choices:
            continue
        piece = chunk.choices[0].delta.content or ""
        buffer += piece
        while True:
            m = re.search(r"[.?]\s", buffer)
            if not m:
                break
            speak(buffer[: m.end()].strip())
            buffer = buffer[m.end():]
    if buffer.strip():
        speak(buffer.strip())

The pattern is simple: a regular expression finds the end of a sentence, and anything after it stays in the buffer. Handle abbreviations such as "Dr." in your own splitter if they appear in your content. Streaming responses end with usage data, so you can still log the token counts per turn.

One point on limits: a streamed request holds its concurrency slot until the stream finishes. A full key allows 8 concurrent requests, so a service with many live callers should cap how many streams it opens at once.

Keep the conversation within the window

The context window is 100,000 tokens, prompt plus completion. A spoken conversation almost never gets near that, since people say little per turn. Even so, the history grows with every exchange and you pay for the resent text each time, so it is worth trimming.

  • Keep the system prompt short and stable.
  • Store the last 10 to 20 turns verbatim.
  • Replace older turns with a two or three line summary that the model wrote earlier.

The large window helps in another way: you can place a whole character sheet, a script or a style guide in the prompt and not worry about fitting it. For work on existing recordings, pair this with transcripts. The Whisper post-processing guide on this site covers cleaning up transcription output before it goes to the model.

What a voice turn costs

The text stage is cheap. Prices are $0.15 per 1M input tokens and $0.50 per 1M output tokens. Say a turn sends 800 tokens (system prompt, a little history and what the user said) and receives 150 tokens back.

  • Input: 800 tokens at $0.15 per 1M = $0.00012
  • Output: 150 tokens at $0.50 per 1M = $0.000075
  • Total per turn: $0.000195

A thousand turns cost $0.195, which is under twenty cents. The $0.50 trial credit covers about 2,564 turns of that size. The speech-to-text and text-to-speech stages will be priced by their own providers, and those usually dominate the bill, so check their current pricing when you plan a budget.

The trial is one click on the API key page after sign-up, with no card, valid for 7 days. For larger projects, the pricing page lists top-ups from $20 to $500.

Common problems

The reply is too long to speak

Lower max_tokens, state a word limit in the system prompt, and add a stop sequence if your format uses one. Repeat the limit in the last user message if the model drifts.

The speech engine stumbles on symbols

Tell the model to spell out numbers, units and abbreviations. As a backup, run a small cleanup function that strips asterisks, hashes and brackets before the text reaches synthesis.

A 429 error under load

You hit a limit. A full key allows 300 requests per minute and 8 concurrent requests, and the trial key allows 60 per minute and 2 concurrent. Queue your turns, retry after the Retry-After value if one is returned, and read the docs for the error codes.

Replies forget earlier turns

The API is stateless. You must send the history you want the model to see, in the messages list, on every request.

Structured output for dubbing and narration scripts

Voice projects often need more than a single string. A narration tool might want each line with a speaker name and a pause length, so the speech engine can treat them separately. JSON mode helps here: set response_format to {"type":"json_object"} and describe the shape you want in the prompt.

import json

resp = client.chat.completions.create(
    model="uncensored",
    response_format={"type": "json_object"},
    messages=[
        {"role": "system", "content": "Return JSON with a key 'lines': a list of objects with 'speaker', 'text' and 'pause_ms'."},
        {"role": "user", "content": "Split this into spoken lines for two speakers: The ferry leaves at dawn. Will you be on it? I will."},
    ],
    max_tokens=400,
)
data = json.loads(resp.choices[0].message.content)
for line in data["lines"]:
    print(line["speaker"], line["pause_ms"], line["text"])

Always parse inside a try block in production code. A model can occasionally return malformed JSON or a differently named key, so validate the shape and retry once with the error message appended to the prompt. This keeps the text stage predictable for whatever speech engine reads it next.

Keep the schema small. Three or four keys are reliable; a deeply nested structure with many optional fields invites mistakes. If you need richer data, make two calls: the first writes the lines, the second adds timing hints for each line. Each call is cheap at these prices, and two simple steps beat one complicated step that sometimes fails.

Seed and temperature help with repeatability. Setting temperature low and passing a fixed seed makes reruns of the same script closer to each other, which is useful when you are comparing prompt versions for a long recording project and want the differences to come from your edits, not from chance.

Questions and answers

Can this API take audio in and return audio?

No. It is text only, with no audio input or output. Use a separate speech-to-text tool before it and a text-to-speech tool after it.

Does it clone voices?

No. Voice cloning is a different kind of model. This API writes the text that a cloning or synthesis tool then speaks, and you should only clone voices you have permission to use.

How do I reduce the delay in a voice loop?

Turn on streaming and send each completed sentence to your speech engine while the rest is still being generated. Keep replies short with a word limit and a max_tokens cap.

Is the model name something I need to set?

Yes. Use the model ID uncensored in the model field of every request, with the base URL https://api.voicecloningapi.com/v1.

Your key is one form away

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