Spaces:
Running
Running
Revert "Adding txt support"
Browse filesThis reverts commit 697bf79931221a3b9059c9cb02c2781b3541083a.
- app.py +1 -1
- modules/subtitle_manager.py +0 -6
- modules/whisper_Inference.py +1 -7
app.py
CHANGED
@@ -44,7 +44,7 @@ class App:
|
|
44 |
label="Model")
|
45 |
dd_lang = gr.Dropdown(choices=["Automatic Detection"] + self.whisper_inf.available_langs,
|
46 |
value="Automatic Detection", label="Language")
|
47 |
-
dd_subformat = gr.Dropdown(["SRT", "WebVTT"
|
48 |
with gr.Row():
|
49 |
cb_translate = gr.Checkbox(value=False, label="Translate to English?", interactive=True)
|
50 |
with gr.Row():
|
|
|
44 |
label="Model")
|
45 |
dd_lang = gr.Dropdown(choices=["Automatic Detection"] + self.whisper_inf.available_langs,
|
46 |
value="Automatic Detection", label="Language")
|
47 |
+
dd_subformat = gr.Dropdown(["SRT", "WebVTT"], value="SRT", label="Subtitle Format")
|
48 |
with gr.Row():
|
49 |
cb_translate = gr.Checkbox(value=False, label="Translate to English?", interactive=True)
|
50 |
with gr.Row():
|
modules/subtitle_manager.py
CHANGED
@@ -21,12 +21,6 @@ def write_file(subtitle, output_file):
|
|
21 |
with open(output_file, 'w', encoding='utf-8') as f:
|
22 |
f.write(subtitle)
|
23 |
|
24 |
-
def get_txt(segments):
|
25 |
-
output = "txt\n\n"
|
26 |
-
for i, segment in enumerate(segments):
|
27 |
-
output += f"{segment['text']}\n\n"
|
28 |
-
return output
|
29 |
-
|
30 |
|
31 |
def get_srt(segments):
|
32 |
output = ""
|
|
|
21 |
with open(output_file, 'w', encoding='utf-8') as f:
|
22 |
f.write(subtitle)
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
def get_srt(segments):
|
26 |
output = ""
|
modules/whisper_Inference.py
CHANGED
@@ -4,7 +4,7 @@ import os
|
|
4 |
from datetime import datetime
|
5 |
|
6 |
from .base_interface import BaseInterface
|
7 |
-
from modules.subtitle_manager import get_srt, get_vtt,
|
8 |
from modules.youtube_manager import get_ytdata, get_ytaudio
|
9 |
|
10 |
DEFAULT_MODEL_SIZE = "large-v2"
|
@@ -91,9 +91,6 @@ class WhisperInference(BaseInterface):
|
|
91 |
elif subformat == "WebVTT":
|
92 |
subtitle = get_vtt(result["segments"])
|
93 |
write_file(subtitle, f"{output_path}.vtt")
|
94 |
-
else :
|
95 |
-
subtitle = get_txt(result["segments"])
|
96 |
-
write_file(subtitle, f"{output_path}.txt")
|
97 |
|
98 |
files_info[file_name] = subtitle
|
99 |
|
@@ -110,9 +107,6 @@ class WhisperInference(BaseInterface):
|
|
110 |
self.release_cuda_memory()
|
111 |
self.remove_input_files([fileobj.name for fileobj in fileobjs])
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
def transcribe_youtube(self,
|
117 |
youtubelink: str,
|
118 |
model_size: str,
|
|
|
4 |
from datetime import datetime
|
5 |
|
6 |
from .base_interface import BaseInterface
|
7 |
+
from modules.subtitle_manager import get_srt, get_vtt, write_file, safe_filename
|
8 |
from modules.youtube_manager import get_ytdata, get_ytaudio
|
9 |
|
10 |
DEFAULT_MODEL_SIZE = "large-v2"
|
|
|
91 |
elif subformat == "WebVTT":
|
92 |
subtitle = get_vtt(result["segments"])
|
93 |
write_file(subtitle, f"{output_path}.vtt")
|
|
|
|
|
|
|
94 |
|
95 |
files_info[file_name] = subtitle
|
96 |
|
|
|
107 |
self.release_cuda_memory()
|
108 |
self.remove_input_files([fileobj.name for fileobj in fileobjs])
|
109 |
|
|
|
|
|
|
|
110 |
def transcribe_youtube(self,
|
111 |
youtubelink: str,
|
112 |
model_size: str,
|