SPACERUNNER99 commited on
Commit
0dbdfb6
·
verified ·
1 Parent(s): e3167ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -284,8 +284,9 @@ def read_srt_file(file_path):
284
  print(f"An error occurred: {e}")
285
 
286
  def write_srt(subtitle_text, output_file="edited_srt.srt"):
287
- with open(output_file, 'w', encoding="utf-8") as file:
288
  file.write(subtitle_text)
 
289
 
290
  def clean_text(text):
291
  # Remove 'srt ' from the start of each line
@@ -386,7 +387,7 @@ def write_google(google_translate):
386
  google = "google_translate.srt"
387
  with open(google, 'a', encoding="utf-8") as f:
388
  f.write(google_translate)
389
-
390
  def time_to_seconds(time_obj):
391
  return time_obj.hours * 3600 + time_obj.minutes * 60 + time_obj.seconds + time_obj.milliseconds / 1000
392
 
@@ -446,8 +447,9 @@ def process_video(video, url, type):
446
  return srt, video, input_audio
447
 
448
  def video_edit(srt, input_video, input_audio= 'audio.mp3'):
449
- write_srt(srt)
450
- return input_video, 'edited_srt.srt'
 
451
  """ input_video_name = input_video.replace(''.mp4', '')
452
  video = VideoFileClip(input_video)
453
  audio = AudioFileClip(input_audio)
 
284
  print(f"An error occurred: {e}")
285
 
286
  def write_srt(subtitle_text, output_file="edited_srt.srt"):
287
+ with open(output_file+".srt", 'w', encoding="utf-8") as file:
288
  file.write(subtitle_text)
289
+ return output_file+".srt"
290
 
291
  def clean_text(text):
292
  # Remove 'srt ' from the start of each line
 
387
  google = "google_translate.srt"
388
  with open(google, 'a', encoding="utf-8") as f:
389
  f.write(google_translate)
390
+
391
  def time_to_seconds(time_obj):
392
  return time_obj.hours * 3600 + time_obj.minutes * 60 + time_obj.seconds + time_obj.milliseconds / 1000
393
 
 
447
  return srt, video, input_audio
448
 
449
  def video_edit(srt, input_video, input_audio= 'audio.mp3'):
450
+ input_video_name = input_video.replace(''.mp4', '')
451
+ srt_name=write_srt(srt, input_video_name)
452
+ return input_video, srt_name
453
  """ input_video_name = input_video.replace(''.mp4', '')
454
  video = VideoFileClip(input_video)
455
  audio = AudioFileClip(input_audio)