Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,8 @@
|
|
1 |
-
from transcribe import transcribe
|
2 |
from moviepy import VideoFileClip
|
3 |
-
from translate import translate
|
4 |
-
from edite_video import video_edit
|
5 |
import gradio as gr
|
6 |
import requests
|
7 |
import os
|
8 |
-
from
|
9 |
-
|
10 |
|
11 |
def extract_audio(input_video_name):
|
12 |
# Define the input video file and output audio file
|
@@ -49,22 +45,30 @@ def main(url, clip_type, parameters, progress=gr.Progress()):
|
|
49 |
if clip_type == "dub":
|
50 |
progress(0, desc="پردازش شروع شد")
|
51 |
yield "پردازش شروع شد", None
|
52 |
-
|
53 |
-
|
54 |
progress(5, desc="در حال دریافت ویدئو")
|
55 |
yield "در حال دریافت ویدئو", None
|
|
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
srt_list = transcribe(mp3_file)
|
62 |
progress(35, desc="تبدیل متن به صوت")
|
63 |
yield "تبدیل متن به صوت", None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
-
subtitle_file = translate(srt_list)
|
66 |
progress(55, desc="در حال ترجمه")
|
67 |
yield "در حال ترجمه", None
|
|
|
|
|
68 |
|
69 |
output_video_file = dub(subtitle_file, video)
|
70 |
progress(100, desc="Dubbing complete")
|
@@ -77,27 +81,45 @@ def main(url, clip_type, parameters, progress=gr.Progress()):
|
|
77 |
progress(0, desc="پردازش شروع شد")
|
78 |
yield "پردازش شروع شد", None
|
79 |
|
80 |
-
|
81 |
-
progress(5, desc="در حال دریافت ویدئو")
|
82 |
yield "در حال دریافت ویدئو", None
|
|
|
83 |
|
84 |
-
mp3_file, duration = extract_audio(video)
|
85 |
progress(10, desc="استخراج صوت")
|
86 |
yield "استخراج صوت", None
|
|
|
87 |
|
88 |
-
|
89 |
-
progress(35, desc="تبدیل متن به صوت")
|
90 |
yield "تبدیل متن به صوت", None
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
-
|
93 |
-
progress(55, desc="در حال ترجمه")
|
94 |
yield "در حال ترجمه", None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
-
|
97 |
-
output_video_file = video_edit(subtitle_file, video, color, font, input_audio="audio.mp3")
|
98 |
-
progress(100, desc="Video editing complete")
|
99 |
yield "درحال پردازش ویدئو", output_video_file
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
|
103 |
with gr.Blocks() as demo:
|
|
|
|
|
1 |
from moviepy import VideoFileClip
|
|
|
|
|
2 |
import gradio as gr
|
3 |
import requests
|
4 |
import os
|
5 |
+
from gradio_client import Client, handle_file
|
|
|
6 |
|
7 |
def extract_audio(input_video_name):
|
8 |
# Define the input video file and output audio file
|
|
|
45 |
if clip_type == "dub":
|
46 |
progress(0, desc="پردازش شروع شد")
|
47 |
yield "پردازش شروع شد", None
|
48 |
+
time.sleep(2)
|
49 |
+
|
50 |
progress(5, desc="در حال دریافت ویدئو")
|
51 |
yield "در حال دریافت ویدئو", None
|
52 |
+
video = download_video(url)
|
53 |
|
54 |
+
#progress(10, desc="استخراج صوت")
|
55 |
+
#yield "استخراج صوت", None
|
56 |
+
#mp3_file, duration = extract_audio(video)
|
57 |
+
|
|
|
58 |
progress(35, desc="تبدیل متن به صوت")
|
59 |
yield "تبدیل متن به صوت", None
|
60 |
+
client = Client("rayesh/transcribe")
|
61 |
+
srt_file = client.predict(
|
62 |
+
mp3_file=handle_file(video),
|
63 |
+
api_name="/transcribe"
|
64 |
+
)
|
65 |
+
client.close()
|
66 |
+
|
67 |
|
|
|
68 |
progress(55, desc="در حال ترجمه")
|
69 |
yield "در حال ترجمه", None
|
70 |
+
subtitle_file = translate(srt_file)
|
71 |
+
|
72 |
|
73 |
output_video_file = dub(subtitle_file, video)
|
74 |
progress(100, desc="Dubbing complete")
|
|
|
81 |
progress(0, desc="پردازش شروع شد")
|
82 |
yield "پردازش شروع شد", None
|
83 |
|
84 |
+
progress(0.05, desc="در حال دریافت ویدئو")
|
|
|
85 |
yield "در حال دریافت ویدئو", None
|
86 |
+
video = download_video(url)
|
87 |
|
|
|
88 |
progress(10, desc="استخراج صوت")
|
89 |
yield "استخراج صوت", None
|
90 |
+
mp3_file, duration = extract_audio(video)
|
91 |
|
92 |
+
progress(0.35, desc="تبدیل متن به صوت")
|
|
|
93 |
yield "تبدیل متن به صوت", None
|
94 |
+
client = Client("rayesh/transcribe")
|
95 |
+
srt_file = client.predict(
|
96 |
+
mp3_file=handle_file(mp3_file),
|
97 |
+
api_name="/transcribe"
|
98 |
+
)
|
99 |
+
client.close()
|
100 |
|
101 |
+
progress(0.55, desc="در حال ترجمه")
|
|
|
102 |
yield "در حال ترجمه", None
|
103 |
+
Client("rayesh/translate")
|
104 |
+
subtitle_file = client.predict(
|
105 |
+
file=handle_file(srt_file),
|
106 |
+
max_chars=3000,
|
107 |
+
api_name="/translate"
|
108 |
+
)
|
109 |
+
client.close()
|
110 |
|
111 |
+
progress(1.0, desc="Video editing complete")
|
|
|
|
|
112 |
yield "درحال پردازش ویدئو", output_video_file
|
113 |
+
client = Client("SPACERUNNER99/video_edite")
|
114 |
+
output_video_file = client.predict(
|
115 |
+
srt=handle_file(subtitle_file),
|
116 |
+
input_video={"video":handle_file(video)},
|
117 |
+
color=color,
|
118 |
+
font=font,
|
119 |
+
audio_in=mp3_file,
|
120 |
+
api_name="/video_edit"
|
121 |
+
)
|
122 |
+
client.close()
|
123 |
|
124 |
|
125 |
with gr.Blocks() as demo:
|