---
title: "Convert an SRT file to a speech transcript in C#"
url: https://recursiveai.org/onespeech/cookbook/import-subtitles-as-transcript/
description: "Read an SRT file as a OneSpeech transcript in C#. Keep the subtitle text and cue times without a speech model or guessed word timestamps."
version: "1.1.0"
---

# Convert an SRT file to a speech transcript in C#

**OneSpeech** is a free, open-source speech recognition library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneSpeech.Media) · [GitHub](https://github.com/recursive-ai-oss/onespeech-csharp) · [Docs](https://recursiveai.org/onespeech/docs/) · [Download example (.zip)](https://recursiveai.org/onespeech/cookbook/import-subtitles-as-transcript/import-subtitles-as-transcript.zip)

Import `sample.srt` from the download. `ToTranscript()` keeps the cue times without audio or a model.

```shell
dotnet add package RecursiveAI.OneSpeech.Media
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using OneSpeech.Media;
using RecursiveAI.OneMedia.Captions;

var bytes = File.ReadAllBytes("sample.srt");
var cues = SubtitleFormats.Srt.Read(bytes);
var transcript = cues.ToTranscript();
Console.WriteLine(transcript.Text);
```

Unzip [the example](https://recursiveai.org/onespeech/cookbook/import-subtitles-as-transcript/import-subtitles-as-transcript.zip), then `dotnet run`.

```text
Welcome to the workshop.
Let’s get started.
```

The `RecursiveAI.OneSpeech.Media` package brings in `RecursiveAI.OneMedia.Captions` through its OneMedia dependency.

## The full program

Here’s the complete `sample.srt`. Each cue has a number, a time range and the text to display.

```text
1
00:00:01,000 --> 00:00:03,500
Welcome to the workshop.

2
00:00:04,000 --> 00:00:06,000
Let’s get started.
```

```csharp
using OneSpeech.Media;
using RecursiveAI.OneMedia.Captions;

var bytes = File.ReadAllBytes("sample.srt");
var cues = SubtitleFormats.Srt.Read(bytes);
var transcript = cues.ToTranscript();
Console.WriteLine(transcript.Text);
foreach (var segment in transcript.Segments)
{
    Console.WriteLine($"{segment.Start:c} --> {segment.End:c}");
}
Console.WriteLine($"Word records: {transcript.Words.Length}");
Console.WriteLine($"Speaker turns: {transcript.Turns.Length}");
```

`dotnet run` prints:

```text
Welcome to the workshop.
Let’s get started.
00:00:01 --> 00:00:03.5000000
00:00:04 --> 00:00:06
Word records: 0
Speaker turns: 0
```

The SRT reader can throw `MediaFormatException` if it can’t read the input as that format.

## Variations

**Save plain text.** Replace the last line of the snippet at the top. This writes the two text lines to `transcript.txt`, without the cue numbers or time ranges.

```csharp
File.WriteAllText("transcript.txt", transcript.Text);
```

## Related recipes

- [Save and load a transcript as JSON](https://recursiveai.org/onespeech/cookbook/save-transcript-as-json/)
- [Generate SRT subtitles from audio](https://recursiveai.org/onespeech/cookbook/generate-subtitles-from-audio/)
- [Get word timestamps from audio](https://recursiveai.org/onespeech/cookbook/word-timestamps/)

## The short answer

In C#, pass the bytes of the `.srt` file to `SubtitleFormats.Srt.Read`, then call `ToTranscript()` on the result. The parser is available through the `RecursiveAI.OneSpeech.Media` package. Use `transcript.Text` for the joined subtitle text or `transcript.Segments` when you also need the start and end of each cue. This imports existing captions; it doesn’t run speech recognition or check the captions against the recording.

## What is the SRT subtitle format?

[SubRip (SRT)](https://www.loc.gov/preservation/digital/formats/fdd/fdd000569.shtml) is a text format for subtitles. A blank line separates cue blocks; a single block can have more than one line of text. In `00:00:03,500`, the comma separates whole seconds from milliseconds. That timestamp marks an edge of the display window for the entire cue, not the moment an individual word is spoken.

The importer makes one segment per cue. In the example, the second segment starts at 4 seconds and ends at 6 seconds. The half-second gap between the two segments stays in the timestamps; it doesn’t become an extra segment or a blank line in `transcript.Text`.

## How do you convert SRT to plain text without losing the timestamps you still need?

Write `transcript.Text` to a text file for reading or searching. The text joins the segment strings with newlines. It doesn’t include cue numbers or timestamp lines, and it doesn’t try to rewrite captions into paragraphs or remove repeated dialogue. Keep the original SRT if another tool still needs the subtitle file. If your application needs the OneSpeech segments and their timing later, the [transcript JSON format](https://recursiveai.org/onespeech/docs/transcript-json/) stores the transcript data instead of flattening it to text.

A common shortcut is to delete every line that looks like a number. That can remove real subtitle text, such as a cue that reads “2026.” Reading the SRT as cues first separates the file structure from the content before you export the text.

## Can you get word timestamps from an SRT file?

Not from the cue times alone. Nothing in the first cue tells you when “workshop” began. The [OneSpeech caption guide](https://recursiveai.org/onespeech/docs/media/#caption-policy) puts it plainly: “It never infers word times from cue bounds.” The example has no word records and no speaker turns. A speaker’s name typed into an SRT cue is still text, not a separate speaker label.

Use the existing cue times if you only need to jump to the right passage in a recording. If you need where each word falls, you need another source of timing, such as [aligning the supplied text to the original audio](https://recursiveai.org/onespeech/cookbook/forced-alignment/). That is a separate operation from importing subtitles.
