CLIPSTAR1305 commited on
Commit
22b53d1
verified
1 Parent(s): d748f26

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +34 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import whisper
3
+ import yt_dlp
4
+ from moviepy.editor import VideoFileClip
5
+ import os
6
+ import uuid
7
+
8
+ model = whisper.load_model("base")
9
+
10
+ def download_video(url):
11
+ ydl_opts = {
12
+ 'format': 'best',
13
+ 'outtmpl': 'downloaded_video.%(ext)s',
14
+ }
15
+ with yt_dlp.YoutubeDL(ydl_opts) as ydl:
16
+ info = ydl.extract_info(url, download=True)
17
+ return ydl.prepare_filename(info)
18
+
19
+ def process_video(url):
20
+ video_path = download_video(url)
21
+ result = model.transcribe(video_path)
22
+ transcript = result['text']
23
+
24
+ clip = VideoFileClip(video_path).subclip(0, 30) # Clip corto de 30s
25
+ output_path = f"clip_{uuid.uuid4().hex}.mp4"
26
+ clip.write_videofile(output_path, codec="libx264", audio_codec="aac")
27
+
28
+ return output_path, transcript
29
+
30
+ demo = gr.Interface(fn=process_video,
31
+ inputs=gr.Textbox(label="YouTube URL"),
32
+ outputs=[gr.Video(label="Clip generado"), gr.Textbox(label="Transcripci贸n")])
33
+
34
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ gradio
2
+ openai-whisper
3
+ yt-dlp
4
+ moviepy
5
+ ffmpeg-python