and the  OpenAIWhisperParserLocal for local support and running on private clouds or on premise.Note: You will need to have an OPENAI_API_KEY supplied.from langchain.document_loaders.generic import GenericLoaderfrom langchain.document_loaders.parsers import OpenAIWhisperParser, OpenAIWhisperParserLocalfrom langchain.document_loaders.blob_loaders.youtube_audio import YoutubeAudioLoaderWe will use yt_dlp to download audio for YouTube urls.We will use pydub to split downloaded audio files (such that we adhere to Whisper API's 25MB file size limit).pip install yt_dlp pip install pydub pip install librosaYouTube url to text‚ÄãUse YoutubeAudioLoader to fetch / download the audio files.Then, ues OpenAIWhisperParser() to transcribe them to text.Let's take the first lecture of Andrej Karpathy's YouTube course as an example! # set a flag to switch between local and remote parsing# change this to True if you want to use local parsinglocal = False# Two Karpathy lecture videosurls = ["https://youtu.be/kCc8FmEb1nY", "https://youtu.be/VMj-3S1tku0"]# Directory to save audio filessave_dir = "~/Downloads/YouTube"# Transcribe the videos to textif local:    loader = GenericLoader(YoutubeAudioLoader(urls, save_dir), OpenAIWhisperParserLocal())else:    loader = GenericLoader(YoutubeAudioLoader(urls, save_dir), OpenAIWhisperParser())docs = loader.load()    [youtube] Extracting URL: https://youtu.be/kCc8FmEb1nY    [youtube] kCc8FmEb1nY: Downloading webpage    [youtube] kCc8FmEb1nY: Downloading android player API JSON    [info] kCc8FmEb1nY: Downloading 1 format(s): 140    [dashsegments] Total fragments: 11    [download] Destination: /Users/31treehaus/Desktop/AI/langchain-fork/docs/modules/indexes/document_loaders/examples/Let's build GPTÔºö from scratch, in code, spelled out..m4a    [download] 100% of  107.73MiB in 00:00:18 at 5.92MiB/s                       [FixupM4a] Correcting container of "/Users/31treehaus/Desktop/AI/langchain-fork/docs/modules/indexes/document_loaders/examples/Let's
Building chat or QA applications on YouTube videos is a topic of high interest.
Building chat or QA applications on YouTube videos is a topic of high interest. ->: and the  OpenAIWhisperParserLocal for local support and running on private clouds or on premise.Note: You will need to have an OPENAI_API_KEY supplied.from langchain.document_loaders.generic import GenericLoaderfrom langchain.document_loaders.parsers import OpenAIWhisperParser, OpenAIWhisperParserLocalfrom langchain.document_loaders.blob_loaders.youtube_audio import YoutubeAudioLoaderWe will use yt_dlp to download audio for YouTube urls.We will use pydub to split downloaded audio files (such that we adhere to Whisper API's 25MB file size limit).pip install yt_dlp pip install pydub pip install librosaYouTube url to text‚ÄãUse YoutubeAudioLoader to fetch / download the audio files.Then, ues OpenAIWhisperParser() to transcribe them to text.Let's take the first lecture of Andrej Karpathy's YouTube course as an example! # set a flag to switch between local and remote parsing# change this to True if you want to use local parsinglocal = False# Two Karpathy lecture videosurls = ["https://youtu.be/kCc8FmEb1nY", "https://youtu.be/VMj-3S1tku0"]# Directory to save audio filessave_dir = "~/Downloads/YouTube"# Transcribe the videos to textif local:    loader = GenericLoader(YoutubeAudioLoader(urls, save_dir), OpenAIWhisperParserLocal())else:    loader = GenericLoader(YoutubeAudioLoader(urls, save_dir), OpenAIWhisperParser())docs = loader.load()    [youtube] Extracting URL: https://youtu.be/kCc8FmEb1nY    [youtube] kCc8FmEb1nY: Downloading webpage    [youtube] kCc8FmEb1nY: Downloading android player API JSON    [info] kCc8FmEb1nY: Downloading 1 format(s): 140    [dashsegments] Total fragments: 11    [download] Destination: /Users/31treehaus/Desktop/AI/langchain-fork/docs/modules/indexes/document_loaders/examples/Let's build GPTÔºö from scratch, in code, spelled out..m4a    [download] 100% of  107.73MiB in 00:00:18 at 5.92MiB/s                       [FixupM4a] Correcting container of "/Users/31treehaus/Desktop/AI/langchain-fork/docs/modules/indexes/document_loaders/examples/Let's