تخطَّ إلى المحتوى

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.

ProviderExecutionRoleNotes
google_ai_studio_savio_ttsbrowser_sessionDefault — always availableThe 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_ttsdirect_protocolOptional fast pathDirect 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.

Terminal window
curl https://ghostmind.optdmsa.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

FieldTypeRequiredDescription
inputstringYesText to synthesize. API envelope allows 10,000 chars; providers currently cap at 3,000 (declared in max_input_length).
voicestringYesVoice name from GET .../voices — e.g. يوسف, ناصر, لين. Must be valid for the selected dialect/gender/age_category.
providerstringNoProvider id (see table above).
modelstringNoMerged into provider_options.model — real for google_gemini_tts (see model list below).
languagestringNoLanguage code hint.
response_formatstringNoOutput format (default wav). Validated against the provider’s declared output_formats — an unsupported value returns 400, never a mislabeled wav.
provider_optionsobjectNoControls below.
Idempotency-KeyheaderNoSafe 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):

KeyValues
dialectegyptian, saudi, levantine, iraqi, algerian, moroccan, tunisian, khaleeji, sudanese, yemeni, lebanese, msa
age_categoryadult, elderly, cartoon
gendermale, female
temperaturewarm, balanced, sharp
emotioncalm, medium, strong, intense
speedslow, medium, fast (delivery-style hint) — or a number 0.25–4.0 (real time-stretch, direct provider only)
pitch_depthlight, medium, deep
registerhigh, medium, low
dramatic_impactlight, medium, strong
purposeadvertisement, narrative, awareness, news, educational

provider_options — google_gemini_tts only

KeyTypeDescription
modelstringgemini-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_factornumberReal post-generation time-stretch, 0.25–4.0. Conflicts with a numeric speed or top-level speed → 400 (never silently chosen).
instructionsstringFree-form delivery instructions (≤500 chars, sanitized into the prompt envelope).
enhancebooleanRewrite the input into the selected dialect before synthesis. Best-effort — falls back to the original text on any failure.
speakersarrayMulti-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

StatusDescription
createdJob created
validatedRequest validated (dialect/voice/options/format)
queuedJob queued for processing
assigned/processingWorker picked it up; audio is being generated
completedAudio is ready for download
failedGeneration failed — error_code/error_message explain why
cancelledJob 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.

Terminal window
curl https://ghostmind.optdmsa.com/v1/audio/generations/{id}/content \
-H "Authorization: Bearer gmk_live_..." \
-o audio.mp3

POST /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