multimodalart HF Staff commited on
Commit
f2de2c9
·
1 Parent(s): 2959fbb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -49,18 +49,24 @@ def process_video(Video, target_language):
49
  with open(transcript_file, "w+", encoding="utf-8") as f:
50
  counter = 1
51
  for segment in segments:
52
- start_minutes = int(segment.start // 60)
 
53
  start_seconds = int(segment.start % 60)
54
  start_milliseconds = int((segment.start - int(segment.start)) * 1000)
55
- end_minutes = int(segment.end // 60)
 
 
56
  end_seconds = int(segment.end % 60)
57
  end_milliseconds = int((segment.end - int(segment.end)) * 1000)
58
- formatted_start = f"{start_minutes:02d}:{start_seconds:02d},{start_milliseconds:03d}"
59
- formatted_end = f"{end_minutes:02d}:{end_seconds:02d},{end_milliseconds:03d}"
 
 
60
  f.write(f"{counter}\n")
61
  f.write(f"{formatted_start} --> {formatted_end}\n")
62
  f.write(f"{segment.text}\n\n")
63
  counter += 1
 
64
 
65
  # Move the file pointer to the beginning of the file.
66
  f.seek(0)
@@ -107,10 +113,10 @@ def process_video(Video, target_language):
107
  except Exception as e:
108
  print(f"Ocorreu uma exceção: {e}")
109
  print("process_video concluído com sucesso")
110
- #os.unlink(audio_file)
111
- #os.unlink(transcript_file)
112
 
113
- return output_video, None
114
 
115
  iface = gr.Interface(
116
  fn=process_video,
@@ -120,7 +126,7 @@ iface = gr.Interface(
120
  ],
121
  outputs=[
122
  gr.Video(),
123
- gr.FileExplorer()
124
  ],
125
  live=False,
126
  title="VIDEO TRANSCRIPTION AND TRANSLATION"
 
49
  with open(transcript_file, "w+", encoding="utf-8") as f:
50
  counter = 1
51
  for segment in segments:
52
+ start_hours = int(segment.start // 3600)
53
+ start_minutes = int((segment.start % 3600) // 60)
54
  start_seconds = int(segment.start % 60)
55
  start_milliseconds = int((segment.start - int(segment.start)) * 1000)
56
+
57
+ end_hours = int(segment.end // 3600)
58
+ end_minutes = int((segment.end % 3600) // 60)
59
  end_seconds = int(segment.end % 60)
60
  end_milliseconds = int((segment.end - int(segment.end)) * 1000)
61
+
62
+ formatted_start = f"{start_hours:02d}:{start_minutes:02d}:{start_seconds:02d},{start_milliseconds:03d}"
63
+ formatted_end = f"{end_hours:02d}:{end_minutes:02d}:{end_seconds:02d},{end_milliseconds:03d}"
64
+
65
  f.write(f"{counter}\n")
66
  f.write(f"{formatted_start} --> {formatted_end}\n")
67
  f.write(f"{segment.text}\n\n")
68
  counter += 1
69
+
70
 
71
  # Move the file pointer to the beginning of the file.
72
  f.seek(0)
 
113
  except Exception as e:
114
  print(f"Ocorreu uma exceção: {e}")
115
  print("process_video concluído com sucesso")
116
+ os.unlink(audio_file)
117
+ os.unlink(transcript_file)
118
 
119
+ return output_video
120
 
121
  iface = gr.Interface(
122
  fn=process_video,
 
126
  ],
127
  outputs=[
128
  gr.Video(),
129
+ #gr.FileExplorer()
130
  ],
131
  live=False,
132
  title="VIDEO TRANSCRIPTION AND TRANSLATION"