0
0

More than 1 year has passed since last update.

英語ディクテーション用にyoutube-dlでダウンロードしたvtt形式の字幕ファイルをPlain Textに変換するrubyスクリプト

Posted at

vtt形式は字幕表示に特化したフォーマットなので、人間が目で見るにはなかなか厳しいものがあります。

そこで、人間が見るのに適したPlain Textに変換するrubyスクリプトを作りました。

vtt2txt.rb
#!ruby

valid_texts = []

while line = gets
    line.strip!
    if line =~ /-->/
        valid_texts << gets.strip
    end
end

lastline = nil
valid_texts.each do |line|
    if line != lastline
        puts line
        lastline = line
    end
end

YouTubeのCNN 10の自動生成字幕で動作確認済みです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0