Docs

Text-to-Speech

A voice of the catalogue reads your text aloud, under your API key: from Python, sequence_ai.speech(), and from a shell, seq speech (Text-to-Speech in the Python client). The answer is the audio, with the characters or tokens it read and what the call cost. In the examples, everything ending in _user is yours, and so are the strings.

Have it read your text

speak.pypython
# everything ending in _user is yours
import sequence_ai

r_user = sequence_ai.speech("aura-2", "The cup is in the left bin.", voice="aura-2-thalia-en")
r_user.save("spoken_user.mp3")
# the characters read, and what the call cost
print(r_user.characters, r_user.cost_usd)
the same, from a shellshell
seq speech "The cup is in the left bin." --model aura-2 --voice aura-2-thalia-en -o spoken_user.mp3
# saves the audio, then says the characters it read and what it cost

The model is a voice’s id, or the name after its last slash as here. The text is up to 5,000 characters, so a longer text is several calls. voice (--voice), format (--format: mp3, wav, or pcm, raw 16-bit mono samples; left out, the model’s first, or in a shell the ending of the file it saves to), speed (--speed) and instructions (--instructions) are each the model’s to take or not: one it does not take is refused before anything is billed, its name in the error. Every field and answer is in the API reference.

Pick a voice

sequence_ai.models(endpoint="speech") lists the voices, with no key, and seq models --endpoint speech prints them. Each says what it takes, in its raw: voices, the voice ids it speaks in (None where it takes any voice id), formats, the first its default, speed, its range or None, and instructions, whether it reads how to say the text. The Model library lists them too, with their prices.

the voices and what each takespython
import sequence_ai

for m_user in sequence_ai.models(endpoint="speech"):
    # its name, its formats (the default first) and its first voices
    print(m_user.short_id, m_user.raw["formats"], (m_user.raw["voices"] or ["any voice id"])[:3])
the same, from a shellshell
seq models --endpoint speech

What it costs

  • Per character. Most voices are priced per million characters of the text they read: characters says how many were read, cost_usd what the call was charged.
  • Per UTF-8 byte. Fish Audio’s voices (drama-3, s2-pro, s2-1-pro) are priced per million UTF-8 bytes of the text they read, as Fish Audio prices them: a Latin letter is one byte, a Chinese character three, an emoji four; cost_usd says what the call was charged.
  • Per token. Gemini’s voices are priced per million tokens in and out, as their maker prices them: the text’s, one for every six characters, and the audio’s, 25 for every second of speech, each rounded up. The answer says them in input_tokens and output_tokens.
  • Only what was read. A call refused or failed is not charged. Each call is on your usage and invoice under its voice’s name.