DNNs are huge data hungry algorithms specially bidirectional-LSTM. For speech recognition models, there's a dearth of voice corpus for specific language/ accents. However, YouTube is a huge library for the same.

I would need to use some script/software which would automatically download YouTube videos(possibly only audio) and the related captions and thereafter slice the same into 20 seconds clip, so that the same can be used as training speech corpus.

Is there any way captions from Youtube can be downloaded? And given a audio and the scripts, how can I slice a audio into 20 seconds clips and have the same clipped in the transcript as well?

  • Welcome to Software Recommendations! Please note this site is about recommending software, not assets or resources like howtos, manuals/tutorials, multi-media content, code fragments, etc. If you're looking for software, please see here what your question should contain.
    – Izzy
    Commented Dec 21, 2018 at 18:50
  • @Sayantan You should reword this to be inline with the help center. It is a very good and useful topic that I would be curious to see answered.
    – Gordon
    Commented Dec 22, 2018 at 5:07
  • 1
    @GordonA. Sure. Thanks, Let me see how I should reword my question. Afterall, this is a very important thing for Speech to Text recognition models. YouTube is a huge library for the same.
    – Sayantan
    Commented Dec 22, 2018 at 9:51
  • 1
    @GordonA. I see. thought it's like somewhere in between the two. I shall do the needful. Still. in case of someone can answer this here I shall not post it in SO, else I shall post it in the next 24 hours. Thanks a lot.
    – Sayantan
    Commented Dec 23, 2018 at 5:56
  • 1
    @GordonA. Thanks a lot. Now that I've waited for about 24 hors here; I'll use SO for this question now.
    – Sayantan
    Commented Dec 24, 2018 at 4:08

1 Answer 1


yt-dlp (or youtube-dl or another fork of youtube-dl)

  1. Can download video and/or audio and/or subtitles and/or other data from YouTube and/or many other websites.
  2. Easy to select the videos you want to target. Note options such as "--match-filter" to filter on almost any attribute and "--batch-file", which will download a list of URLs in the named file.
  3. Easy to grab most information without downloading the video. See, for example, "--skip-download"
  4. Many options explicitly for subtitles: see below. Especially note that you can distinguish between the automatic subtitles, which are machine generated, and files there were uploaded by a human, which doesn't mean they are accurate or generated by a human, just that they were not put in that location by YouTube.
  5. You can discard the video and keep only the audio. See, for example, "--extract-audio"

Subtitle options:

--write-subs                     Write subtitle file
--no-write-subs                  Do not write subtitle file (default)
--write-auto-subs                Write automatically generated subtitle file
                                 (Alias: --write-automatic-subs)
--no-write-auto-subs             Do not write auto-generated subtitles
                                 (default) (Alias: --no-write-automatic-subs)
--list-subs                      List available subtitles of each video.
                                 Simulate unless --no-simulate is used
--sub-format FORMAT              Subtitle format, accepts formats
                                 preference, for example: "srt" or
--sub-langs LANGS                Languages of the subtitles to download (can
                                 be regex) or "all" separated by commas.
                                 (Eg: --sub-langs "en.*,ja") You can prefix
                                 the language code with a "-" to exempt it
                                 from the requested languages. (Eg:
                                 --sub-langs all,-live_chat) Use --list-subs
                                 for a list of available language tags


  1. With a little cleverness, you should be able to create arbitrary length segments of audio and their associated subtitles. See, for example, this page describing how to remove the first five minutes of a video file and remove the first five minutes of the corresponding subtitle file.
  2. Extremely good at converting media to your desired codec.
  3. When configured properly (which isn't always obvious how to do), it is good at creating files with a precise time length.
  4. Fast. Free. Open-source. Multiplatform. Extensible.

This question is three years old, so I imagine the OP already found many options. But, maybe this will help other people.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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