Audio
Text to speech in built-in, cloned and designed voices, and speech to text with word timestamps.
Access: Keys with the media:read or media:generate scope, on an account with media access granted by Albastar Corp.
The audio routes cover text to speech with POST /v1/audio/speech, in a model's built-in voice or
in a saved voice, and speech to text with POST /v1/audio/transcriptions. Both routes take OpenAI's request shape,
so OpenAI SDKs work with the base URL changed.
Quick example
The example downloads the reference clip of Narrator A, a synthetic voice, and transcribes the clip with parakeet.
curl
curl -o reference.mp3 \
https://api.albastov.com/v1/media/samples/reference-848c3d555461736a.mp3
curl https://api.albastov.com/v1/audio/transcriptions \
-H "Authorization: Bearer $ALBASTAR_API_KEY" \
-F model=parakeet \
-F [email protected]Python
import os
import httpx
from openai import OpenAI
CLIP = (
"https://api.albastov.com/v1/media/samples/"
"reference-848c3d555461736a.mp3"
)
client = OpenAI(
base_url="https://api.albastov.com/v1",
api_key=os.environ["ALBASTAR_API_KEY"],
)
clip = httpx.get(CLIP)
clip.raise_for_status()
transcript = client.audio.transcriptions.create(
model="parakeet",
file=("reference.mp3", clip.content),
)
print(transcript.text)JavaScript
const base = "https://api.albastov.com/v1";
const clip = await fetch(
`${base}/media/samples/reference-848c3d555461736a.mp3`,
);
if (!clip.ok) throw new Error(`${clip.status} ${await clip.text()}`);
const form = new FormData();
form.append("model", "parakeet");
form.append("file", await clip.blob(), "reference.mp3");
const res = await fetch(`${base}/audio/transcriptions`, {
method: "POST",
headers: { Authorization: `Bearer ${process.env.ALBASTAR_API_KEY}` },
body: form,
});
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
console.log((await res.json()).text);The response is the transcript Parakeet returned for the clip:
{
"text": "Okay, so here's the plan. We land just after sunset, …"
}The text value above is shortened. The whole transcript, wrapped at 76 characters:
Okay, so here's the plan. We land just after sunset, grab the bags, and head
straight for the harbor. If the ferry's late again, and honestly, it usually
is, we'll get dinner by the water and wait it out. Sound good.What you can build
Text to speech
Speech from text in a built-in voice or a saved voice, as MP3, WAV or Opus.
Voices
Saved voices: cloned from a clip, designed from a description, listed, copied and deleted.
Voice cloning
The reference clip, the speaker's consent, and how much of the clip each cloning model uses.
Voice models
Every text-to-speech model, with a sample of each.
Speech to text
Transcripts of audio files, with word and segment timestamps.
Transcription models
The speech-to-text model, with a transcript of the reference clip.
Key concepts
- Built-in voice
- A voice that belongs to one model, named by its id:
af_heartonkokoro.GET /v1/media/voices?model=kokorolists a model's built-in voices. - Saved voice
- A reference clip of one voice with an id
vo_…. A cloning model speaks any text in a saved voice; withoutmodel, the request runs on the voice'sdefault_model. - Reference voice
- Narrator A,
vo_tBeDCRb2byGFjB6HGyQq6a, a synthetic voice (Kokoro's built-inaf_heart) that every key withmedia:generatemay use. The docs examples clone it. - Scopes
media:generateopens speech, transcriptions, media jobs, uploads and voice writes.media:readopens the model list, job reads and voice reads;media:generatedoes not includemedia:read.- Media job
- Every speech and transcription request runs as a media job. A job not done in time returns
503withcodequeuedandjob_id;GET /v1/media/jobs/{job_id}?wait=30returns the result oncestateisdone.
Next steps
Speech reference
Every parameter, header and error of POST /v1/audio/speech.
Transcriptions reference
Every parameter, response format and error of POST /v1/audio/transcriptions.
Voices reference
The voice object and every voice route.
Media jobs reference
The job object, ?wait, queue timeouts and the model list.