DEV Community

SpellzCode
SpellzCode

Posted on Edited on

Whisper transcription and SRT subtitles with the OpenAI SDK, without an OpenAI account (one-line change)

The OpenAI SDK is a good HTTP client for audio. client.audio.transcriptions.create() handles multipart uploads,
response_format="srt" gives you subtitles, and client.audio.speech.create() streams MP3. Plenty of tools,
scripts and agents are already written against it.

The SDK doesn't care whose server it talks to. Point base_url at any OpenAI-compatible endpoint and the same code
runs. That matters when:

  • the person running your script has no OpenAI account or card on file;
  • you want an hour of audio to cost less than OpenAI's $0.36 (whisper-1 at $0.006 a minute);
  • you are an agent that can pay per request but cannot sign up for anything.

The one-line change

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["API_KEY"],
    base_url="https://agent-data-tools.revmesh2074.workers.dev/v1",  # <- the only change
)

with open("meeting.mp3", "rb") as f:
    srt = client.audio.transcriptions.create(model="whisper-1", file=f, response_format="srt")
open("meeting.srt", "w").write(srt)

client.audio.speech.create(model="tts-1", voice="alloy", input="Your order has shipped.").write_to_file("hi.mp3")
Enter fullscreen mode Exit fullscreen mode

The Node SDK takes baseURL in the same way. json, text, srt, vtt and verbose_json all come back in
OpenAI's format, and OpenAI voice names map to similar voices. We ran each of these calls with the stock
openai packages (Python and Node) before writing this.

What is behind it

Disclosure: the endpoint is ours (SpellzCode). It runs Whisper large-v3-turbo for transcription and Deepgram Aura
voices for speech. The trade-offs, honestly:

OpenAI This endpoint
Account to start Yes, plus a card No: a $1 card top-up gives a key, or an agent pays per call in USDC (x402)
One hour of audio $0.36 (whisper-1), $0.18 (gpt-4o-mini-transcribe) $0.05 per file up to 60 min (/transcribe/long)
Short clip per minute $0.01 per file up to 5 MB
Subtitles srt / vtt srt / vtt
Speech languages many English and Spanish
Failed calls never charged

If you need many speech languages or a specific OpenAI model such as gpt-4o-transcribe, stay on OpenAI. If you mostly
transcribe and want no account and a lower bill, this is a one-line switch.

Long recordings

The OpenAI endpoint caps uploads at 25 MB. For meetings and podcasts there is a separate call that takes up to 60
minutes of MP3 or WAV, splits it into parts and joins the timestamps:

curl -s -G "https://agent-data-tools.revmesh2074.workers.dev/transcribe/long" \
  -H "Authorization: Bearer $API_KEY" \
  --data-urlencode "url=https://example.com/episode.mp3" \
  --data-urlencode "subtitles=srt" | jq -r .subtitles > episode.srt
Enter fullscreen mode Exit fullscreen mode

A 9.7-minute speech came back in 3 parts with continuous SRT timestamps.

Code ElevenLabs users can keep

The same endpoint also answers POST /v1/speech-to-text and POST /v1/text-to-speech/{voice_id} in ElevenLabs'
shape, with the same xi-api-key header. Only the host changes.

All the examples, tested, MIT licensed:
https://github.com/Nutshell2000/voice-api-no-account-examples

Top comments (0)