Spaces:
Build error
Build error
Resolved the transProcessor deletion issue causing an exception in TranslationModel.py for release_vram.
Browse files- app.py +108 -186
- src/translation/translationModel.py +1 -1
app.py
CHANGED
|
@@ -114,22 +114,11 @@ class WhisperTranscriber:
|
|
| 114 |
self.diarization.cleanup()
|
| 115 |
self.diarization_kwargs = None
|
| 116 |
|
| 117 |
-
# Entry function for the simple tab, Queue mode disabled: progress bars will not be shown
|
| 118 |
-
def
|
| 119 |
-
|
| 120 |
-
# Entry function for the simple tab progress, Progress tracking requires queuing to be enabled
|
| 121 |
-
def transcribe_webui_simple_progress(self, data: dict, progress=gr.Progress()):
|
| 122 |
-
dataDict = {}
|
| 123 |
-
for key, value in data.items():
|
| 124 |
-
dataDict.update({key.elem_id: value})
|
| 125 |
-
|
| 126 |
-
return self.transcribe_webui(dataDict, progress=progress)
|
| 127 |
-
|
| 128 |
-
# Entry function for the full tab, Queue mode disabled: progress bars will not be shown
|
| 129 |
-
def transcribe_webui_full(self, data: dict): return self.transcribe_webui_full_progress(data)
|
| 130 |
|
| 131 |
-
# Entry function for the full tab with progress, Progress tracking requires queuing to be enabled
|
| 132 |
-
def
|
| 133 |
dataDict = {}
|
| 134 |
for key, value in data.items():
|
| 135 |
dataDict.update({key.elem_id: value})
|
|
@@ -1043,182 +1032,115 @@ def create_ui(app_config: ApplicationConfig):
|
|
| 1043 |
|
| 1044 |
is_queue_mode = app_config.queue_concurrency_count is not None and app_config.queue_concurrency_count > 0
|
| 1045 |
|
| 1046 |
-
|
| 1047 |
-
|
| 1048 |
-
|
| 1049 |
-
|
| 1050 |
-
|
| 1051 |
-
|
| 1052 |
-
with gr.Row():
|
| 1053 |
-
with gr.Column():
|
| 1054 |
-
simpleSubmit = gr.Button("Submit", variant="primary")
|
| 1055 |
with gr.Column():
|
| 1056 |
-
|
| 1057 |
-
|
| 1058 |
-
with gr.Tab(label="M2M100") as simpleM2M100Tab:
|
| 1059 |
-
with gr.Row():
|
| 1060 |
-
simpleInputDict.update(common_m2m100_inputs())
|
| 1061 |
-
with gr.Tab(label="NLLB") as simpleNllbTab:
|
| 1062 |
-
with gr.Row():
|
| 1063 |
-
simpleInputDict.update(common_nllb_inputs())
|
| 1064 |
-
with gr.Tab(label="MT5") as simpleMT5Tab:
|
| 1065 |
-
with gr.Row():
|
| 1066 |
-
simpleInputDict.update(common_mt5_inputs())
|
| 1067 |
-
with gr.Tab(label="ALMA") as simpleALMATab:
|
| 1068 |
-
with gr.Row():
|
| 1069 |
-
simpleInputDict.update(common_ALMA_inputs())
|
| 1070 |
-
with gr.Tab(label="madlad400") as simpleMadlad400Tab:
|
| 1071 |
-
with gr.Row():
|
| 1072 |
-
simpleInputDict.update(common_madlad400_inputs())
|
| 1073 |
-
with gr.Tab(label="seamless") as simpleSeamlessTab:
|
| 1074 |
with gr.Row():
|
| 1075 |
-
|
| 1076 |
-
|
| 1077 |
-
|
| 1078 |
-
|
| 1079 |
-
|
| 1080 |
-
|
| 1081 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1082 |
with gr.Column():
|
| 1083 |
-
|
| 1084 |
-
|
| 1085 |
-
|
| 1086 |
-
|
| 1087 |
-
|
| 1088 |
-
|
| 1089 |
-
|
| 1090 |
-
|
| 1091 |
-
|
| 1092 |
-
|
| 1093 |
-
|
| 1094 |
-
|
| 1095 |
-
|
| 1096 |
-
|
| 1097 |
-
|
| 1098 |
-
|
| 1099 |
-
|
| 1100 |
-
simpleInputDict.update(common_diarization_inputs())
|
| 1101 |
-
with gr.Accordion("Translation options", open=False):
|
| 1102 |
-
simpleInputDict.update(common_translation_inputs())
|
| 1103 |
-
with gr.Column():
|
| 1104 |
-
simpleOutput = common_output()
|
| 1105 |
-
gr.Markdown(uiArticle)
|
| 1106 |
-
if optionsMd is not None:
|
| 1107 |
-
with gr.Accordion("docs/options.md", open=False):
|
| 1108 |
-
gr.Markdown(optionsMd)
|
| 1109 |
-
if translateModelMd is not None:
|
| 1110 |
-
with gr.Accordion("docs/translateModel.md", open=False):
|
| 1111 |
-
gr.Markdown(translateModelMd)
|
| 1112 |
-
if readmeMd is not None:
|
| 1113 |
-
with gr.Accordion("README.md", open=False):
|
| 1114 |
-
gr.Markdown(readmeMd)
|
| 1115 |
-
|
| 1116 |
-
simpleInputDict.update({simpleTranslateInput, simpleSourceInput})
|
| 1117 |
-
simpleSubmit.click(fn=ui.transcribe_webui_simple_progress if is_queue_mode else ui.transcribe_webui_simple,
|
| 1118 |
-
inputs=simpleInputDict, outputs=simpleOutput)
|
| 1119 |
|
| 1120 |
-
|
| 1121 |
fullDescription = uiDescription + "\n\n\n\n" + "Be careful when changing some of the options in the full interface - this can cause the model to crash."
|
| 1122 |
-
|
| 1123 |
-
with gr.Blocks() as fullTranscribe:
|
| 1124 |
-
fullTranslateInput = gr.State(value="m2m100", elem_id = "translateInput")
|
| 1125 |
-
fullSourceInput = gr.State(value="urlData", elem_id = "sourceInput")
|
| 1126 |
-
gr.Markdown(fullDescription)
|
| 1127 |
-
with gr.Row():
|
| 1128 |
-
with gr.Column():
|
| 1129 |
-
fullSubmit = gr.Button("Submit", variant="primary")
|
| 1130 |
-
with gr.Column():
|
| 1131 |
-
with gr.Row():
|
| 1132 |
-
fullInputDict = common_whisper_inputs()
|
| 1133 |
-
with gr.Tab(label="M2M100") as fullM2M100Tab:
|
| 1134 |
-
with gr.Row():
|
| 1135 |
-
fullInputDict.update(common_m2m100_inputs())
|
| 1136 |
-
with gr.Tab(label="NLLB") as fullNllbTab:
|
| 1137 |
-
with gr.Row():
|
| 1138 |
-
fullInputDict.update(common_nllb_inputs())
|
| 1139 |
-
with gr.Tab(label="MT5") as fullMT5Tab:
|
| 1140 |
-
with gr.Row():
|
| 1141 |
-
fullInputDict.update(common_mt5_inputs())
|
| 1142 |
-
with gr.Tab(label="ALMA") as fullALMATab:
|
| 1143 |
-
with gr.Row():
|
| 1144 |
-
fullInputDict.update(common_ALMA_inputs())
|
| 1145 |
-
with gr.Tab(label="madlad400") as fullMadlad400Tab:
|
| 1146 |
-
with gr.Row():
|
| 1147 |
-
fullInputDict.update(common_madlad400_inputs())
|
| 1148 |
-
with gr.Tab(label="seamless") as fullSeamlessTab:
|
| 1149 |
-
with gr.Row():
|
| 1150 |
-
fullInputDict.update(common_seamless_inputs())
|
| 1151 |
-
fullM2M100Tab.select(fn=lambda: "m2m100", inputs = [], outputs= [fullTranslateInput] )
|
| 1152 |
-
fullNllbTab.select(fn=lambda: "nllb", inputs = [], outputs= [fullTranslateInput] )
|
| 1153 |
-
fullMT5Tab.select(fn=lambda: "mt5", inputs = [], outputs= [fullTranslateInput] )
|
| 1154 |
-
fullALMATab.select(fn=lambda: "ALMA", inputs = [], outputs= [fullTranslateInput] )
|
| 1155 |
-
fullMadlad400Tab.select(fn=lambda: "madlad400", inputs = [], outputs= [fullTranslateInput] )
|
| 1156 |
-
fullSeamlessTab.select(fn=lambda: "seamless", inputs = [], outputs= [fullTranslateInput] )
|
| 1157 |
-
with gr.Column():
|
| 1158 |
-
with gr.Tab(label="URL") as fullUrlTab:
|
| 1159 |
-
fullInputDict.update({gr.Text(label="URL (YouTube, etc.)", elem_id = "urlData")})
|
| 1160 |
-
with gr.Tab(label="Upload") as fullUploadTab:
|
| 1161 |
-
fullInputDict.update({gr.File(label="Upload Files", file_count="multiple", elem_id = "multipleFiles")})
|
| 1162 |
-
with gr.Tab(label="Microphone") as fullMicTab:
|
| 1163 |
-
fullInputDict.update({gr.Audio(source="microphone", type="filepath", label="Microphone Input", elem_id = "microphoneData")})
|
| 1164 |
-
fullUrlTab.select(fn=lambda: "urlData", inputs = [], outputs= [fullSourceInput] )
|
| 1165 |
-
fullUploadTab.select(fn=lambda: "multipleFiles", inputs = [], outputs= [fullSourceInput] )
|
| 1166 |
-
fullMicTab.select(fn=lambda: "microphoneData", inputs = [], outputs= [fullSourceInput] )
|
| 1167 |
-
fullInputDict.update({gr.Dropdown(choices=["transcribe", "translate"], label="Task", value=app_config.task, elem_id = "task")})
|
| 1168 |
-
with gr.Accordion("VAD options", open=False):
|
| 1169 |
-
fullInputDict.update(common_vad_inputs())
|
| 1170 |
-
fullInputDict.update({
|
| 1171 |
-
gr.Number(label="VAD - Padding (s)", precision=None, value=app_config.vad_padding, elem_id = "vadPadding"),
|
| 1172 |
-
gr.Number(label="VAD - Prompt Window (s)", precision=None, value=app_config.vad_prompt_window, elem_id = "vadPromptWindow"),
|
| 1173 |
-
gr.Dropdown(choices=VAD_INITIAL_PROMPT_MODE_VALUES, label="VAD - Initial Prompt Mode", value=app_config.vad_initial_prompt_mode, elem_id = "vadInitialPromptMode")})
|
| 1174 |
-
with gr.Accordion("Word Timestamps options", open=False):
|
| 1175 |
-
fullInputDict.update(common_word_timestamps_inputs())
|
| 1176 |
-
fullInputDict.update({
|
| 1177 |
-
gr.Text(label="Word Timestamps - Prepend Punctuations", value=app_config.prepend_punctuations, elem_id = "prepend_punctuations"),
|
| 1178 |
-
gr.Text(label="Word Timestamps - Append Punctuations", value=app_config.append_punctuations, elem_id = "append_punctuations")})
|
| 1179 |
-
with gr.Accordion("Whisper Advanced options", open=False):
|
| 1180 |
-
fullInputDict.update({
|
| 1181 |
-
gr.TextArea(label="Initial Prompt", elem_id = "initial_prompt"),
|
| 1182 |
-
gr.Number(label="Temperature", value=app_config.temperature, elem_id = "temperature"),
|
| 1183 |
-
gr.Number(label="Best Of - Non-zero temperature", value=app_config.best_of, precision=0, elem_id = "best_of"),
|
| 1184 |
-
gr.Number(label="Beam Size - Zero temperature", value=app_config.beam_size, precision=0, elem_id = "beam_size"),
|
| 1185 |
-
gr.Number(label="Patience - Zero temperature", value=app_config.patience, elem_id = "patience"),
|
| 1186 |
-
gr.Number(label="Length Penalty - Any temperature", value=lambda : None if app_config.length_penalty is None else app_config.length_penalty, elem_id = "length_penalty"),
|
| 1187 |
-
gr.Text(label="Suppress Tokens - Comma-separated list of token IDs", value=app_config.suppress_tokens, elem_id = "suppress_tokens"),
|
| 1188 |
-
gr.Checkbox(label="Condition on previous text", value=app_config.condition_on_previous_text, elem_id = "condition_on_previous_text"),
|
| 1189 |
-
gr.Checkbox(label="FP16", value=app_config.fp16, elem_id = "fp16"),
|
| 1190 |
-
gr.Number(label="Temperature increment on fallback", value=app_config.temperature_increment_on_fallback, elem_id = "temperature_increment_on_fallback"),
|
| 1191 |
-
gr.Number(label="Compression ratio threshold", value=app_config.compression_ratio_threshold, elem_id = "compression_ratio_threshold"),
|
| 1192 |
-
gr.Number(label="Logprob threshold", value=app_config.logprob_threshold, elem_id = "logprob_threshold"),
|
| 1193 |
-
gr.Number(label="No speech threshold", value=app_config.no_speech_threshold, elem_id = "no_speech_threshold"),
|
| 1194 |
-
})
|
| 1195 |
-
if app_config.whisper_implementation == "faster-whisper":
|
| 1196 |
-
fullInputDict.update({
|
| 1197 |
-
gr.Number(label="Repetition Penalty", value=app_config.repetition_penalty, elem_id = "repetition_penalty"),
|
| 1198 |
-
gr.Number(label="No Repeat Ngram Size", value=app_config.no_repeat_ngram_size, precision=0, elem_id = "no_repeat_ngram_size")
|
| 1199 |
-
})
|
| 1200 |
-
with gr.Accordion("Whisper Segments Filter options", open=False):
|
| 1201 |
-
fullInputDict.update(common_segments_filter_inputs())
|
| 1202 |
-
with gr.Accordion("Diarization options", open=False):
|
| 1203 |
-
fullInputDict.update(common_diarization_inputs())
|
| 1204 |
-
with gr.Accordion("Translation options", open=False):
|
| 1205 |
-
fullInputDict.update(common_translation_inputs())
|
| 1206 |
-
with gr.Column():
|
| 1207 |
-
fullOutput = common_output()
|
| 1208 |
-
gr.Markdown(uiArticle)
|
| 1209 |
-
if optionsMd is not None:
|
| 1210 |
-
with gr.Accordion("docs/options.md", open=False):
|
| 1211 |
-
gr.Markdown(optionsMd)
|
| 1212 |
-
if translateModelMd is not None:
|
| 1213 |
-
with gr.Accordion("docs/translateModel.md", open=False):
|
| 1214 |
-
gr.Markdown(translateModelMd)
|
| 1215 |
-
if readmeMd is not None:
|
| 1216 |
-
with gr.Accordion("README.md", open=False):
|
| 1217 |
-
gr.Markdown(readmeMd)
|
| 1218 |
-
|
| 1219 |
-
fullInputDict.update({fullTranslateInput, fullSourceInput})
|
| 1220 |
-
fullSubmit.click(fn=ui.transcribe_webui_full_progress if is_queue_mode else ui.transcribe_webui_full,
|
| 1221 |
-
inputs=fullInputDict, outputs=fullOutput)
|
| 1222 |
|
| 1223 |
demo = gr.TabbedInterface([simpleTranscribe, fullTranscribe], tab_names=["Simple", "Full"], css=css)
|
| 1224 |
|
|
|
|
| 114 |
self.diarization.cleanup()
|
| 115 |
self.diarization_kwargs = None
|
| 116 |
|
| 117 |
+
# Entry function for the simple or full tab, Queue mode disabled: progress bars will not be shown
|
| 118 |
+
def transcribe_entry(self, data: dict): return self.transcribe_entry_progress(data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
|
| 120 |
+
# Entry function for the simple or full tab with progress, Progress tracking requires queuing to be enabled
|
| 121 |
+
def transcribe_entry_progress(self, data: dict, progress=gr.Progress()):
|
| 122 |
dataDict = {}
|
| 123 |
for key, value in data.items():
|
| 124 |
dataDict.update({key.elem_id: value})
|
|
|
|
| 1032 |
|
| 1033 |
is_queue_mode = app_config.queue_concurrency_count is not None and app_config.queue_concurrency_count > 0
|
| 1034 |
|
| 1035 |
+
def create_transcribe(uiDescription: str, isQueueMode: bool, isFull: bool = False):
|
| 1036 |
+
with gr.Blocks() as transcribe:
|
| 1037 |
+
translateInput = gr.State(value="m2m100", elem_id = "translateInput")
|
| 1038 |
+
sourceInput = gr.State(value="urlData", elem_id = "sourceInput")
|
| 1039 |
+
gr.Markdown(uiDescription)
|
| 1040 |
+
with gr.Row():
|
|
|
|
|
|
|
|
|
|
| 1041 |
with gr.Column():
|
| 1042 |
+
submitBtn = gr.Button("Submit", variant="primary")
|
| 1043 |
+
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1044 |
with gr.Row():
|
| 1045 |
+
inputDict = common_whisper_inputs()
|
| 1046 |
+
with gr.Tab(label="M2M100") as m2m100Tab:
|
| 1047 |
+
with gr.Row():
|
| 1048 |
+
inputDict.update(common_m2m100_inputs())
|
| 1049 |
+
with gr.Tab(label="NLLB") as nllbTab:
|
| 1050 |
+
with gr.Row():
|
| 1051 |
+
inputDict.update(common_nllb_inputs())
|
| 1052 |
+
with gr.Tab(label="MT5") as mt5Tab:
|
| 1053 |
+
with gr.Row():
|
| 1054 |
+
inputDict.update(common_mt5_inputs())
|
| 1055 |
+
with gr.Tab(label="ALMA") as almaTab:
|
| 1056 |
+
with gr.Row():
|
| 1057 |
+
inputDict.update(common_ALMA_inputs())
|
| 1058 |
+
with gr.Tab(label="madlad400") as madlad400Tab:
|
| 1059 |
+
with gr.Row():
|
| 1060 |
+
inputDict.update(common_madlad400_inputs())
|
| 1061 |
+
with gr.Tab(label="seamless") as seamlessTab:
|
| 1062 |
+
with gr.Row():
|
| 1063 |
+
inputDict.update(common_seamless_inputs())
|
| 1064 |
+
m2m100Tab.select(fn=lambda: "m2m100", inputs = [], outputs= [translateInput] )
|
| 1065 |
+
nllbTab.select(fn=lambda: "nllb", inputs = [], outputs= [translateInput] )
|
| 1066 |
+
mt5Tab.select(fn=lambda: "mt5", inputs = [], outputs= [translateInput] )
|
| 1067 |
+
almaTab.select(fn=lambda: "ALMA", inputs = [], outputs= [translateInput] )
|
| 1068 |
+
madlad400Tab.select(fn=lambda: "madlad400", inputs = [], outputs= [translateInput] )
|
| 1069 |
+
seamlessTab.select(fn=lambda: "seamless", inputs = [], outputs= [translateInput] )
|
| 1070 |
+
with gr.Column():
|
| 1071 |
+
with gr.Tab(label="URL") as UrlTab:
|
| 1072 |
+
inputDict.update({gr.Text(label="URL (YouTube, etc.)", elem_id = "urlData")})
|
| 1073 |
+
with gr.Tab(label="Upload") as UploadTab:
|
| 1074 |
+
inputDict.update({gr.File(label="Upload Files", file_count="multiple", elem_id = "multipleFiles")})
|
| 1075 |
+
with gr.Tab(label="Microphone") as MicTab:
|
| 1076 |
+
inputDict.update({gr.Audio(source="microphone", type="filepath", label="Microphone Input", elem_id = "microphoneData")})
|
| 1077 |
+
UrlTab.select(fn=lambda: "urlData", inputs = [], outputs= [sourceInput] )
|
| 1078 |
+
UploadTab.select(fn=lambda: "multipleFiles", inputs = [], outputs= [sourceInput] )
|
| 1079 |
+
MicTab.select(fn=lambda: "microphoneData", inputs = [], outputs= [sourceInput] )
|
| 1080 |
+
inputDict.update({gr.Dropdown(choices=["transcribe", "translate"], label="Task", value=app_config.task, elem_id = "task")})
|
| 1081 |
+
with gr.Accordion("VAD options", open=False):
|
| 1082 |
+
inputDict.update(common_vad_inputs())
|
| 1083 |
+
if isFull:
|
| 1084 |
+
inputDict.update({
|
| 1085 |
+
gr.Number(label="VAD - Padding (s)", precision=None, value=app_config.vad_padding, elem_id = "vadPadding"),
|
| 1086 |
+
gr.Number(label="VAD - Prompt Window (s)", precision=None, value=app_config.vad_prompt_window, elem_id = "vadPromptWindow"),
|
| 1087 |
+
gr.Dropdown(choices=VAD_INITIAL_PROMPT_MODE_VALUES, label="VAD - Initial Prompt Mode", value=app_config.vad_initial_prompt_mode, elem_id = "vadInitialPromptMode")})
|
| 1088 |
+
with gr.Accordion("Word Timestamps options", open=False):
|
| 1089 |
+
inputDict.update(common_word_timestamps_inputs())
|
| 1090 |
+
if isFull:
|
| 1091 |
+
inputDict.update({
|
| 1092 |
+
gr.Text(label="Word Timestamps - Prepend Punctuations", value=app_config.prepend_punctuations, elem_id = "prepend_punctuations"),
|
| 1093 |
+
gr.Text(label="Word Timestamps - Append Punctuations", value=app_config.append_punctuations, elem_id = "append_punctuations")})
|
| 1094 |
+
if isFull:
|
| 1095 |
+
with gr.Accordion("Whisper Advanced options", open=False):
|
| 1096 |
+
inputDict.update({
|
| 1097 |
+
gr.TextArea(label="Initial Prompt", elem_id = "initial_prompt"),
|
| 1098 |
+
gr.Number(label="Temperature", value=app_config.temperature, elem_id = "temperature"),
|
| 1099 |
+
gr.Number(label="Best Of - Non-zero temperature", value=app_config.best_of, precision=0, elem_id = "best_of"),
|
| 1100 |
+
gr.Number(label="Beam Size - Zero temperature", value=app_config.beam_size, precision=0, elem_id = "beam_size"),
|
| 1101 |
+
gr.Number(label="Patience - Zero temperature", value=app_config.patience, elem_id = "patience"),
|
| 1102 |
+
gr.Number(label="Length Penalty - Any temperature", value=lambda : None if app_config.length_penalty is None else app_config.length_penalty, elem_id = "length_penalty"),
|
| 1103 |
+
gr.Text(label="Suppress Tokens - Comma-separated list of token IDs", value=app_config.suppress_tokens, elem_id = "suppress_tokens"),
|
| 1104 |
+
gr.Checkbox(label="Condition on previous text", value=app_config.condition_on_previous_text, elem_id = "condition_on_previous_text"),
|
| 1105 |
+
gr.Checkbox(label="FP16", value=app_config.fp16, elem_id = "fp16"),
|
| 1106 |
+
gr.Number(label="Temperature increment on fallback", value=app_config.temperature_increment_on_fallback, elem_id = "temperature_increment_on_fallback"),
|
| 1107 |
+
gr.Number(label="Compression ratio threshold", value=app_config.compression_ratio_threshold, elem_id = "compression_ratio_threshold"),
|
| 1108 |
+
gr.Number(label="Logprob threshold", value=app_config.logprob_threshold, elem_id = "logprob_threshold"),
|
| 1109 |
+
gr.Number(label="No speech threshold", value=app_config.no_speech_threshold, elem_id = "no_speech_threshold"),
|
| 1110 |
+
})
|
| 1111 |
+
if app_config.whisper_implementation == "faster-whisper":
|
| 1112 |
+
inputDict.update({
|
| 1113 |
+
gr.Number(label="Repetition Penalty", value=app_config.repetition_penalty, elem_id = "repetition_penalty"),
|
| 1114 |
+
gr.Number(label="No Repeat Ngram Size", value=app_config.no_repeat_ngram_size, precision=0, elem_id = "no_repeat_ngram_size")
|
| 1115 |
+
})
|
| 1116 |
+
with gr.Accordion("Whisper Segments Filter options", open=False):
|
| 1117 |
+
inputDict.update(common_segments_filter_inputs())
|
| 1118 |
+
with gr.Accordion("Diarization options", open=False):
|
| 1119 |
+
inputDict.update(common_diarization_inputs())
|
| 1120 |
+
with gr.Accordion("Translation options", open=False):
|
| 1121 |
+
inputDict.update(common_translation_inputs())
|
| 1122 |
with gr.Column():
|
| 1123 |
+
outputs = common_output()
|
| 1124 |
+
gr.Markdown(uiArticle)
|
| 1125 |
+
if optionsMd is not None:
|
| 1126 |
+
with gr.Accordion("docs/options.md", open=False):
|
| 1127 |
+
gr.Markdown(optionsMd)
|
| 1128 |
+
if translateModelMd is not None:
|
| 1129 |
+
with gr.Accordion("docs/translateModel.md", open=False):
|
| 1130 |
+
gr.Markdown(translateModelMd)
|
| 1131 |
+
if readmeMd is not None:
|
| 1132 |
+
with gr.Accordion("README.md", open=False):
|
| 1133 |
+
gr.Markdown(readmeMd)
|
| 1134 |
+
|
| 1135 |
+
inputDict.update({translateInput, sourceInput})
|
| 1136 |
+
submitBtn.click(fn=ui.transcribe_entry_progress if isQueueMode else ui.transcribe_entry,
|
| 1137 |
+
inputs=inputDict, outputs=outputs)
|
| 1138 |
+
|
| 1139 |
+
return transcribe
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1140 |
|
| 1141 |
+
simpleTranscribe = create_transcribe(uiDescription, is_queue_mode)
|
| 1142 |
fullDescription = uiDescription + "\n\n\n\n" + "Be careful when changing some of the options in the full interface - this can cause the model to crash."
|
| 1143 |
+
fullTranscribe = create_transcribe(fullDescription, is_queue_mode, True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1144 |
|
| 1145 |
demo = gr.TabbedInterface([simpleTranscribe, fullTranscribe], tab_names=["Simple", "Full"], css=css)
|
| 1146 |
|
src/translation/translationModel.py
CHANGED
|
@@ -318,7 +318,7 @@ class TranslationModel:
|
|
| 318 |
if getattr(self, "transModel", None) is not None and getattr(self.transModel, "unload_model", None) is not None:
|
| 319 |
self.transModel.unload_model()
|
| 320 |
|
| 321 |
-
if getattr(self, "transProcessor") is not None:
|
| 322 |
del self.transProcessor
|
| 323 |
if getattr(self, "transTokenizer", None) is not None:
|
| 324 |
del self.transTokenizer
|
|
|
|
| 318 |
if getattr(self, "transModel", None) is not None and getattr(self.transModel, "unload_model", None) is not None:
|
| 319 |
self.transModel.unload_model()
|
| 320 |
|
| 321 |
+
if getattr(self, "transProcessor", None) is not None:
|
| 322 |
del self.transProcessor
|
| 323 |
if getattr(self, "transTokenizer", None) is not None:
|
| 324 |
del self.transTokenizer
|