sonioxsrt
v0.1.1
Published
Soniox async transcription helpers and SRT generation (TypeScript port).
Maintainers
Readme
SonioxSRT (TypeScript)
Purpose: TypeScript port of the Soniox async transcription helpers and SRT generation utilities.
Prerequisites: Node.js 18+ (or compatible runtime)
Installation
npm install sonioxsrtLocal Development
cd ts
npm installEnvironment: Create a .env file at the repository root or export
SONIOX_API_KEY in your shell. The TypeScript implementation automatically
loads .env if the environment variable is missing.
CLI
npm run cli:transcribe -- --audio ../samples/audio.mp3 --output ../samples/response.jsonnpm run cli:to-srt -- --input ../samples/response.json --output subtitles.srt
Library
import { SubtitleConfig, tokensToSubtitleSegments, renderSegments, writeSrtFile, srt } from "sonioxsrt";
import transcript from "../samples/response.json" assert { type: "json" };
const tokens = transcript.tokens ?? [];
const config = new SubtitleConfig({ splitOnSpeaker: true });
const segments = tokensToSubtitleSegments(tokens, config);
const entries = renderSegments(segments, config);
writeSrtFile(entries, "subtitles.srt");
// Or rely on the convenience helper:
srt("../samples/response.json", "subtitles.srt");Testing
cd ts
npm testBuilding
npm run buildThis emits compiled JavaScript and declaration files in dist/ suitable for
publishing to npm.
