Spaces:
Running
Running
jhj0517
commited on
Commit
•
40f2b57
1
Parent(s):
6f0e822
removed redundant function
Browse files
modules/subtitle_manager.py
CHANGED
@@ -17,12 +17,7 @@ def timeformat_vtt(time):
|
|
17 |
return f"{int(hours):02d}:{int(minutes):02d}:{int(seconds):02d}.{int(milliseconds):03d}"
|
18 |
|
19 |
|
20 |
-
def
|
21 |
-
with open(output_file, 'w', encoding='utf-8') as f:
|
22 |
-
f.write(subtitle)
|
23 |
-
|
24 |
-
|
25 |
-
def write_vtt(subtitle, output_file):
|
26 |
with open(output_file, 'w', encoding='utf-8') as f:
|
27 |
f.write(subtitle)
|
28 |
|
|
|
17 |
return f"{int(hours):02d}:{int(minutes):02d}:{int(seconds):02d}.{int(milliseconds):03d}"
|
18 |
|
19 |
|
20 |
+
def write_file(subtitle, output_file):
|
|
|
|
|
|
|
|
|
|
|
21 |
with open(output_file, 'w', encoding='utf-8') as f:
|
22 |
f.write(subtitle)
|
23 |
|
modules/whisper_Inference.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import whisper
|
2 |
-
from modules.subtitle_manager import get_srt, get_vtt,
|
3 |
from modules.youtube_manager import get_ytdata, get_ytaudio
|
4 |
import gradio as gr
|
5 |
import os
|
@@ -56,10 +56,10 @@ class WhisperInference:
|
|
56 |
|
57 |
if subformat == "SRT":
|
58 |
subtitle = get_srt(result["segments"])
|
59 |
-
|
60 |
elif subformat == "WebVTT":
|
61 |
subtitle = get_vtt(result["segments"])
|
62 |
-
|
63 |
|
64 |
files_info[file_name] = subtitle
|
65 |
|
@@ -106,10 +106,10 @@ class WhisperInference:
|
|
106 |
|
107 |
if subformat == "SRT":
|
108 |
subtitle = get_srt(result["segments"])
|
109 |
-
|
110 |
elif subformat == "WebVTT":
|
111 |
subtitle = get_vtt(result["segments"])
|
112 |
-
|
113 |
|
114 |
return f"Done! Subtitle file is in the outputs folder.\n\n{subtitle}"
|
115 |
|
@@ -145,9 +145,9 @@ class WhisperInference:
|
|
145 |
|
146 |
if subformat == "SRT":
|
147 |
subtitle = get_srt(result["segments"])
|
148 |
-
|
149 |
elif subformat == "WebVTT":
|
150 |
subtitle = get_vtt(result["segments"])
|
151 |
-
|
152 |
|
153 |
return f"Done! Subtitle file is in the outputs folder.\n\n{subtitle}"
|
|
|
1 |
import whisper
|
2 |
+
from modules.subtitle_manager import get_srt, get_vtt, write_file, safe_filename
|
3 |
from modules.youtube_manager import get_ytdata, get_ytaudio
|
4 |
import gradio as gr
|
5 |
import os
|
|
|
56 |
|
57 |
if subformat == "SRT":
|
58 |
subtitle = get_srt(result["segments"])
|
59 |
+
write_file(subtitle, f"{output_path}.srt")
|
60 |
elif subformat == "WebVTT":
|
61 |
subtitle = get_vtt(result["segments"])
|
62 |
+
write_file(subtitle, f"{output_path}.vtt")
|
63 |
|
64 |
files_info[file_name] = subtitle
|
65 |
|
|
|
106 |
|
107 |
if subformat == "SRT":
|
108 |
subtitle = get_srt(result["segments"])
|
109 |
+
write_file(subtitle, f"{output_path}.srt")
|
110 |
elif subformat == "WebVTT":
|
111 |
subtitle = get_vtt(result["segments"])
|
112 |
+
write_file(subtitle, f"{output_path}.vtt")
|
113 |
|
114 |
return f"Done! Subtitle file is in the outputs folder.\n\n{subtitle}"
|
115 |
|
|
|
145 |
|
146 |
if subformat == "SRT":
|
147 |
subtitle = get_srt(result["segments"])
|
148 |
+
write_file(subtitle, f"{output_path}.srt")
|
149 |
elif subformat == "WebVTT":
|
150 |
subtitle = get_vtt(result["segments"])
|
151 |
+
write_file(subtitle, f"{output_path}.vtt")
|
152 |
|
153 |
return f"Done! Subtitle file is in the outputs folder.\n\n{subtitle}"
|