Audio Generation
Providers — two permanent paths
GhostMind offers two coexisting TTS paths. Select one per request with
provider, or omit it to use the workspace default.
| Provider | Execution | Role | Notes |
|---|---|---|---|
google_ai_studio_savio_tts | browser_session | Default — always available | The established path: browser-driven generation. wav output only; enum-style speed is a prompt-level hint. Enabled for every workspace — it is not deprecated and remains the fallback whenever the direct provider is unavailable. |
google_gemini_tts | direct_protocol | Optional fast path | Direct Gemini TTS API call — no browser (seconds vs ~1–2 min). Adds mp3/flac/pcm/ogg, real numeric speed, multi-speaker, and free-form delivery instructions. Activated per workspace by platform-side key provisioning — shows unavailable until enabled. |
The browser path is permanent. Adding google_gemini_tts does not
remove, demote, or limit google_ai_studio_savio_tts — both providers are
served by the same durable job pipeline, and requests continue working on
the browser provider regardless of direct-provider status.
Check GET /v1/audio/providers for each provider’s live status and declared
capabilities (output_formats, numeric_speed, multi_speaker,
max_input_length).
POST /v1/audio/generations
Create an async audio generation job. Returns 202 Accepted with the job ID.
curl https://ghostmind.g-ksa.com/v1/audio/generations \ -H "Authorization: Bearer gmk_live_..." \ -H "Content-Type: application/json" \ -d '{ "input": "مرحباً بالعالم، هذا اختبار للصوت السعودي الفخم.", "voice": "ناصر", "provider": "google_gemini_tts", "response_format": "mp3", "provider_options": { "dialect": "saudi", "gender": "male", "age_category": "adult", "emotion": "calm", "purpose": "narrative", "speed_factor": 1.1 } }'Parameters
| Field | Type | Required | Description |
|---|---|---|---|
input | string | Yes | Text to synthesize. API envelope allows 10,000 chars; providers currently cap at 3,000 (declared in max_input_length). |
voice | string | Yes | Voice name from GET .../voices — e.g. يوسف, ناصر, لين. Must be valid for the selected dialect/gender/age_category. |
provider | string | No | Provider id (see table above). |
model | string | No | Merged into provider_options.model — real for google_gemini_tts (see model list below). |
language | string | No | Language code hint. |
response_format | string | No | Output format (default wav). Validated against the provider’s declared output_formats — an unsupported value returns 400, never a mislabeled wav. |
provider_options | object | No | Controls below. |
Idempotency-Key | header | No | Safe retry — same key + same payload returns the existing job; same key + different payload returns 409. |
provider_options — shared controls
Accepted by both providers (identical key/value semantics):
| Key | Values |
|---|---|
dialect | egyptian, saudi, levantine, iraqi, algerian, moroccan, tunisian, khaleeji, sudanese, yemeni, lebanese, msa |
age_category | adult, elderly, cartoon |
gender | male, female |
temperature | warm, balanced, sharp |
emotion | calm, medium, strong, intense |
speed | slow, medium, fast (delivery-style hint) — or a number 0.25–4.0 (real time-stretch, direct provider only) |
pitch_depth | light, medium, deep |
register | high, medium, low |
dramatic_impact | light, medium, strong |
purpose | advertisement, narrative, awareness, news, educational |
provider_options — google_gemini_tts only
| Key | Type | Description |
|---|---|---|
model | string | gemini-2.5-flash-preview-tts (default), gemini-2.5-pro-preview-tts, gemini-3.1-flash-tts-preview, gemini-2.5-flash-lite-preview-tts |
speed_factor | number | Real post-generation time-stretch, 0.25–4.0. Conflicts with a numeric speed or top-level speed → 400 (never silently chosen). |
instructions | string | Free-form delivery instructions (≤500 chars, sanitized into the prompt envelope). |
enhance | boolean | Rewrite the input into the selected dialect before synthesis. Best-effort — falls back to the original text on any failure. |
speakers | array | Multi-speaker dialogue, max 2 items: [{"voice": "ناصر", "text": "..."}, ...]. Combined text ≤3,000 chars. |
Response (202)
{ "id": "job-uuid", "status": "queued", "provider": "google_gemini_tts", "voice": "ناصر"}POST /v1/audio/speech
Synchronous generation — polls the job and returns audio when ready (or the
job id on timeout). Accepts an OpenAI-style numeric speed (0.25–4.0) at
top level; it is wired to provider_options.speed_factor and applied as a
real time-stretch by google_gemini_tts. Supplying both top-level speed
and provider_options.speed_factor returns 400.
GET /v1/audio/generations/{id}
Get job status.
{ "id": "job-uuid", "status": "completed", "provider": "google_gemini_tts", "voice": "ناصر", "output_mime_type": "audio/mpeg", "output_size_bytes": 102400, "duration_ms": 2500, "content_url": "/v1/audio/generations/job-uuid/content"}output_mime_type and duration_ms reflect the actual stored output —
when speed_factor was applied, the duration differs from the unstretched
rendering.
Job Statuses
| Status | Description |
|---|---|
created | Job created |
validated | Request validated (dialect/voice/options/format) |
queued | Job queued for processing |
assigned/processing | Worker picked it up; audio is being generated |
completed | Audio is ready for download |
failed | Generation failed — error_code/error_message explain why |
cancelled | Job was cancelled |
GET /v1/audio/generations/{id}/content
Download the generated audio. Supports Range requests and returns the
real Content-Type/Content-Disposition for the produced format.
curl https://ghostmind.g-ksa.com/v1/audio/generations/{id}/content \ -H "Authorization: Bearer gmk_live_..." \ -o audio.mp3POST /v1/audio/generations/{id}/cancel
Cancel a queued or processing job.
POST /v1/audio/generations/{id}/retry
Retry a failed job. Creates a new job with the same parameters.
The original input text is retained on failure (bounded to the job’s
expiry) so retries can execute. If the text has already expired, retry
returns 410 input_text_expired — submit a new generation instead.
When a job fails with provider_rate_limited, its error_metadata may
include retry_after_seconds — the upstream backoff hint (Google’s
Retry-After/retryDelay) when one is provided.
GET /v1/audio/generations
List jobs in the workspace. Supports status, limit, and offset query parameters.
GET /v1/audio/providers
List available TTS providers with provider_family, execution_mode, and
declared capabilities (output_formats, numeric_speed,
multi_speaker, max_input_length, max_speakers).
GET /v1/audio/providers/{provider}/voices
List voices. Filter with ?dialect=<dialect> — select the dialect first;
a voice valid under saudi will fail validation under the default
egyptian. google_gemini_tts voices also carry category,
category_key, and base_voice catalog fields.
Next Steps
- Voice Catalog — All 219 voices by dialect (generated)
- Speech Generation Guide — User guide
- Async Audio Jobs — Developer guide
- Google Savio — Browser provider details