-
-
Save johndpope/ce0a2d9b915ab3e90062491c0046fe9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import assemblyai as aai | |
from pytube import YouTube | |
aai.settings.api_key = "INSERT YOUR API KEY HERE" | |
youtube_url = "https://www.youtube.com/watch?v=f94wKh70cOY" | |
# Let's download the YouTube video | |
youtube = YouTube(youtube_url) | |
audio = youtube.streams.filter(only_audio=True).first() | |
filename = os.path.basename(audio.download()) | |
# We can now transcribe it | |
transcriber = aai.Transcriber() | |
transcript = transcriber.transcribe(filename) | |
print(transcript.text) | |
# This will summarize the video | |
summary = transcript.lemur.summarize( | |
context="A magician performing a magic trick" | |
) | |
print(summary.response) | |
# Now we can ask questions about the video | |
questions = [ | |
aai.LemurQuestion(question="What is the name of the magician?"), | |
aai.LemurQuestion(question="What are the names of the participants?"), | |
aai.LemurQuestion(question="What is the magic trick about?"), | |
] | |
answers = transcript.lemur.question(questions) | |
for answer in answers.response: | |
print(f"Question: {answer.question}") | |
print(f"Answer: {answer.answer}") | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment