Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,8 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from pytube import YouTube
|
| 3 |
from crewai import Agent, Task, Crew
|
| 4 |
from transformers import pipeline
|
| 5 |
import torch
|
| 6 |
import whisper
|
| 7 |
-
import yt_dlp
|
| 8 |
import os
|
| 9 |
|
| 10 |
st.title("AI Blog Writer from YouTube")
|
|
@@ -12,20 +10,20 @@ st.title("AI Blog Writer from YouTube")
|
|
| 12 |
# Whisper model setup (Base Model for better speed)
|
| 13 |
whisper_model = whisper.load_model("base")
|
| 14 |
|
| 15 |
-
def
|
| 16 |
-
"""
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
}
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
| 29 |
|
| 30 |
def transcribe_audio(audio_path):
|
| 31 |
"""Transcribes the audio using Whisper AI."""
|
|
@@ -51,12 +49,8 @@ video_url = st.text_input("Enter YouTube Video URL:")
|
|
| 51 |
if st.button("Generate Blog"):
|
| 52 |
if video_url:
|
| 53 |
try:
|
| 54 |
-
st.info("
|
| 55 |
-
|
| 56 |
-
st.success("Audio downloaded successfully!")
|
| 57 |
-
|
| 58 |
-
st.info("Transcribing audio using Whisper...")
|
| 59 |
-
transcript_text = transcribe_audio(audio_path)
|
| 60 |
st.text_area("Transcript Extracted", transcript_text, height=200)
|
| 61 |
|
| 62 |
# Generate Blog with CrewAI
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
from crewai import Agent, Task, Crew
|
| 3 |
from transformers import pipeline
|
| 4 |
import torch
|
| 5 |
import whisper
|
|
|
|
| 6 |
import os
|
| 7 |
|
| 8 |
st.title("AI Blog Writer from YouTube")
|
|
|
|
| 10 |
# Whisper model setup (Base Model for better speed)
|
| 11 |
whisper_model = whisper.load_model("base")
|
| 12 |
|
| 13 |
+
def get_video_transcript(video_url):
|
| 14 |
+
"""Fetch video transcript using CrewAI's YouTubeChannelSearch tool."""
|
| 15 |
+
from crewai.tools.youtubechannelsearch import YouTubeChannelSearch
|
| 16 |
+
|
| 17 |
+
# Initialize the YouTube Channel Search tool
|
| 18 |
+
search_tool = YouTubeChannelSearch()
|
| 19 |
+
|
| 20 |
+
# Search for video and fetch transcript
|
| 21 |
+
video_data = search_tool.search(video_url)
|
|
|
|
| 22 |
|
| 23 |
+
if video_data and 'transcript' in video_data:
|
| 24 |
+
return video_data['transcript']
|
| 25 |
+
else:
|
| 26 |
+
raise Exception("Transcript not found for this video.")
|
| 27 |
|
| 28 |
def transcribe_audio(audio_path):
|
| 29 |
"""Transcribes the audio using Whisper AI."""
|
|
|
|
| 49 |
if st.button("Generate Blog"):
|
| 50 |
if video_url:
|
| 51 |
try:
|
| 52 |
+
st.info("Fetching transcript...")
|
| 53 |
+
transcript_text = get_video_transcript(video_url) # Fetch transcript using CrewAI
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
st.text_area("Transcript Extracted", transcript_text, height=200)
|
| 55 |
|
| 56 |
# Generate Blog with CrewAI
|