From: Michael D. Lowis Date: Tue, 26 Mar 2024 03:08:06 +0000 (-0400) Subject: added subtitles and script to generate them using whisper X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=c3f1c55459f36fda0ac1ce4e08ba65f0a891693e;p=proto%2Fatv.git added subtitles and script to generate them using whisper --- diff --git a/atv/assets/index.html b/atv/assets/index.html index f6fad0f..01f261b 100644 --- a/atv/assets/index.html +++ b/atv/assets/index.html @@ -13,6 +13,12 @@
@@ -69,6 +75,7 @@ const updatePlayer = (prev)=>{ if (diffTooBig || srcChanged || playStateChanged || chanChanged) { Video.src = current["curr"]["path"] + "#t=" + elapsed; + SubtitleTrack.src = current["curr"]["path"] + ".vtt"; if (current["playing"]) { Video.play(); diff --git a/atv/bin/atv-gensubs b/atv/bin/atv-gensubs new file mode 100644 index 0000000..f8c0464 --- /dev/null +++ b/atv/bin/atv-gensubs @@ -0,0 +1,11 @@ +#!/bin/env ruby + +TYPES = "{mp4,ogg,webm,avi}" +FILES = ARGV.map {|f| Dir.glob("#{f}/**/*.#{TYPES}") }.flatten +FILES.each do |f| + if not File.exist? "#{f}.vtt" + puts f + system("whisper \"#{f}\" --model small.en --language en -f vtt --threads 4 > \"#{f}.vtt.tmp\"") + FileUtils.mv("#{f}.vtt.tmp", "#{f}.vtt") + end +end diff --git a/atv/bin/atv-index b/atv/bin/atv-index new file mode 100644 index 0000000..094ced7 --- /dev/null +++ b/atv/bin/atv-index @@ -0,0 +1,7 @@ +#!/bin/env ruby + +TYPES = "{mp4,ogg,webm}" +FILES = ARGV.map {|f| Dir.glob("#{f}/**/*.#{TYPES}") }.flatten +FILES.each do |f| +end + diff --git a/atv/lib/atv/database.rb b/atv/lib/atv/database.rb index abd613e..829376c 100644 --- a/atv/lib/atv/database.rb +++ b/atv/lib/atv/database.rb @@ -53,7 +53,7 @@ module ATV def scan() # scan for videos @dirs.each do |dir| - Dir.glob("#{@root}/#{dir}/**/*.{mp4,webm,ogg}").each do |f| + Dir.glob("#{@root}/#{dir}/**/*.{mp4,m4v,webm,ogg}").each do |f| short_path = f.sub("#{@root}/", '') next if @data[short_path] puts f