Spaces:
Build error
Build error
Test 7
Browse files
app.py
CHANGED
|
@@ -295,28 +295,6 @@ def json_to_srt(transcription_json):
|
|
| 295 |
|
| 296 |
return '\n'.join(srt_lines)
|
| 297 |
|
| 298 |
-
def measure_response_time(func, *args, **kwargs):
|
| 299 |
-
start_time = time.time()
|
| 300 |
-
result = func(*args, **kwargs)
|
| 301 |
-
end_time = time.time()
|
| 302 |
-
response_time = end_time - start_time
|
| 303 |
-
return response_time, result
|
| 304 |
-
|
| 305 |
-
def measure_resource_usage(func, *args, **kwargs):
|
| 306 |
-
process = psutil.Process(os.getpid())
|
| 307 |
-
start_memory = process.memory_info().rss
|
| 308 |
-
start_cpu = process.cpu_percent(interval=None)
|
| 309 |
-
|
| 310 |
-
result = func(*args, **kwargs)
|
| 311 |
-
|
| 312 |
-
end_memory = process.memory_info().rss
|
| 313 |
-
end_cpu = process.cpu_percent(interval=None)
|
| 314 |
-
|
| 315 |
-
memory_usage = end_memory - start_memory
|
| 316 |
-
cpu_usage = end_cpu - start_cpu
|
| 317 |
-
|
| 318 |
-
return memory_usage, cpu_usage, result
|
| 319 |
-
|
| 320 |
|
| 321 |
def generate_subtitles(input_mode, input_file, link_input, prompt, language, auto_detect_language, model, include_video, font_selection, font_file, font_color, font_size, outline_thickness, outline_color):
|
| 322 |
if input_mode == "Upload Video/Audio File":
|
|
@@ -487,13 +465,6 @@ def generate_subtitles(input_mode, input_file, link_input, prompt, language, aut
|
|
| 487 |
except ValueError as e:
|
| 488 |
raise gr.Error(f"Error creating SRT file: {e}")
|
| 489 |
|
| 490 |
-
response_time, result = measure_response_time(generate_subtitles, input_mode, input_file, link_input, prompt, language, auto_detect_language, model, include_video, font_selection, font_file, font_color, font_size, outline_thickness, outline_color)
|
| 491 |
-
memory_usage, cpu_usage, result = measure_resource_usage(generate_subtitles, input_mode, input_file, link_input, prompt, language, auto_detect_language, model, include_video, font_selection, font_file, font_color, font_size, outline_thickness, outline_color)
|
| 492 |
-
|
| 493 |
-
print(f"Response Time: {response_time} seconds")
|
| 494 |
-
print(f"Memory Usage: {memory_usage} bytes")
|
| 495 |
-
print(f"CPU Usage: {cpu_usage} %")
|
| 496 |
-
|
| 497 |
|
| 498 |
theme = gr.themes.Soft(
|
| 499 |
primary_hue="sky",
|
|
|
|
| 295 |
|
| 296 |
return '\n'.join(srt_lines)
|
| 297 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 298 |
|
| 299 |
def generate_subtitles(input_mode, input_file, link_input, prompt, language, auto_detect_language, model, include_video, font_selection, font_file, font_color, font_size, outline_thickness, outline_color):
|
| 300 |
if input_mode == "Upload Video/Audio File":
|
|
|
|
| 465 |
except ValueError as e:
|
| 466 |
raise gr.Error(f"Error creating SRT file: {e}")
|
| 467 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 468 |
|
| 469 |
theme = gr.themes.Soft(
|
| 470 |
primary_hue="sky",
|