Recursive AI

Transcribe an MP4 video in C#

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

Turn the audio track of a video into text. Register the media adapter before opening the file; the example uses an English speech model.

Terminal
dotnet add package RecursiveAI.OneSpeech.Media
dotnet add package RecursiveAI.OneSpeech.Models.MoonshineStreamingTiny

Requires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.

sample.mp4 is included in the zip; you can substitute your own video with a supported audio track. VAD (voice activity detection) finds the speech parts, Silero is the VAD model, and Moonshine is the English recognition model.

C#
using OneSpeech;
using OneSpeech.Moonshine;
using OneSpeech.Vad;
using OneSpeech.Pipeline;
using OneSpeech.Media;
 
MediaInput.Register();
using var recognizer = await MoonshineRecognizer.LoadAsync();
using var vad = new SileroVad();
var pipeline = new VadTranscriptionPipeline(recognizer, vad);
var transcript = pipeline.Transcribe("sample.mp4", "en");
File.WriteAllText("transcript.txt", transcript.Text);
Console.WriteLine(transcript.Text);

Writes transcript.txt and prints:

Text
Stuff it into you, his belly counseled him.

Unzip the example, then dotnet run.

Full program

The zip includes sample.mp4: a short English reading, “Stuff it into you, his belly counseled him.” Source: LibriSpeech test-clean utterance 1089-134686-0001, Vassil Panayotov, Guoguo Chen, Daniel Povey and Sanjeev Khudanpur (2015), CC BY 4.0. The MP4 adapts its audio to AAC and adds a generated black video track.

The download’s Program.cs is the snippet above.

Output:

Text
Stuff it into you, his belly counseled him.

Missing or corrupt input and missing model files fail instead of producing a successful empty result.

Variations

Pass a cancellation token

Replace the transcription call with this overload. Use your application’s token instead of None to allow cancellation:

C#
var transcript = pipeline.Transcribe(
    "sample.mp4", "en", CancellationToken.None);

Output:

Text
Stuff it into you, his belly counseled him.

The short answer

Install RecursiveAI.OneSpeech.Media, call MediaInput.Register() once at startup and pass the MP4 path to a transcription pipeline. The adapter reads the container’s audio track and supplies decoded samples to recognition. The example writes transcript.txt; it does not read text visible in video frames.

Is there a way to transcribe an MP4 video?

Yes, when the MP4 contains a decodable speech audio track. The media adapter uses the default audio track and OneMedia.Audio’s supported codecs. Video decoding is not part of this operation. A video with no audio cannot supply spoken words, and a supported container extension does not guarantee support for every codec it can contain.

The OneSpeech media guide lists MP4/MOV, Matroska/WebM, AVI, transport streams, ASF and FLV, subject to audio codec support. The pinned OneMedia audio adapter guide maps AAC, Opus, Vorbis, FLAC, MP3 and AMR-NB/WB tracks to decoders; it names AC-3, E-AC-3, PCM, ALAC and protected tracks as unsupported. These are container and codec lists, not a promise that every combination or codec profile works.

The sample uses AAC speech audio and a generated black picture. This keeps the download small while exercising a real MP4 container. It is not a placeholder file renamed from WAV. The text shown above comes from its decoded audio, not a hard-coded transcript.

Register the adapter before opening input files. Registration configures an explicit decoder hook; it does not download speech weights. Core decoders still handle their supported audio formats first. On other supported inputs, the media adapter opens the container. Registration alone does not change recognition language or model selection.

How can I transcribe an audio transcript from a video?

The complete program separates the jobs: open the container through the registered adapter, detect speech with Silero VAD, recognize English using Moonshine streaming tiny and save the resulting text. The pipeline decodes in bounded chunks rather than loading the whole video waveform into memory. Returned transcript text and metadata still grow with the recording.

This is an explicit, lightweight recognition pipeline. It does not add whole-file speaker clustering or companion forced aligners. Its Text is suitable for a plain transcript. Do not assume every word has a measured timestamp or speaker just because the result is a Transcript object.

The higher-level Speech.Transcribe(path, language: "en") helper provides a different composition that includes diarization and timing companions. Those extra roles can require additional model downloads. See loading and composition before swapping APIs on a disconnected machine.

How to automatically transcribe a video?

Run the pipeline after a complete input file is available. Handle decoding, model and file errors rather than treating an empty output as successful conversion. A container without a decodable track fails; it is not silently treated as silence. Keep the input file unchanged while processing it.

The cancellation variation passes a token through decoding and inference cancellation points. In an application, supply a token from the operation that owns the job. The example uses CancellationToken.None so it runs to completion from the command line.

Can I transcribe an MP4 video for free?

The library is free and open source, and this example uses packaged model weights for local inference without an API key. Restore still needs NuGet access or a prepared package feed. Deployment must retain the model directory copied beside the executable, not just the executable itself.

A plain text transcript is not a subtitle file: it has no display cue timing. The media package can export captions from a suitably timed transcript, but refuses completely unknown cue bounds rather than assigning arbitrary times. If your goal is subtitles, first choose a pipeline that obtains the timing evidence your export needs. The caption policy explains that distinction.

All onespeech recipes