[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"article-doc:docs\u002Frecorded\u002F4.subtitles":3},"---\ntitle: Subtitles\ndescription: Generate SRT \u002F VTT subtitle files from transcription results.\n---\nGenerate subtitle files from transcription result timestamps.\n\n## From transcription results to subtitles\n\nSegment data from a completed transcription can be directly converted to SRT or VTT:\n\n```json\n{\n  \"segments\": [\n    { \"id\": 0, \"start_time\": 0.0, \"end_time\": 3.2, \"text\": \"The weather is nice today\" },\n    { \"id\": 1, \"start_time\": 3.5, \"end_time\": 8.1, \"text\": \"It might rain tomorrow\" }\n  ]\n}\n```\n\n### SRT format\n\n```\n1\n00:00:00,000 --> 00:00:03,200\nThe weather is nice today\n\n2\n00:00:03,500 --> 00:00:08,100\nIt might rain tomorrow\n```\n\n### VTT format\n\n```\nWEBVTT\n\n00:00:00.000 --> 00:00:03.200\nThe weather is nice today\n\n00:00:03.500 --> 00:00:08.100\nIt might rain tomorrow\n```\n\n## Time format conversion\n\n| Format | Time notation |\n|---|---|\n| SRT | `HH:MM:SS,mmm` (comma for milliseconds) |\n| VTT | `HH:MM:SS.mmm` (dot for milliseconds) |\n| API | Seconds (float) |\n\n## Conversion function\n\n```python\ndef seconds_to_srt(seconds):\n    h = int(seconds \u002F\u002F 3600)\n    m = int((seconds % 3600) \u002F\u002F 60)\n    s = int(seconds % 60)\n    ms = int((seconds % 1) * 1000)\n    return f\"{h:02d}:{m:02d}:{s:02d},{ms:03d}\"\n\ndef generate_srt(segments):\n    lines = []\n    for i, seg in enumerate(segments, 1):\n        lines.append(str(i))\n        lines.append(f\"{seconds_to_srt(seg['start_time'])} --> {seconds_to_srt(seg['end_time'])}\")\n        lines.append(seg['text'])\n        lines.append(\"\")\n    return \"\\n\".join(lines)\n```\n\n## Segmentation rules\n\n- Each API segment maps to one subtitle entry\n- Gaps between segments naturally become subtitle breaks\n- No additional subtitle length limits are imposed by the API\n- For traditional subtitle formatting (character-per-line limits), split long segments client-side\n\n## Related\n\n- [Timestamps & Speakers](\u002Fdocs\u002Frecorded\u002Ftimestamps-speakers) — timestamp reference\n- [Transcribe Audio](\u002Fdocs\u002Frecorded\u002Ftranscribe-audio) — get transcription results\n- [Save a Transcript](\u002Fdocs\u002Fguides\u002Fsave-transcript) — persistence guide\n",1790059118960]