Spaces:
Sleeping
Sleeping
File size: 1,748 Bytes
8e9d0f7 a20be5b f9a68e8 a20be5b 8e9d0f7 dd15546 e20ef5a a20be5b 9d5a5b5 e20ef5a f9a68e8 a20be5b f06e255 e04eb7c f06e255 617b57b e04eb7c 617b57b c9ef289 617b57b e04eb7c f06e255 a20be5b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
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 = "Enter a search query, question or topic to receive the top 5 most relevant short video answers. The most relevant clip will be displayed separately, and it will also be included in the list of top 5 video titles with links to Google Drive."
input_text = gr.Textbox(placeholder = "Your query, question, topic, ...", label = "Query")
video = gr.Video(label = "Most relevant clip")
output_text = gr.Textbox(label = "Top-5 relevants clips")
iface = gr.Interface(fn=search,
inputs=input_text,
outputs=[video, output_text],
title=title,
description=description)
iface.launch() |