class

Yt::TranscriptExtractor

Inherits Reference < Object

Service to extract transcripts from YouTube videos using yt-dlp and Whisper fallback.

Constants

DEFAULT_LANG = "es,en"
DEFAULT_WHISPER_MODEL = "base"

Constructors

new(yt_dlp_path : String = "yt-dlp", whisper_path : String = "whisper", cookies_from_browser : String | Nil = "firefox")
Source

Instance methods

clean_subtitle_text(text : String) : String

Strips HTML/VTT style tags, e.g. <c.colorE5E5E5> or <00:00:01.000> and unescapes HTML entities

Source
extract(video_id : String, lang : String = DEFAULT_LANG, allow_audio_fallback : Bool = true, whisper_model : String = DEFAULT_WHISPER_MODEL) : Models::Transcript

Extracts transcript for the given video_id.

video_id - 11-character YouTube video ID lang - Preferred language codes (comma-separated, e.g. "es,en") allow_audio_fallback - Whether to download audio and run local Whisper if no captions exist whisper_model - Whisper model to use if audio fallback is triggered (default: "base")

Source
parse_json3(json_content : String) : Array(Models::TranscriptSegment)

Parses YouTube json3 subtitle format

Source
parse_timestamp(ts : String) : Float64

Converts HH:MM:SS.mmm or MM:SS.mmm to seconds (Float64)

Source
parse_vtt(vtt_content : String) : Array(Models::TranscriptSegment)

Parses WebVTT content into an array of TranscriptSegment

Source