StampyAI / alignment-research-dataset

Stampy's copy of Alignment Research Dataset scraper
https://huggingface.co/datasets/StampyAI/alignment-research-dataset
MIT License
6 stars 6 forks source link

Improve YouTube transcripts #172

Open ccstan99 opened 10 months ago

ccstan99 commented 10 months ago

We are currently using transcripts directly from YouTube. Many are low quality, without proper capitalization & punctuation and odd formatting. There are Otter transcripts at https://drive.google.com/drive/u/0/folders/12FFjcP_60rq3qgq_Wl7HDWIjEA7p_3T_ for many of the YouTube videos from the previous ARD but we'll need to reconcile the transcripts with the associated URL.

For new videos, we may want to consider integrating Whisper transcripts into the workflow, i.e. https://huggingface.co/spaces/SteveDigital/free-fast-youtube-url-video-to-text-using-openai-whisper

ccstan99 commented 10 months ago

Maybe we can use LangChain document loaders in conjuction with their whisper parser? https://python.langchain.com/docs/integrations/document_loaders/youtube_audio

# ! pip install yt_dlp
# ! pip install pydub

from langchain.document_loaders.generic import GenericLoader
from langchain.document_loaders.parsers import OpenAIWhisperParser
from langchain.document_loaders.blob_loaders.youtube_audio import YoutubeAudioLoader

url="https://www.youtube.com/watch?v=jGwO_UgTS7I"
save_dir="docs/youtube/"
loader = GenericLoader(
    YoutubeAudioLoader([url],save_dir),
    OpenAIWhisperParser()
)
docs = loader.load()