Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import gradio as gr
|
|
3 |
import time
|
4 |
from moviepy.editor import VideoFileClip
|
5 |
from faster_whisper import WhisperModel
|
|
|
6 |
|
7 |
# λΉλμ€λ₯Ό MP3λ‘ λ³ννλ ν¨μ
|
8 |
def convert_mp4_to_mp3(video_file_path, output_dir):
|
@@ -38,10 +39,17 @@ def transcribe_audio(model_size, audio_file):
|
|
38 |
|
39 |
return f"{detected_language}\n\nTranscription:\n{result_text}\n\nElapsed time: {elapsed_time:.2f} seconds"
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
# Gradio μΈν°νμ΄μ€μμ μ¬μ©ν λ©μΈ ν¨μ
|
42 |
def process_video(model_size, video_file=None, video_url=None):
|
43 |
if video_url and not video_file:
|
44 |
-
video_file_path =
|
45 |
elif video_file and not video_url:
|
46 |
video_file_path = video_file.name
|
47 |
else:
|
|
|
3 |
import time
|
4 |
from moviepy.editor import VideoFileClip
|
5 |
from faster_whisper import WhisperModel
|
6 |
+
from pytube import YouTube
|
7 |
|
8 |
# λΉλμ€λ₯Ό MP3λ‘ λ³ννλ ν¨μ
|
9 |
def convert_mp4_to_mp3(video_file_path, output_dir):
|
|
|
39 |
|
40 |
return f"{detected_language}\n\nTranscription:\n{result_text}\n\nElapsed time: {elapsed_time:.2f} seconds"
|
41 |
|
42 |
+
# YouTube URLμμ λΉλμ€λ₯Ό λ€μ΄λ‘λνλ ν¨μ
|
43 |
+
def download_youtube_video(url, output_dir):
|
44 |
+
yt = YouTube(url)
|
45 |
+
stream = yt.streams.filter(file_extension='mp4').first()
|
46 |
+
output_path = stream.download(output_dir)
|
47 |
+
return output_path
|
48 |
+
|
49 |
# Gradio μΈν°νμ΄μ€μμ μ¬μ©ν λ©μΈ ν¨μ
|
50 |
def process_video(model_size, video_file=None, video_url=None):
|
51 |
if video_url and not video_file:
|
52 |
+
video_file_path = download_youtube_video(video_url, '/tmp')
|
53 |
elif video_file and not video_url:
|
54 |
video_file_path = video_file.name
|
55 |
else:
|