SonioxSRT provides helper libraries and CLIs for working with the Soniox async transcription API and generating SRT subtitles. The repository hosts parallel implementations in Python and TypeScript that share common samples and tests.
python/– Python package, CLI entry points, and pytest suite.ts/– TypeScript port with equivalent APIs, CLIs, and Vitest coverage.samples/– Shared audio/transcript fixtures used by both stacks.
- Export your Soniox API key (or add it to a
.envfile in the repo root):export SONIOX_API_KEY=<YOUR_API_KEY>
- Pick the language you want to use:
- Python instructions live in
python/README.md. - TypeScript instructions live in
ts/README.md.
- Python instructions live in
Both implementations load the shared fixtures from samples/ and expose CLIs for
transcribing audio and emitting SRT files.
Python
from pathlib import Path
from sonioxsrt import srt, run_realtime_session
# Convert the shared sample transcript into subtitles
srt(Path("../samples/response.json"), output_path="subtitles.srt")
print("SRT ready at subtitles.srt")
# Stream audio using the realtime model (requires `pip install websockets`)
session = run_realtime_session("../samples/audio.mp3", model="stt-rt-preview-v2")
print(session.text)TypeScript
import { srt, runRealtimeSession } from "sonioxsrt";
// Convert the shared sample transcript into subtitles
srt("../samples/response.json", "subtitles.srt");
console.log("SRT ready at subtitles.srt");
// Realtime transcription (requires the optional `ws` dependency)
const session = await runRealtimeSession({
audioPath: "../samples/audio.mp3",
model: "stt-rt-preview-v2"
});
console.log(session.text);-
Python
cd python poetry install poetry run pytest -
TypeScript
cd ts npm install npm test
GitHub Actions runs both the Python and TypeScript suites on every push and pull
request. The workflow definition lives at
./.github/workflows/tests.yml.