module

MJ::Arcana::TtsRates

What an OpenAI spoken line cost when OpenAI reported no usage — the same per-provider knowledge cameras.cr holds for images, for speech. Usage is the usual case, and arcana-ai prices it (VoiceService.price): from 0.5.5 every model but tts-1 and tts-1-hd answers in events whose last one reports its tokens, and from 0.6.1 tts-1's characters are counted as sent, as ElevenLabs' billed characters are read. This is the fallback for a token-billed reply that came back without usage.

OpenAI gpt-4o-mini-tts billed per TOKEN — $0.60/1M input characters plus $12.00/1M AUDIO OUTPUT tokens. Audio tokens track duration, so DURATION is the cost driver and OpenAI publishes a composite of ~$0.015/minute.

So the fallback is an estimate from measured duration, and says so.

Published prices drift. Every figure here is overridable by environment variable, and basis names the rule so a stale number is visible rather than silent.

Constants

ARGS = ["-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0"]

ffprobe is the only general answer — opus, mp3, aac and flac all need a decoder to know their length, and this service's default is opus.

It needs a SEEKABLE source, so the bytes get a short-lived temp file rather than a pipe. Two things ruled the pipe out, and the first is the one that matters:

  1. ffprobe cannot get a duration out of a piped Ogg stream at all — it reports N/A, because the length lives in the last page's granule position and it cannot seek there. mp3 pipes fine; opus, the default here, never does.
  2. Piping bytes to a subprocess worked in a standalone program and returned nil from inside the service's fiber for the same audio, where probing a path worked in both.

Careful: ffprobe - < file SUCCEEDS where a true pipe fails, because shell redirection hands over a seekable file descriptor. Testing that way proves nothing about piping.

This is a probe-only write of ~50KB, not a round-trip of the synthesis itself — the audio still comes back in memory from arcana-ai and is served from there.

USD_PER_MINUTE = {"gpt-4o-mini-tts" => 0.015}

Duration-billed models: OpenAI's own composite figure for text + audio tokens, as of 2026-10. NOT measured — unlike the camera costs, which come from Runware's includeCost. Treat as a default to be overridden, not as truth.

Class methods

duration(audio : Bytes, format : String) : Float64 | Nil
Source
duration(path : String) : Float64 | Nil
Source
openai_usd_per_minute(model : String) : Float64 | Nil
Source
price(provider : String, model : String, seconds : Float64 | Nil) : Tuple(Float64 | Nil, Bool, String)

Returns {usd, exact?, basis}. usd nil means genuinely unknown — never a guess dressed as a figure.

Source
undated(model : String) : String

A dated snapshot (gpt-4o-mini-tts-2025-12-15) is billed at its model's rates.

Source