I build browser extensions that dub online course videos (Udemy, Coursera, YouTube) into the viewer's language. Going in, I assumed the interesting engineering would be the AI: the translation, the voices, the pipeline. It wasn't. The AI parts turned out to be mostly plumbing between APIs.

The part that actually ate my time was dumber and much harder: playing generated audio, in sync, inside a video player I don't own and can't modify.

One aside first, because someone always asks: I don't run speech-to-text. The platforms already ship a caption track, so I read that instead of transcribing the audio. Cheaper, faster, cleaner on technical vocabulary. Good decision, one line to explain, and not what this post is about. This post is about everything downstream of "I already have the text."

Problem 1: getting a second audio track to coexist with a player you don't control

You can't just play a new <audio> element and hope for the best. The original video is still sitting there with its own audio, its own controls, its own event handling. Your track has to duck the source audio, follow every play, pause, seek and rate change the user triggers on the native controls, and never break those controls in the process.