MediaSearch / app.py
azamat's picture
Added title and desc
f06e255
raw
history blame
1.57 kB
import os
import gdown
import gradio as gr
from weaviate_explorer import WeaviateExplorer
weaviate_explorer = WeaviateExplorer()
# video_player = gr.Video(label="Search Results")
downloads_dir = "downloads" # Directory to store downloaded videos
# Create the downloads directory if it doesn't exist
os.makedirs(downloads_dir, exist_ok=True)
def remove_downloaded_videos():
"""Remove all downloaded videos from the 'downloads' directory."""
for file_name in os.listdir(downloads_dir):
file_path = os.path.join(downloads_dir, file_name)
if os.path.isfile(file_path):
os.remove(file_path)
def search(query):
# remove_downloaded_videos() # Remove previously downloaded videos
shorts = weaviate_explorer.explore(query)
download_url = f"https://drive.google.com/uc?id={shorts[0]['link'].split('/')[-2]}"
video_path = gdown.download(download_url, output=f"./video.mp4")
return video_path, "\n\n".join([f"{r['title']}\n{r['link']}" for r in shorts])
title = "Slideo Explorer: Your AI-based short video search engine"
description = "Write down a search query, question or a topic and receive top-5 most relevant short video-answers. The most relevant clip will be displayed in the widget and the whole list will be available in another widget as a list of titles, links to Google Drive."
iface = gr.Interface(fn=search,
inputs="text",
outputs=["playable_video", "text"],
title=title,
description=description)
iface.launch()