pip install yt-dlp assemblyai
from google.colab import userdata
import assemblyai as aai
aai.settings.api_key = userdata.get('AAI_KEY')
import yt_dlp
def download_audio(url):
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
'outtmpl': '%(title)s.%(ext)s',
'verbose': True,
}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
URL = "https://www.youtube.com/watch?v=wB7IU0EFN68"
download_audio(URL)
audio_file = f'{video_title}.mp3'
Transcribing audio
transcriber = aai.Transcriber()
transcript = transcriber.transcribe(audio_file)
prompt = "What are the 5 key messages that was mentioned in this video?"
result = transcript.lemur.task(
prompt,
final_model=aai.LemurModel.claude3_5_sonnet
)
print(result.response)
References:
https://towardsdatascience.com/i-coded-a-youtube-ai-assistant-that-boosted-my-productivity-bdda884d4104
No comments:
Post a Comment