Files changed (1) hide show
  1. app.py +14 -16
app.py CHANGED
@@ -17,7 +17,9 @@ import spaces
17
  # Constants and initialization
18
  HF_TOKEN = os.environ.get("HF_TOKEN")
19
  REPO_ID = "artificialguybr/video-dubbing"
20
- MAX_VIDEO_DURATION = 60 # seconds
 
 
21
 
22
  api = HfApi(token=HF_TOKEN)
23
 
@@ -60,6 +62,10 @@ def cleanup_files(*files):
60
  os.remove(file)
61
  print(f"Removed file: {file}")
62
 
 
 
 
 
63
  @spaces.GPU(duration=90)
64
  def transcribe_audio(file_path):
65
  print(f"Starting transcription of file: {file_path}")
@@ -116,6 +122,8 @@ def process_video(video, target_language, use_wav2lip):
116
  try:
117
  if target_language is None:
118
  raise ValueError("Please select a Target Language for Dubbing.")
 
 
119
 
120
  run_uuid = uuid.uuid4().hex[:6]
121
  output_filename = f"{run_uuid}_resized_video.mp4"
@@ -177,8 +185,8 @@ def process_video(video, target_language, use_wav2lip):
177
  # Gradio interface setup
178
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
179
  gr.Markdown("# AI Video Dubbing")
180
- gr.Markdown("This tool uses AI to dub videos into different languages. Upload a video, choose a target language, and get a dubbed version!")
181
-
182
  with gr.Row():
183
  with gr.Column(scale=2):
184
  video_input = gr.Video(label="Upload Video")
@@ -206,19 +214,9 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
206
 
207
  gr.Markdown("""
208
  ## Notes:
209
- - Video limit is 1 minute. The tool will dub all speakers using a single voice.
210
- - Processing may take up to 5 minutes.
211
- - This is an alpha version using open-source models.
212
- - Quality vs. speed trade-off was made for scalability and hardware limitations.
213
- - For videos longer than 1 minute, please duplicate this Space and adjust the limit in the code.
214
- """)
215
-
216
- gr.Markdown("""
217
- ---
218
- Developed by [@artificialguybr](https://twitter.com/artificialguybr) using open-source tools.
219
- Special thanks to Hugging Face for GPU support and [@yeswondwer](https://twitter.com/@yeswondwerr) for the original code.
220
-
221
- Try our [Video Transcription and Translation](https://huggingface.co/spaces/artificialguybr/VIDEO-TRANSLATION-TRANSCRIPTION) tool!
222
  """)
223
 
224
  print("Launching Gradio interface...")
 
17
  # Constants and initialization
18
  HF_TOKEN = os.environ.get("HF_TOKEN")
19
  REPO_ID = "artificialguybr/video-dubbing"
20
+
21
+ MAX_VIDEO_DURATION = 900 # 15 minutes
22
+ MAX_FILE_SIZE = 1073741824 # 1GB
23
 
24
  api = HfApi(token=HF_TOKEN)
25
 
 
62
  os.remove(file)
63
  print(f"Removed file: {file}")
64
 
65
+ def validate_file_size(video_path):
66
+ if os.path.getsize(video_path) > MAX_FILE_SIZE:
67
+ raise ValueError(f"File size exceeds 1GB limit. Please upload a smaller file.")
68
+
69
  @spaces.GPU(duration=90)
70
  def transcribe_audio(file_path):
71
  print(f"Starting transcription of file: {file_path}")
 
122
  try:
123
  if target_language is None:
124
  raise ValueError("Please select a Target Language for Dubbing.")
125
+
126
+ validate_file_size(video) # Validate file size first
127
 
128
  run_uuid = uuid.uuid4().hex[:6]
129
  output_filename = f"{run_uuid}_resized_video.mp4"
 
185
  # Gradio interface setup
186
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
187
  gr.Markdown("# AI Video Dubbing")
188
+ gr.Markdown("Upload a video (up to 15 minutes and 1GB), choose a target language, and get a dubbed version!")
189
+
190
  with gr.Row():
191
  with gr.Column(scale=2):
192
  video_input = gr.Video(label="Upload Video")
 
214
 
215
  gr.Markdown("""
216
  ## Notes:
217
+ - Video limit: 15 minutes, 1GB file size.
218
+ - Processing may take several minutes depending on length.
219
+ - Developed using open-source models and tools.
 
 
 
 
 
 
 
 
 
 
220
  """)
221
 
222
  print("Launching Gradio interface...")