Openai audio

From calesthio/generative-media-skills · View interactive version

Openai audio is an AI agent skill from the GitHub repository calesthio/generative-media-skills. Produce and understand audio with OpenAI request-based audio APIs and audio-capable chat models, including text-to-speech, transcription, translation, multimodal audio input/output, model routing, prompt and performance direction, artifact custody, approval gates, and safety/rights review. Use for n

How to use this skill

Skill file

OpenAI audio

Use this skill when a user wants OpenAI audio production or understanding in a bounded request: generated narration, spoken product demos, podcast or interview transcription, subtitle timing, translation to English, audio QA, or adding audio input/output to an existing chat workflow.

Do not use this as the primary guide for continuous low-latency speech-to-speech agents, live interpreting, SIP/WebRTC sessions, or voice activity detection. Those belong to the separate realtime voice skill. This skill may still explain the boundary: request-based audio APIs fit files, scripts, and bounded requests; realtime sessions fit open connections with live audio events. Documented source: OpenAI’s audio guide distinguishes request-based APIs, realtime sessions, and multimodal chat completions; verified 2026-07-10: https://developers.openai.com/api/docs/guides/audio

Source status and evidence labels

Treat the following as documented facts verified on 2026-07-10 from OpenAI public docs:

Treat the following as production heuristics, not OpenAI guarantees:

Route the job before making an API call

Ask or infer these variables before choosing an endpoint:

  1. Input: text script, audio file, live microphone stream, or a mixed chat turn with audio.
  2. Output: audio file, transcript, translated English transcript, captions, diarized transcript, chat response with audio, or live audio events.
  3. Time shape: bounded request versus continuous session.
  4. Approval risk: celebrity/employee/customer voice, regulated transcript, public-facing ad, legal/medical/financial content, minors, or sensitive personal data.
  5. Artifact custody: where raw inputs, generated audio, transcripts, sidecars, and approvals must be stored.

Decision table:

| User intent | Primary route | Model/API choice | Notes |

|---|---|---|---|

| Generate narration or a spoken line from text | /v1/audio/speech | Usually gpt-4o-mini-tts | Best fit for file output, batch narration, style-directed voice performance. |

| Generate low-latency speech in an older simple TTS integration | /v1/audio/speech | tts-1 | Accept lower quality; do not send instructions. |

| Generate speech when an older high-quality TTS path is required | /v1/audio/speech | tts-1-hd | Test against gpt-4o-mini-tts; do not assume “HD” beats a newer model for every brief. |

| Transcribe a file or bounded upload | /v1/audio/transcriptions | gpt-4o-transcribe or gpt-4o-mini-transcribe | Use model selection by accuracy/cost; request only supported response formats. |

| Transcribe with speaker labels | /v1/audio/transcriptions | gpt-4o-transcribe-diarize | Use diarized_json when speaker annotations are required. |

| Create word/segment timestamps for captions | /v1/audio/transcriptions | Often whisper-1 with verbose_json and timestamp granularities | Docs say timestamp granularities require verbose_json; word timestamps add latency. |

| Translate non-English audio to English | /v1/audio/translations | whisper-1 | The translation endpoint is not general localization dubbing; it produces English text. |

| Add audio input/output to an existing chat app | Chat Completions | gpt-audio-1.5 with modalities and audio | Use when the model must reason over audio and respond in text/audio in one chat turn. |

| Build live speech-to-speech, live translation, live transcription, SIP, WebRTC, or VAD | Realtime API | Route out of this skill | Use the separate realtime voice skill. |

Never silently substitute a route. If the approved path is blocked, say what failed, whether it is model access, parameter incompatibility, policy, privacy, cost, or product mismatch, and ask before switching endpoint or model.

Text-to-speech production

Script preparation

Write for spoken performance before prompting. A TTS model can render pacing and tone, but it cannot rescue a script that is visually written, over-punctuated, or full of unexpanded abbreviations.

Production heuristics:

Example performance brief shape:

Voice: coral
Model: gpt-4o-mini-tts
Format: wav for editing; mp3 only for review copies
Performance instructions:
Warm, confident startup launch voice. Conversational, not announcer-like.
Medium pace, lightly excited on the first sentence, then grounded.
Pronounce "Aster Lane" as "ASS-ter lane"; pronounce "SOC 2" as "sock two".
Do not impersonate any real person or named celebrity.

Documented controls:

Voice selection

Do not describe voices only by demographic labels. Describe the performance role the production needs:

Select 2 or 3 candidate voices, generate short auditions from the same representative line, and get approval before full-run generation. Use the exact final script or a dense excerpt, not a generic demo sentence, because pronunciation and pacing failures often appear only in the real copy.

Approval gate for public-facing voice:

  1. Confirm the user has rights to the script and any referenced brand/character.
  2. Confirm the selected built-in or custom voice is permitted for the intended use.
  3. Confirm no request asks for confusing impersonation of a real person without consent.
  4. Generate an audition no longer than needed to judge tone.
  5. Store the selected voice, model, instructions, script version hash or filename, approver, date, and approved audition path.
  6. Only then generate the full batch.

For a custom voice, also confirm organization eligibility, retain the provider consent-recording ID, verify that the actor in the consent and sample recordings is the same person, and follow the Text-to-Speech Supplemental Agreement. A general email approval is not a substitute for OpenAI's required consent-recording workflow.

Output formats and custody

Use format by lifecycle:

Record every generated audio artifact with:

Do not overwrite approved masters. If you regenerate a line, create a new versioned file and update the manifest.

Complete example: narrated product launch line

User intent: create one public-facing launch voiceover line, with approval before batch generation.

Model and endpoint: /v1/audio/speech, gpt-4o-mini-tts, voice marin, WAV master.

This call is the audition/sample, not authorization for a full batch. Run it only after the rights, disclosure, storage, and sample-cost preflight above; require recorded approval of this take before expanding the run.

Python example:

from pathlib import Path
from openai import OpenAI

client = OpenAI()

script = (
    "Aster Lane turns every customer call into a searchable product signal, "
    "so your team can fix what matters first."
)

instructions = (
    "Speak as a warm, credible product-launch narrator. "
    "Confident but not hypey. Medium pace. "
    "Pronounce Aster as ASS-ter. "
    "Do not imitate any real person."
)

out = Path("artifacts/audio/aster-lane-launch-v001.wav")
out.parent.mkdir(parents=True, exist_ok=True)

with client.audio.speech.with_streaming_response.create(
    model="gpt-4o-mini-tts",
    voice="marin",
    input=script,
    instructions=instructions,
    response_format="wav",
    speed=1.0,
) as response:
    response.stream_to_file(out)

Why it is structured this way:

Review criteria:

Speech-to-text production

Choose the transcription model by downstream use

Documented facts:

Production heuristics:

Transcription prompts

Use prompt to guide style, spelling, jargon, or continuation from previous segments. The prompt should match the audio language for transcription. Do not use the prompt to invent content or “fix” unclear audio; mark inaudible spans in post-review when necessary.

Good prompt contents:

Example:

This is an English product interview about Aster Lane, SOC 2, Snowflake, Zendesk, and call summarization. Preserve product names. Use "Aster Lane" not "Asterlane". Use "SOC 2" not "sock two" in the transcript.

Complete example: diarized meeting transcript

User intent: transcribe a 35-minute customer interview and preserve speaker turns for a researcher.

Model and endpoint: /v1/audio/transcriptions, gpt-4o-transcribe-diarize, diarized_json.

Python example:

from pathlib import Path
from openai import OpenAI

client = OpenAI()

audio_path = Path("raw/customer-interview-2026-07-10.m4a")  # Prevalidated at <25 MB.

with audio_path.open("rb") as audio_file:
    transcript = client.audio.transcriptions.create(
        model="gpt-4o-transcribe-diarize",
        file=audio_file,
        response_format="diarized_json",
        chunking_strategy="auto",
    )

Path("artifacts/transcripts/customer-interview-diarized-v001.json").write_text(
    transcript.model_dump_json(indent=2),
    encoding="utf-8",
)

Expected result:

Likely failure modes:

Repair:

Complete example: caption timing with word timestamps

User intent: create caption timing for a short tutorial clip where word-level karaoke highlighting is required.

Model and endpoint: /v1/audio/transcriptions, whisper-1, verbose_json, timestamp_granularities=["word"].

Python example:

from pathlib import Path
from openai import OpenAI

client = OpenAI()

with open("exports/tutorial-voice.wav", "rb") as audio_file:
    transcription = client.audio.transcriptions.create(
        model="whisper-1",
        file=audio_file,
        response_format="verbose_json",
        timestamp_granularities=["word"],
        prompt=(
            "Tutorial narration about Aster Lane, SOC 2, and Zendesk. "
            "Use product capitalization exactly."
        ),
    )

Path("artifacts/captions/tutorial-word-timestamps-v001.json").write_text(
    transcription.model_dump_json(indent=2),
    encoding="utf-8",
)

Why this route:

Translation to English

The audio translations endpoint translates audio into English text. Do not present it as multilingual dubbing, voice conversion, or localized audio production.

Use it when:

Do not use it when:

Complete example:

from pathlib import Path
from openai import OpenAI

client = OpenAI()

with open("raw/founder-clip-es.m4a", "rb") as audio_file:
    translation = client.audio.translations.create(
        model="whisper-1",
        file=audio_file,
        response_format="text",
        prompt=(
            "The speaker discusses Aster Lane, customer support analytics, "
            "and SOC 2. Translate to clear English while preserving product names."
        ),
    )

Path("artifacts/transcripts/founder-clip-english-v001.txt").write_text(
    translation,
    encoding="utf-8",
)

Approval rule: if the translation will be published, require bilingual review or explicit user acceptance that the machine translation may miss nuance.

Audio-capable chat completions

Use Chat Completions with an audio-capable model when audio is part of a conversational model turn, not merely a file conversion job. Documented pattern: use gpt-audio-1.5, set modalities to include audio, provide audio output parameters, and include audio inputs as base64 input_audio content blocks. Source: https://developers.openai.com/api/docs/guides/audio

Use this route for:

Do not use this route for:

Complete example:

import base64
from pathlib import Path
from openai import OpenAI

client = OpenAI()

audio_bytes = Path("raw/user-question.wav").read_bytes()
encoded_audio = base64.b64encode(audio_bytes).decode("utf-8")

completion = client.chat.completions.create(
    model="gpt-audio-1.5",
    modalities=["text", "audio"],
    audio={"voice": "alloy", "format": "wav"},
    messages=[
        {
            "role": "system",
            "content": (
                "Answer as a concise support coach. If the recording is unclear, "
                "say what you could not determine rather than guessing."
            ),
        },
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "What is the customer asking for?"},
                {
                    "type": "input_audio",
                    "input_audio": {
                        "data": encoded_audio,
                        "format": "wav",
                    },
                },
            ],
        },
    ],
)

message = completion.choices[0].message
Path("artifacts/chat-audio/answer-transcript-v001.txt").write_text(
    message.audio.transcript,
    encoding="utf-8",
)
Path("artifacts/chat-audio/answer-v001.wav").write_bytes(
    base64.b64decode(message.audio.data)
)

Custody note: chat audio responses include base64 audio bytes and a transcript. Store both if the output is an approved production artifact. If privacy policy requires no server-side persistence, verify store behavior and the organization’s data controls before use.

Latency, cost, and batching

Documented cost facts are volatile; always re-check pricing on the day of production. On 2026-07-10, OpenAI’s pricing page lists:

Production heuristics:

Rights, consent, privacy, and safety

Hard requirements:

Data-control facts verified 2026-07-10:

Approval and artifact custody protocol

Use this protocol for any production asset, public-facing content, customer content, regulated transcript, or paid batch job.

Before generation or transcription:

  1. Name the endpoint, model, output format, and reason for the route.
  2. Confirm rights/consent for voices, recordings, scripts, brands, and music beds.
  3. Confirm privacy classification and storage location.
  4. Confirm cost estimate source and date if cost is material.
  5. Confirm whether the first call is an audition/sample or full batch.

After a sample:

  1. Store raw output under a versioned path.
  2. Produce a short review note: model, voice, prompt/instructions, input file/script, format, reviewer, date, pass/fail.
  3. Ask for approval or revision before generating the full batch.

After a full batch:

  1. Store raw inputs, generated outputs, transcripts, sidecars, manifests, and approvals separately.
  2. Preserve original model outputs before post-processing.
  3. Write a manifest that records model, endpoint, parameters, source files, output files, checksums, and approval status.
  4. Mark derivative files clearly: edited, normalized, mixed, captioned, translated, or reviewed.
  5. Do not delete raw source or approved masters unless the user’s retention policy requires deletion and the deletion is logged.

Minimal artifact manifest shape:

{
  "artifact_id": "narration_sc01_v003",
  "created_at": "2026-07-10T18:30:00Z",
  "provider": "openai",
  "endpoint": "/v1/audio/speech",
  "model": "gpt-4o-mini-tts",
  "voice": "marin",
  "input_script": "scripts/narration/sc01_v004.txt",
  "instructions": "Warm, credible, medium pace; pronounce Aster as ASS-ter.",
  "parameters": {
    "response_format": "wav",
    "speed": 1.0
  },
  "outputs": [
    {
      "path": "artifacts/audio/sc01_v003.wav",
      "role": "raw_model_master",
      "sha256": "..."
    }
  ],
  "approval": {
    "status": "approved",
    "approver": "user",
    "approved_at": "2026-07-10T18:45:00Z"
  },
  "source_verification": {
    "docs_checked_at": "2026-07-10",
    "pricing_checked_at": "2026-07-10"
  }
}

Quality review

For generated speech, review:

For transcripts, review:

For translated transcripts, review:

Common failure modes and repairs

| Failure | Likely cause | Repair |

|---|---|---|

| TTS mispronounces a product name | Name not phonetically constrained | Add pronunciation in instructions and/or script; regenerate only affected lines. |

| TTS sounds like an ad read | Direction too broad: “excited”, “professional” | Specify audience, emotional arc, pace, and what to avoid. |

| TTS chunks do not match | Direction changed between chunks or script boundaries were unnatural | Lock one instruction block and chunk at scene/paragraph boundaries. |

| Output format wrong for edit | Delivery format chosen too early | Generate WAV/FLAC master; transcode copies downstream. |

| Transcript misses proper nouns | No vocabulary prompt or poor audio | Add vocabulary prompt; retry clean segments; manually QA final. |

| Timestamps unavailable | Wrong model/response format | Use documented timestamp route: whisper-1, verbose_json, requested granularities. |

| Streaming request ignored | whisper-1 used | Use a GPT transcription model for streaming, or accept non-streaming Whisper behavior. |

| Translation requested to non-English target | Endpoint mismatch | Use translation endpoint only for English text, or route to a localization/dubbing workflow outside this skill. |

| Speaker labels treated as identity | Misuse of diarization | Human-review speaker mapping; never use diarization as biometric ID. |

| Privacy blocker | Sensitive source audio or unclear consent | Pause, confirm lawful basis, storage, retention, and disclosure requirements. |

Final response pattern for production work

When handing off results, include:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.