Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

Is there a way to download the automatically generated YouTube transcriptions without downloading the video?

I would like to check out the TED talks, but I have limited bandwidth and would like to export the automated transcripts (also possibly known as subtitles or closed captions).

share|improve this question
    
anybody know a way to do this for videos with automatically transcribed subtitles? –  qntmfred Mar 6 '12 at 4:44
    
Related (for non-auto-generated subtitles): webapps.stackexchange.com/questions/25072/… –  Mechanical snail Nov 12 '12 at 1:01

5 Answers 5

Use "Network inspector" function of your browser's script debugger and find second request to timedtext page after enabling transcribed subtitles then just copy all that request to the addressbar to download them in native YouTube xml format.

To get SRT version run this code in the debugger console for that xml's page:

function makeTimeline (time) {
    var string, time_array = [], milliseconds = Math.round(time % 1 * 1000).toString();

    while (3 > milliseconds.length) {
        milliseconds = '0' + milliseconds;
    }

    time_array.push(Math.floor(time / (60 * 60)));
    time_array.push(Math.floor((time - (time_array[0] * 60 * 60)) / 60));
    time_array.push(Math.floor(time - ((time_array[1] * 60) + (time_array[0] * 60 * 60))));

    for (var i = 0, il = time_array.length; i < il; i++) {
        string = '' + time_array[i];
        if (1 === string.length) {
            time_array[i] = '0' + string;
        }
    }
    return time_array.join(':') + ',' + milliseconds;
};

function returnSRT (data) {
    var caption, previous_start, start, end, temp, captions = data.getElementsByTagName('text'), srt_output = '';

    for (var i = 0, il = captions.length; i < il; i++) {
        caption = captions[i];
        start = +caption.getAttribute('start');

        if (0 <= previous_start) {
            temp = captions[i - 1].textContent.replace(/</g, '&lt;').replace(/>/g, '&gt;');
            srt_output += i + '\n' + makeTimeline(previous_start) + ' --> ' + makeTimeline(start) + '\n' + temp + '\n\n';
            previous_start = -1;
        }

        if ( end = +caption.getAttribute('dur'))
            end = start + end;
        else {
            if (captions[i + 1]) {
                previous_start = start;
                continue;
            }
        }

        temp = caption.textContent.replace(/</g, '&lt;').replace(/>/g, '&gt;');
        srt_output += i + '\n' + makeTimeline(start) + ' --> ' + makeTimeline(end) + '\n' + temp + '\n\n';
    };
    return srt_output;
}

returnSRT(document.documentElement)

Also here is bookmarklet version of the script:

javascript:(function(){function%20makeTimeline(time)%7Bvar%20string%2Ctime_array%3D%5B%5D%2Cmilliseconds%3DMath.round(time%251*1000).toString()%3Bwhile(3%3Emilliseconds.length)%7Bmilliseconds%3D'0'%2Bmilliseconds%3B%7Dtime_array.push(Math.floor(time%2F(60*60)))%3Btime_array.push(Math.floor((time-(time_array%5B0%5D*60*60))%2F60))%3Btime_array.push(Math.floor(time-((time_array%5B1%5D*60)%2B(time_array%5B0%5D*60*60))))%3Bfor(var%20i%3D0%2Cil%3Dtime_array.length%3Bi%3Cil%3Bi%2B%2B)%7Bstring%3D''%2Btime_array%5Bi%5D%3Bif(1%3D%3D%3Dstring.length)%7Btime_array%5Bi%5D%3D'0'%2Bstring%3B%7D%7Dreturn%20time_array.join('%3A')%2B'%2C'%2Bmilliseconds%3B%7D%3Bfunction%20returnSRT(data)%7Bvar%20caption%2Cprevious_start%2Cstart%2Cend%2Ctemp%2Ccaptions%3Ddata.getElementsByTagName('text')%2Csrt_output%3D''%3Bfor(var%20i%3D0%2Cil%3Dcaptions.length%3Bi%3Cil%3Bi%2B%2B)%7Bcaption%3Dcaptions%5Bi%5D%3Bstart%3D%2Bcaption.getAttribute('start')%3Bif(0%3C%3Dprevious_start)%7Btemp%3Dcaptions%5Bi-1%5D.textContent.replace(%2F%3C%2Fg%2C'%26lt%3B').replace(%2F%3E%2Fg%2C'%26gt%3B')%3Bsrt_output%2B%3Di%2B'%5Cn'%2BmakeTimeline(previous_start)%2B'%20--%3E%20'%2BmakeTimeline(start)%2B'%5Cn'%2Btemp%2B'%5Cn%5Cn'%3Bprevious_start%3D-1%3B%7Dif(end%3D%2Bcaption.getAttribute('dur'))end%3Dstart%2Bend%3Belse%7Bif(captions%5Bi%2B1%5D)%7Bprevious_start%3Dstart%3Bcontinue%3B%7D%7Dtemp%3Dcaption.textContent.replace(%2F%3C%2Fg%2C'%26lt%3B').replace(%2F%3E%2Fg%2C'%26gt%3B')%3Bsrt_output%2B%3Di%2B'%5Cn'%2BmakeTimeline(start)%2B'%20--%3E%20'%2BmakeTimeline(end)%2B'%5Cn'%2Btemp%2B'%5Cn%5Cn'%3B%7D%3Breturn%20srt_output%3B%7Dwindow.location.href%3D'data%3Atext%2Fplain%3Bbase64%2C'%2Bbtoa(returnSRT(document.documentElement))})();
share|improve this answer

There are a couple of ways to extract subtitles from a YouTube video -

By specifying the language and VideoId in this generic URL - http://video.google.com/timedtext?lang={LANG}&v={VIDEOID} http://www.youtube.com/api/timedtext?lang={LANG}&v={VIDEOID} you can get an .xml file containing the subtitles in the desired language for a choosen video.

To get rid of the tags within that file and to just have the plain-text transcript, here is what you have to do:

  • Open up Microsoft Excel
  • Copy paste the subtitles inside one cell
  • Press Ctrl+H
  • In the replace tab type <*> in the Find What textbox and leave the Replace With textbox blank, and click Replace All. The search expression will remove all tags within the original text.

Alternatively, there is an open-source tool called Google2SRT that downloads all available subs from a YouTube video with one click & converts them into .srt format so that it can be used within media players like VLC Media Player.

Update: Ted.com now provides transcripts of the talks on its site.

share|improve this answer
    
The generic URL does not seem to work. I enter http://video.google.com/timedtext?lang=english&v=b11AXknrsEI but it does not work. Also, going to developer tools does not help. There are tons of resources in there and none of them say timedtext. –  fredsbend Feb 27 at 23:21
    
Nevermind, I did find it through the dev tools. Still can't get a generic url to work though. That would be the easiest thing. –  fredsbend Feb 27 at 23:34
    
Try youtube.com/api/timedtext?lang={LANG}&v={VIDEOID} –  mvark Mar 17 at 14:39
    
I must be doing something wrong. For this video I enter this but it loads a blank page. I have tried changing english to en and eng but it does the same thing. –  fredsbend Mar 17 at 16:06
    
Looks like the subtitles can be fetched only if captions are manually transcribed i.e. not automatically generated. The video link you shared has only automatic captions. –  mvark Mar 17 at 18:38

I think this userscript should work for you:

http://userscripts.org/scripts/show/50003/

share|improve this answer
2  
Thanks, but that doesn't seem to allow downloading of automatically transcribed captions –  Casebash Jul 9 '10 at 23:06

If it is your own video, you can download the subtitles from the video manager. Go to:

Video Manager >> Edit (on the video you want) >> Captions >> (Click on the track you want to download) >> Actions (drop down box)

At the time of writing, there are three file types available:

  • .vtt
  • .srt
  • .sbv

These have different uses in different applications, but are very similar. SRT is probably the most common.

Otherwise, if it is not your video, the best method (only method) is to get the xml file from the Developer tools.

Using Google Chrome in this example, navigate to the video then follow these steps:

  1. Pause the video. Wait for it to play if there is an advertisement.
  2. Push F12 on your keyboard. This opens the developer tools. You may have to click on some empty space in the page so that the video is not active.
  3. Click on the Network tab in the Developer Tools.
  4. Click the transcript icon just below the video. Two items will come up in the Network tab in the Developer Tools.
  5. Both items are titled timedtext? plus a bunch of variables. The second one is typically the one you want. It starts like this:
    <transcript> <text start="4.14" dur="3.049">my name is doctor john rush</text> <text start="7.189" dur="3.731">I'm the CEO and president</text>

This xml file is useful if you want to use the transcript in a web page. Other than that, I don't think you can use it the same way you would use an SRT file. If you are any good at programming, you can easily write up a program that will convert it to SRT. I wrote my own C# program that extracts the data for a different purpose and it took less than two hours.

share|improve this answer

Google2SRT 0.6 supports YouTube ASR: http://sourceforge.net/projects/google2srt/

share|improve this answer
1  
An answer should be more than just a link to an external site. Please add a solution. –  toscho Feb 3 at 23:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.