SPACERUNNER99 commited on
Commit
369ad25
·
verified ·
1 Parent(s): 115a03f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -24
app.py CHANGED
@@ -8,22 +8,19 @@ import gradio as gr
8
  def main(url, parameters, progress=gr.Progress()):
9
  try:
10
  font_type, font_size, font_color, service, target, style, subject = parameters.split(',')
11
-
12
  progress(0, desc="پردازش شروع شد")
13
  yield "پردازش شروع شد", None
14
 
15
- # Transcription Stage - Updated API endpoint
16
  progress(0.35, desc="تبدیل صوت به متن")
17
  yield "تبدیل صوت به متن", None
18
 
19
- transcribe_client = Client("rayesh/transcribe")
20
  try:
21
- # Changed to use default API name
22
- job = transcribe_client.submit(url)
23
  while not job.done():
24
  time.sleep(0.5)
25
- progress(0.35, desc="تبدیل صوت به متن")
26
-
27
  results = job.outputs()[0]
28
  print(results)
29
  if len(results) != 3:
@@ -33,41 +30,41 @@ def main(url, parameters, progress=gr.Progress()):
33
  finally:
34
  transcribe_client.close()
35
 
36
- # Translation Stage - Updated API endpoint
37
  progress(0.55, desc="در حال ترجمه")
38
  yield "در حال ترجمه", None
39
 
40
- translate_client = Client("rayesh/translate")
41
  try:
42
- # Changed to use default API name
43
- job = translate_client.submit(results[0], target)
 
 
 
44
  while not job.done():
45
- time.sleep(0.5)
46
- progress(0.55, desc="در حال ترجمه")
47
-
48
- translated_text = job.outputs()[0]
49
  finally:
50
  translate_client.close()
51
 
52
- # Video Processing Stage - Updated API endpoint
53
  progress(0.75, desc="پردازش ویدئو")
54
  yield "درحال پردازش ویدئو", None
55
 
56
- video_client = Client("SPACERUNNER99/video_edite")
57
  try:
58
- # Changed API name to match typical video processing endpoints
59
  job = video_client.submit(
60
- url,
61
- translated_text,
 
62
  font_type,
63
  font_size,
64
- font_color,
65
- api_name="/process" # Changed to common endpoint name
66
  )
67
  while not job.done():
68
  time.sleep(0.5)
69
- progress(0.75, desc="پردازش ویدئو")
70
-
71
  output_video = job.outputs()[0]['video']
72
 
73
 
 
8
  def main(url, parameters, progress=gr.Progress()):
9
  try:
10
  font_type, font_size, font_color, service, target, style, subject = parameters.split(',')
 
11
  progress(0, desc="پردازش شروع شد")
12
  yield "پردازش شروع شد", None
13
 
14
+ # Transcription Stage
15
  progress(0.35, desc="تبدیل صوت به متن")
16
  yield "تبدیل صوت به متن", None
17
 
18
+ transcribe_client = Client("kavehtaheri/transcribe")
19
  try:
20
+ job = transcribe_client.submit(url, api_name="/transcribe")
 
21
  while not job.done():
22
  time.sleep(0.5)
23
+
 
24
  results = job.outputs()[0]
25
  print(results)
26
  if len(results) != 3:
 
30
  finally:
31
  transcribe_client.close()
32
 
33
+ # Translation Stage
34
  progress(0.55, desc="در حال ترجمه")
35
  yield "در حال ترجمه", None
36
 
37
+ translate_client = Client("kavehtaheri/translate")
38
  try:
39
+ job = translate_client.submit(
40
+ handle_file(srt_file),
41
+ 3000,
42
+ api_name="/translate"
43
+ )
44
  while not job.done():
45
+ time.sleep(0.3)
46
+ subtitle_file = job.outputs()[0]
 
 
47
  finally:
48
  translate_client.close()
49
 
50
+ # Video Processing Stage
51
  progress(0.75, desc="پردازش ویدئو")
52
  yield "درحال پردازش ویدئو", None
53
 
54
+ video_client = Client("kavehtaheri/video_edite")
55
  try:
 
56
  job = video_client.submit(
57
+ handle_file(subtitle_file),
58
+ {"video": handle_file(video["video"])},
59
+ font_color,
60
  font_type,
61
  font_size,
62
+ handle_file(mp3_file),
63
+ api_name="/video_edit"
64
  )
65
  while not job.done():
66
  time.sleep(0.5)
67
+
 
68
  output_video = job.outputs()[0]['video']
69
 
70