artificialguybr commited on
Commit
6783c16
1 Parent(s): 6312799

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -31,9 +31,18 @@ model_size = "small"
31
  model = WhisperModel(model_size, device="cuda", compute_type="int8")
32
 
33
  def process_video(radio, video, target_language):
34
- # Check video duration
35
- video_info = ffmpeg.probe(video)
36
- video_duration = float(video_info['streams'][0]['duration'])
 
 
 
 
 
 
 
 
 
37
  if video_duration > 90:
38
  return gr.Interface.Warnings("Video duration exceeds 1 minute and 30 seconds. Please upload a shorter video.")
39
  if target_language is None:
@@ -148,5 +157,5 @@ with gr.Blocks() as demo:
148
  - Quality can be improved but would require more processing time per video. For scalability and hardware limitations, speed was chosen, not just quality.
149
  - If you need more than 1 minute, duplicate the Space and change the limit on app.py.
150
  """)
151
- demo.queue(concurrency_count=2, max_size=15)
152
  demo.launch()
 
31
  model = WhisperModel(model_size, device="cuda", compute_type="int8")
32
 
33
  def process_video(radio, video, target_language):
34
+ video_duration = 0.0
35
+ if radio == "Upload":
36
+ video_info = ffmpeg.probe(video)
37
+ if 'duration' in video_info['streams'][0]:
38
+ video_duration = float(video_info['streams'][0]['duration'])
39
+ else: # Handle webcam video
40
+ try:
41
+ video_info = ffmpeg.probe(video)
42
+ print("Webcam Video Info:", video_info)
43
+ except Exception as e:
44
+ print("Error probing webcam video:", e)
45
+
46
  if video_duration > 90:
47
  return gr.Interface.Warnings("Video duration exceeds 1 minute and 30 seconds. Please upload a shorter video.")
48
  if target_language is None:
 
157
  - Quality can be improved but would require more processing time per video. For scalability and hardware limitations, speed was chosen, not just quality.
158
  - If you need more than 1 minute, duplicate the Space and change the limit on app.py.
159
  """)
160
+ demo.queue(concurrency_count=1, max_size=15)
161
  demo.launch()