Spaces:
Running
Running
jhj0517
commited on
Commit
·
f7de005
1
Parent(s):
f5da61b
Apply i18n
Browse files
app.py
CHANGED
|
@@ -41,8 +41,8 @@ class App:
|
|
| 41 |
output_dir=os.path.join(self.args.output_dir, "translations")
|
| 42 |
)
|
| 43 |
self.default_params = load_yaml(DEFAULT_PARAMETERS_CONFIG_PATH)
|
| 44 |
-
print(f"Use \"{self.args.whisper_type}\" implementation"
|
| 45 |
-
|
| 46 |
|
| 47 |
def create_whisper_parameters(self):
|
| 48 |
whisper_params = self.default_params["whisper"]
|
|
@@ -52,23 +52,28 @@ class App:
|
|
| 52 |
|
| 53 |
with gr.Row():
|
| 54 |
dd_model = gr.Dropdown(choices=self.whisper_inf.available_models, value=whisper_params["model_size"],
|
| 55 |
-
label="Model")
|
| 56 |
dd_lang = gr.Dropdown(choices=[AUTOMATIC_DETECTION] + self.whisper_inf.available_langs,
|
| 57 |
-
value=whisper_params["lang"]
|
| 58 |
-
|
|
|
|
| 59 |
with gr.Row():
|
| 60 |
-
cb_translate = gr.Checkbox(value=whisper_params["is_translate"], label="Translate to English?",
|
| 61 |
interactive=True)
|
| 62 |
with gr.Row():
|
| 63 |
-
cb_timestamp = gr.Checkbox(value=whisper_params["add_timestamp"],
|
|
|
|
| 64 |
interactive=True)
|
| 65 |
|
| 66 |
-
with gr.Accordion("Advanced Parameters", open=False):
|
| 67 |
-
nb_beam_size = gr.Number(label="Beam Size", value=whisper_params["beam_size"], precision=0,
|
|
|
|
| 68 |
info="Beam size to use for decoding.")
|
| 69 |
-
nb_log_prob_threshold = gr.Number(label="Log Probability Threshold",
|
|
|
|
| 70 |
info="If the average log probability over sampled tokens is below this value, treat as failed.")
|
| 71 |
-
nb_no_speech_threshold = gr.Number(label="No Speech Threshold", value=whisper_params["no_speech_threshold"],
|
|
|
|
| 72 |
info="If the no speech probability is higher than this value AND the average log probability over sampled tokens is below 'Log Prob Threshold', consider the segment as silent.")
|
| 73 |
dd_compute_type = gr.Dropdown(label="Compute Type", choices=self.whisper_inf.available_compute_types,
|
| 74 |
value=self.whisper_inf.current_compute_type, interactive=True,
|
|
@@ -78,10 +83,12 @@ class App:
|
|
| 78 |
info="Number of candidates when sampling with non-zero temperature.")
|
| 79 |
nb_patience = gr.Number(label="Patience", value=whisper_params["patience"], interactive=True,
|
| 80 |
info="Beam search patience factor.")
|
| 81 |
-
cb_condition_on_previous_text = gr.Checkbox(label="Condition On Previous Text",
|
|
|
|
| 82 |
interactive=True,
|
| 83 |
info="Condition on previous text during decoding.")
|
| 84 |
-
sld_prompt_reset_on_temperature = gr.Slider(label="Prompt Reset On Temperature",
|
|
|
|
| 85 |
minimum=0, maximum=1, step=0.01, interactive=True,
|
| 86 |
info="Resets prompt if temperature is above this value."
|
| 87 |
" Arg has effect only if 'Condition On Previous Text' is True.")
|
|
@@ -90,7 +97,8 @@ class App:
|
|
| 90 |
sd_temperature = gr.Slider(label="Temperature", value=whisper_params["temperature"], minimum=0.0,
|
| 91 |
step=0.01, maximum=1.0, interactive=True,
|
| 92 |
info="Temperature for sampling. It can be a tuple of temperatures, which will be successively used upon failures according to either `Compression Ratio Threshold` or `Log Prob Threshold`.")
|
| 93 |
-
nb_compression_ratio_threshold = gr.Number(label="Compression Ratio Threshold",
|
|
|
|
| 94 |
interactive=True,
|
| 95 |
info="If the gzip compression ratio is above this value, treat as failed.")
|
| 96 |
nb_chunk_length = gr.Number(label="Chunk Length (s)", value=lambda: whisper_params["chunk_length"],
|
|
@@ -99,9 +107,11 @@ class App:
|
|
| 99 |
with gr.Group(visible=isinstance(self.whisper_inf, FasterWhisperInference)):
|
| 100 |
nb_length_penalty = gr.Number(label="Length Penalty", value=whisper_params["length_penalty"],
|
| 101 |
info="Exponential length penalty constant.")
|
| 102 |
-
nb_repetition_penalty = gr.Number(label="Repetition Penalty",
|
|
|
|
| 103 |
info="Penalty applied to the score of previously generated tokens (set > 1 to penalize).")
|
| 104 |
-
nb_no_repeat_ngram_size = gr.Number(label="No Repeat N-gram Size",
|
|
|
|
| 105 |
precision=0,
|
| 106 |
info="Prevent repetitions of n-grams with this size (set 0 to disable).")
|
| 107 |
tb_prefix = gr.Textbox(label="Prefix", value=lambda: whisper_params["prefix"],
|
|
@@ -110,48 +120,55 @@ class App:
|
|
| 110 |
info="Suppress blank outputs at the beginning of the sampling.")
|
| 111 |
tb_suppress_tokens = gr.Textbox(label="Suppress Tokens", value=whisper_params["suppress_tokens"],
|
| 112 |
info="List of token IDs to suppress. -1 will suppress a default set of symbols as defined in the model config.json file.")
|
| 113 |
-
nb_max_initial_timestamp = gr.Number(label="Max Initial Timestamp",
|
|
|
|
| 114 |
info="The initial timestamp cannot be later than this.")
|
| 115 |
cb_word_timestamps = gr.Checkbox(label="Word Timestamps", value=whisper_params["word_timestamps"],
|
| 116 |
info="Extract word-level timestamps using the cross-attention pattern and dynamic time warping, and include the timestamps for each word in each segment.")
|
| 117 |
-
tb_prepend_punctuations = gr.Textbox(label="Prepend Punctuations",
|
|
|
|
| 118 |
info="If 'Word Timestamps' is True, merge these punctuation symbols with the next word.")
|
| 119 |
-
tb_append_punctuations = gr.Textbox(label="Append Punctuations",
|
|
|
|
| 120 |
info="If 'Word Timestamps' is True, merge these punctuation symbols with the previous word.")
|
| 121 |
nb_max_new_tokens = gr.Number(label="Max New Tokens", value=lambda: whisper_params["max_new_tokens"],
|
| 122 |
precision=0,
|
| 123 |
info="Maximum number of new tokens to generate per-chunk. If not set, the maximum will be set by the default max_length.")
|
| 124 |
nb_hallucination_silence_threshold = gr.Number(label="Hallucination Silence Threshold (sec)",
|
| 125 |
-
value=lambda: whisper_params[
|
|
|
|
| 126 |
info="When 'Word Timestamps' is True, skip silent periods longer than this threshold (in seconds) when a possible hallucination is detected.")
|
| 127 |
tb_hotwords = gr.Textbox(label="Hotwords", value=lambda: whisper_params["hotwords"],
|
| 128 |
info="Hotwords/hint phrases to provide the model with. Has no effect if prefix is not None.")
|
| 129 |
-
nb_language_detection_threshold = gr.Number(label="Language Detection Threshold",
|
|
|
|
|
|
|
| 130 |
info="If the maximum probability of the language tokens is higher than this value, the language is detected.")
|
| 131 |
-
nb_language_detection_segments = gr.Number(label="Language Detection Segments",
|
|
|
|
| 132 |
precision=0,
|
| 133 |
info="Number of segments to consider for the language detection.")
|
| 134 |
with gr.Group(visible=isinstance(self.whisper_inf, InsanelyFastWhisperInference)):
|
| 135 |
nb_batch_size = gr.Number(label="Batch Size", value=whisper_params["batch_size"], precision=0)
|
| 136 |
|
| 137 |
-
with gr.Accordion("Background Music Remover Filter", open=False):
|
| 138 |
-
cb_bgm_separation = gr.Checkbox(label="Enable Background Music Remover Filter",
|
|
|
|
| 139 |
interactive=True,
|
| 140 |
-
info="Enabling this will remove background music
|
| 141 |
-
|
| 142 |
-
dd_uvr_device = gr.Dropdown(label="Device", value=self.whisper_inf.music_separator.device,
|
| 143 |
choices=self.whisper_inf.music_separator.available_devices)
|
| 144 |
-
dd_uvr_model_size = gr.Dropdown(label="Model", value=uvr_params["model_size"],
|
| 145 |
choices=self.whisper_inf.music_separator.available_models)
|
| 146 |
nb_uvr_segment_size = gr.Number(label="Segment Size", value=uvr_params["segment_size"], precision=0)
|
| 147 |
-
cb_uvr_save_file = gr.Checkbox(label="Save separated files to output", value=uvr_params["save_file"])
|
| 148 |
-
cb_uvr_enable_offload = gr.Checkbox(label="Offload sub model after removing background music",
|
| 149 |
value=uvr_params["enable_offload"])
|
| 150 |
|
| 151 |
-
with gr.Accordion("Voice Detection Filter", open=False):
|
| 152 |
-
cb_vad_filter = gr.Checkbox(label="Enable Silero VAD Filter", value=vad_params["vad_filter"],
|
| 153 |
interactive=True,
|
| 154 |
-
info="Enable this to transcribe only detected voice
|
| 155 |
sd_threshold = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label="Speech Threshold",
|
| 156 |
value=vad_params["threshold"],
|
| 157 |
info="Lower it to be more sensitive to small sounds.")
|
|
@@ -168,15 +185,11 @@ class App:
|
|
| 168 |
nb_speech_pad_ms = gr.Number(label="Speech Padding (ms)", precision=0, value=vad_params["speech_pad_ms"],
|
| 169 |
info="Final speech chunks are padded by this time each side")
|
| 170 |
|
| 171 |
-
with gr.Accordion("Diarization", open=False):
|
| 172 |
-
cb_diarize = gr.Checkbox(label="Enable Diarization", value=diarization_params["is_diarize"])
|
| 173 |
-
tb_hf_token = gr.Text(label="HuggingFace Token", value=diarization_params["hf_token"],
|
| 174 |
-
info="This is only needed the first time you download the model
|
| 175 |
-
|
| 176 |
-
"to \"https://huggingface.co/pyannote/speaker-diarization-3.1\" and "
|
| 177 |
-
"\"https://huggingface.co/pyannote/segmentation-3.0\" and agree to"
|
| 178 |
-
" their requirement.")
|
| 179 |
-
dd_diarization_device = gr.Dropdown(label="Device",
|
| 180 |
choices=self.whisper_inf.diarizer.get_available_device(),
|
| 181 |
value=self.whisper_inf.diarizer.get_device())
|
| 182 |
|
|
@@ -295,15 +308,19 @@ class App:
|
|
| 295 |
|
| 296 |
with gr.TabItem(_("T2T Translation")): # tab 4
|
| 297 |
with gr.Row():
|
| 298 |
-
file_subs = gr.Files(type="filepath", label="Upload Subtitle Files to translate here")
|
| 299 |
|
| 300 |
with gr.TabItem(_("DeepL API")): # sub tab1
|
| 301 |
with gr.Row():
|
| 302 |
-
tb_api_key = gr.Textbox(label=_("Your Auth Key (API KEY)"),
|
|
|
|
| 303 |
with gr.Row():
|
| 304 |
-
dd_source_lang = gr.Dropdown(label=_("Source Language"),
|
|
|
|
|
|
|
| 305 |
choices=list(self.deepl_api.available_source_langs.keys()))
|
| 306 |
-
dd_target_lang = gr.Dropdown(label=_("Target Language"),
|
|
|
|
| 307 |
choices=list(self.deepl_api.available_target_langs.keys()))
|
| 308 |
with gr.Row():
|
| 309 |
cb_is_pro = gr.Checkbox(label=_("Pro User?"), value=deepl_params["is_pro"])
|
|
@@ -323,17 +340,20 @@ class App:
|
|
| 323 |
cb_is_pro, cb_timestamp],
|
| 324 |
outputs=[tb_indicator, files_subtitles])
|
| 325 |
|
| 326 |
-
btn_openfolder.click(
|
| 327 |
-
|
| 328 |
-
|
|
|
|
| 329 |
|
| 330 |
with gr.TabItem(_("NLLB")): # sub tab2
|
| 331 |
with gr.Row():
|
| 332 |
dd_model_size = gr.Dropdown(label=_("Model"), value=nllb_params["model_size"],
|
| 333 |
choices=self.nllb_inf.available_models)
|
| 334 |
-
dd_source_lang = gr.Dropdown(label=_("Source Language"),
|
|
|
|
| 335 |
choices=self.nllb_inf.available_source_langs)
|
| 336 |
-
dd_target_lang = gr.Dropdown(label=_("Target Language"),
|
|
|
|
| 337 |
choices=self.nllb_inf.available_target_langs)
|
| 338 |
with gr.Row():
|
| 339 |
nb_max_length = gr.Number(label="Max Length Per Line", value=nllb_params["max_length"],
|
|
@@ -356,17 +376,19 @@ class App:
|
|
| 356 |
nb_max_length, cb_timestamp],
|
| 357 |
outputs=[tb_indicator, files_subtitles])
|
| 358 |
|
| 359 |
-
btn_openfolder.click(
|
| 360 |
-
|
| 361 |
-
|
|
|
|
| 362 |
|
| 363 |
with gr.TabItem(_("BGM Separation")):
|
| 364 |
-
files_audio = gr.Files(type="filepath", label="Upload Audio Files to separate background music")
|
| 365 |
dd_uvr_device = gr.Dropdown(label=_("Device"), value=self.whisper_inf.music_separator.device,
|
| 366 |
choices=self.whisper_inf.music_separator.available_devices)
|
| 367 |
dd_uvr_model_size = gr.Dropdown(label=_("Model"), value=uvr_params["model_size"],
|
| 368 |
choices=self.whisper_inf.music_separator.available_models)
|
| 369 |
-
nb_uvr_segment_size = gr.Number(label="Segment Size", value=uvr_params["segment_size"],
|
|
|
|
| 370 |
cb_uvr_save_file = gr.Checkbox(label=_("Save separated files to output"),
|
| 371 |
value=True, visible=False)
|
| 372 |
btn_run = gr.Button(_("SEPARATE BACKGROUND MUSIC"), variant="primary")
|
|
@@ -390,7 +412,7 @@ class App:
|
|
| 390 |
btn_open_vocals_folder.click(inputs=None,
|
| 391 |
outputs=None,
|
| 392 |
fn=lambda: self.open_folder(os.path.join(
|
| 393 |
-
|
| 394 |
)))
|
| 395 |
|
| 396 |
# Launch the app with optional gradio settings
|
|
@@ -424,10 +446,10 @@ class App:
|
|
| 424 |
return gr.Checkbox(visible=True, value=False, label="Translate to English?", interactive=True)
|
| 425 |
|
| 426 |
|
| 427 |
-
# Create the parser for command-line arguments
|
| 428 |
parser = argparse.ArgumentParser()
|
| 429 |
parser.add_argument('--whisper_type', type=str, default="faster-whisper",
|
| 430 |
-
|
|
|
|
| 431 |
parser.add_argument('--share', type=str2bool, default=False, nargs='?', const=True, help='Gradio share value')
|
| 432 |
parser.add_argument('--server_name', type=str, default=None, help='Gradio server host')
|
| 433 |
parser.add_argument('--server_port', type=int, default=None, help='Gradio server port')
|
|
@@ -436,8 +458,10 @@ parser.add_argument('--username', type=str, default=None, help='Gradio authentic
|
|
| 436 |
parser.add_argument('--password', type=str, default=None, help='Gradio authentication password')
|
| 437 |
parser.add_argument('--theme', type=str, default=None, help='Gradio Blocks theme')
|
| 438 |
parser.add_argument('--colab', type=str2bool, default=False, nargs='?', const=True, help='Is colab user or not')
|
| 439 |
-
parser.add_argument('--api_open', type=str2bool, default=False, nargs='?', const=True,
|
| 440 |
-
|
|
|
|
|
|
|
| 441 |
parser.add_argument('--whisper_model_dir', type=str, default=WHISPER_MODELS_DIR,
|
| 442 |
help='Directory path of the whisper model')
|
| 443 |
parser.add_argument('--faster_whisper_model_dir', type=str, default=FASTER_WHISPER_MODELS_DIR,
|
|
|
|
| 41 |
output_dir=os.path.join(self.args.output_dir, "translations")
|
| 42 |
)
|
| 43 |
self.default_params = load_yaml(DEFAULT_PARAMETERS_CONFIG_PATH)
|
| 44 |
+
print(f"Use \"{self.args.whisper_type}\" implementation\n"
|
| 45 |
+
f"Device \"{self.whisper_inf.device}\" is detected")
|
| 46 |
|
| 47 |
def create_whisper_parameters(self):
|
| 48 |
whisper_params = self.default_params["whisper"]
|
|
|
|
| 52 |
|
| 53 |
with gr.Row():
|
| 54 |
dd_model = gr.Dropdown(choices=self.whisper_inf.available_models, value=whisper_params["model_size"],
|
| 55 |
+
label=_("Model"))
|
| 56 |
dd_lang = gr.Dropdown(choices=[AUTOMATIC_DETECTION] + self.whisper_inf.available_langs,
|
| 57 |
+
value=AUTOMATIC_DETECTION if whisper_params["lang"] == AUTOMATIC_DETECTION.unwrap()
|
| 58 |
+
else whisper_params["lang"], label=_("Language"))
|
| 59 |
+
dd_file_format = gr.Dropdown(choices=["SRT", "WebVTT", "txt"], value="SRT", label=_("File Format"))
|
| 60 |
with gr.Row():
|
| 61 |
+
cb_translate = gr.Checkbox(value=whisper_params["is_translate"], label=_("Translate to English?"),
|
| 62 |
interactive=True)
|
| 63 |
with gr.Row():
|
| 64 |
+
cb_timestamp = gr.Checkbox(value=whisper_params["add_timestamp"],
|
| 65 |
+
label=_("Add a timestamp to the end of the filename"),
|
| 66 |
interactive=True)
|
| 67 |
|
| 68 |
+
with gr.Accordion(_("Advanced Parameters"), open=False):
|
| 69 |
+
nb_beam_size = gr.Number(label="Beam Size", value=whisper_params["beam_size"], precision=0,
|
| 70 |
+
interactive=True,
|
| 71 |
info="Beam size to use for decoding.")
|
| 72 |
+
nb_log_prob_threshold = gr.Number(label="Log Probability Threshold",
|
| 73 |
+
value=whisper_params["log_prob_threshold"], interactive=True,
|
| 74 |
info="If the average log probability over sampled tokens is below this value, treat as failed.")
|
| 75 |
+
nb_no_speech_threshold = gr.Number(label="No Speech Threshold", value=whisper_params["no_speech_threshold"],
|
| 76 |
+
interactive=True,
|
| 77 |
info="If the no speech probability is higher than this value AND the average log probability over sampled tokens is below 'Log Prob Threshold', consider the segment as silent.")
|
| 78 |
dd_compute_type = gr.Dropdown(label="Compute Type", choices=self.whisper_inf.available_compute_types,
|
| 79 |
value=self.whisper_inf.current_compute_type, interactive=True,
|
|
|
|
| 83 |
info="Number of candidates when sampling with non-zero temperature.")
|
| 84 |
nb_patience = gr.Number(label="Patience", value=whisper_params["patience"], interactive=True,
|
| 85 |
info="Beam search patience factor.")
|
| 86 |
+
cb_condition_on_previous_text = gr.Checkbox(label="Condition On Previous Text",
|
| 87 |
+
value=whisper_params["condition_on_previous_text"],
|
| 88 |
interactive=True,
|
| 89 |
info="Condition on previous text during decoding.")
|
| 90 |
+
sld_prompt_reset_on_temperature = gr.Slider(label="Prompt Reset On Temperature",
|
| 91 |
+
value=whisper_params["prompt_reset_on_temperature"],
|
| 92 |
minimum=0, maximum=1, step=0.01, interactive=True,
|
| 93 |
info="Resets prompt if temperature is above this value."
|
| 94 |
" Arg has effect only if 'Condition On Previous Text' is True.")
|
|
|
|
| 97 |
sd_temperature = gr.Slider(label="Temperature", value=whisper_params["temperature"], minimum=0.0,
|
| 98 |
step=0.01, maximum=1.0, interactive=True,
|
| 99 |
info="Temperature for sampling. It can be a tuple of temperatures, which will be successively used upon failures according to either `Compression Ratio Threshold` or `Log Prob Threshold`.")
|
| 100 |
+
nb_compression_ratio_threshold = gr.Number(label="Compression Ratio Threshold",
|
| 101 |
+
value=whisper_params["compression_ratio_threshold"],
|
| 102 |
interactive=True,
|
| 103 |
info="If the gzip compression ratio is above this value, treat as failed.")
|
| 104 |
nb_chunk_length = gr.Number(label="Chunk Length (s)", value=lambda: whisper_params["chunk_length"],
|
|
|
|
| 107 |
with gr.Group(visible=isinstance(self.whisper_inf, FasterWhisperInference)):
|
| 108 |
nb_length_penalty = gr.Number(label="Length Penalty", value=whisper_params["length_penalty"],
|
| 109 |
info="Exponential length penalty constant.")
|
| 110 |
+
nb_repetition_penalty = gr.Number(label="Repetition Penalty",
|
| 111 |
+
value=whisper_params["repetition_penalty"],
|
| 112 |
info="Penalty applied to the score of previously generated tokens (set > 1 to penalize).")
|
| 113 |
+
nb_no_repeat_ngram_size = gr.Number(label="No Repeat N-gram Size",
|
| 114 |
+
value=whisper_params["no_repeat_ngram_size"],
|
| 115 |
precision=0,
|
| 116 |
info="Prevent repetitions of n-grams with this size (set 0 to disable).")
|
| 117 |
tb_prefix = gr.Textbox(label="Prefix", value=lambda: whisper_params["prefix"],
|
|
|
|
| 120 |
info="Suppress blank outputs at the beginning of the sampling.")
|
| 121 |
tb_suppress_tokens = gr.Textbox(label="Suppress Tokens", value=whisper_params["suppress_tokens"],
|
| 122 |
info="List of token IDs to suppress. -1 will suppress a default set of symbols as defined in the model config.json file.")
|
| 123 |
+
nb_max_initial_timestamp = gr.Number(label="Max Initial Timestamp",
|
| 124 |
+
value=whisper_params["max_initial_timestamp"],
|
| 125 |
info="The initial timestamp cannot be later than this.")
|
| 126 |
cb_word_timestamps = gr.Checkbox(label="Word Timestamps", value=whisper_params["word_timestamps"],
|
| 127 |
info="Extract word-level timestamps using the cross-attention pattern and dynamic time warping, and include the timestamps for each word in each segment.")
|
| 128 |
+
tb_prepend_punctuations = gr.Textbox(label="Prepend Punctuations",
|
| 129 |
+
value=whisper_params["prepend_punctuations"],
|
| 130 |
info="If 'Word Timestamps' is True, merge these punctuation symbols with the next word.")
|
| 131 |
+
tb_append_punctuations = gr.Textbox(label="Append Punctuations",
|
| 132 |
+
value=whisper_params["append_punctuations"],
|
| 133 |
info="If 'Word Timestamps' is True, merge these punctuation symbols with the previous word.")
|
| 134 |
nb_max_new_tokens = gr.Number(label="Max New Tokens", value=lambda: whisper_params["max_new_tokens"],
|
| 135 |
precision=0,
|
| 136 |
info="Maximum number of new tokens to generate per-chunk. If not set, the maximum will be set by the default max_length.")
|
| 137 |
nb_hallucination_silence_threshold = gr.Number(label="Hallucination Silence Threshold (sec)",
|
| 138 |
+
value=lambda: whisper_params[
|
| 139 |
+
"hallucination_silence_threshold"],
|
| 140 |
info="When 'Word Timestamps' is True, skip silent periods longer than this threshold (in seconds) when a possible hallucination is detected.")
|
| 141 |
tb_hotwords = gr.Textbox(label="Hotwords", value=lambda: whisper_params["hotwords"],
|
| 142 |
info="Hotwords/hint phrases to provide the model with. Has no effect if prefix is not None.")
|
| 143 |
+
nb_language_detection_threshold = gr.Number(label="Language Detection Threshold",
|
| 144 |
+
value=lambda: whisper_params[
|
| 145 |
+
"language_detection_threshold"],
|
| 146 |
info="If the maximum probability of the language tokens is higher than this value, the language is detected.")
|
| 147 |
+
nb_language_detection_segments = gr.Number(label="Language Detection Segments",
|
| 148 |
+
value=lambda: whisper_params["language_detection_segments"],
|
| 149 |
precision=0,
|
| 150 |
info="Number of segments to consider for the language detection.")
|
| 151 |
with gr.Group(visible=isinstance(self.whisper_inf, InsanelyFastWhisperInference)):
|
| 152 |
nb_batch_size = gr.Number(label="Batch Size", value=whisper_params["batch_size"], precision=0)
|
| 153 |
|
| 154 |
+
with gr.Accordion(_("Background Music Remover Filter"), open=False):
|
| 155 |
+
cb_bgm_separation = gr.Checkbox(label=_("Enable Background Music Remover Filter"),
|
| 156 |
+
value=uvr_params["is_separate_bgm"],
|
| 157 |
interactive=True,
|
| 158 |
+
info=_("Enabling this will remove background music"))
|
| 159 |
+
dd_uvr_device = gr.Dropdown(label=_("Device"), value=self.whisper_inf.music_separator.device,
|
|
|
|
| 160 |
choices=self.whisper_inf.music_separator.available_devices)
|
| 161 |
+
dd_uvr_model_size = gr.Dropdown(label=_("Model"), value=uvr_params["model_size"],
|
| 162 |
choices=self.whisper_inf.music_separator.available_models)
|
| 163 |
nb_uvr_segment_size = gr.Number(label="Segment Size", value=uvr_params["segment_size"], precision=0)
|
| 164 |
+
cb_uvr_save_file = gr.Checkbox(label=_("Save separated files to output"), value=uvr_params["save_file"])
|
| 165 |
+
cb_uvr_enable_offload = gr.Checkbox(label=_("Offload sub model after removing background music"),
|
| 166 |
value=uvr_params["enable_offload"])
|
| 167 |
|
| 168 |
+
with gr.Accordion(_("Voice Detection Filter"), open=False):
|
| 169 |
+
cb_vad_filter = gr.Checkbox(label=_("Enable Silero VAD Filter"), value=vad_params["vad_filter"],
|
| 170 |
interactive=True,
|
| 171 |
+
info=_("Enable this to transcribe only detected voice"))
|
| 172 |
sd_threshold = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label="Speech Threshold",
|
| 173 |
value=vad_params["threshold"],
|
| 174 |
info="Lower it to be more sensitive to small sounds.")
|
|
|
|
| 185 |
nb_speech_pad_ms = gr.Number(label="Speech Padding (ms)", precision=0, value=vad_params["speech_pad_ms"],
|
| 186 |
info="Final speech chunks are padded by this time each side")
|
| 187 |
|
| 188 |
+
with gr.Accordion(_("Diarization"), open=False):
|
| 189 |
+
cb_diarize = gr.Checkbox(label=_("Enable Diarization"), value=diarization_params["is_diarize"])
|
| 190 |
+
tb_hf_token = gr.Text(label=_("HuggingFace Token"), value=diarization_params["hf_token"],
|
| 191 |
+
info=_("This is only needed the first time you download the model"))
|
| 192 |
+
dd_diarization_device = gr.Dropdown(label=_("Device"),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
choices=self.whisper_inf.diarizer.get_available_device(),
|
| 194 |
value=self.whisper_inf.diarizer.get_device())
|
| 195 |
|
|
|
|
| 308 |
|
| 309 |
with gr.TabItem(_("T2T Translation")): # tab 4
|
| 310 |
with gr.Row():
|
| 311 |
+
file_subs = gr.Files(type="filepath", label=_("Upload Subtitle Files to translate here"))
|
| 312 |
|
| 313 |
with gr.TabItem(_("DeepL API")): # sub tab1
|
| 314 |
with gr.Row():
|
| 315 |
+
tb_api_key = gr.Textbox(label=_("Your Auth Key (API KEY)"),
|
| 316 |
+
value=deepl_params["api_key"])
|
| 317 |
with gr.Row():
|
| 318 |
+
dd_source_lang = gr.Dropdown(label=_("Source Language"),
|
| 319 |
+
value=AUTOMATIC_DETECTION if deepl_params["source_lang"] == AUTOMATIC_DETECTION.unwrap()
|
| 320 |
+
else deepl_params["source_lang"],
|
| 321 |
choices=list(self.deepl_api.available_source_langs.keys()))
|
| 322 |
+
dd_target_lang = gr.Dropdown(label=_("Target Language"),
|
| 323 |
+
value=deepl_params["target_lang"],
|
| 324 |
choices=list(self.deepl_api.available_target_langs.keys()))
|
| 325 |
with gr.Row():
|
| 326 |
cb_is_pro = gr.Checkbox(label=_("Pro User?"), value=deepl_params["is_pro"])
|
|
|
|
| 340 |
cb_is_pro, cb_timestamp],
|
| 341 |
outputs=[tb_indicator, files_subtitles])
|
| 342 |
|
| 343 |
+
btn_openfolder.click(
|
| 344 |
+
fn=lambda: self.open_folder(os.path.join(self.args.output_dir, "translations")),
|
| 345 |
+
inputs=None,
|
| 346 |
+
outputs=None)
|
| 347 |
|
| 348 |
with gr.TabItem(_("NLLB")): # sub tab2
|
| 349 |
with gr.Row():
|
| 350 |
dd_model_size = gr.Dropdown(label=_("Model"), value=nllb_params["model_size"],
|
| 351 |
choices=self.nllb_inf.available_models)
|
| 352 |
+
dd_source_lang = gr.Dropdown(label=_("Source Language"),
|
| 353 |
+
value=nllb_params["source_lang"],
|
| 354 |
choices=self.nllb_inf.available_source_langs)
|
| 355 |
+
dd_target_lang = gr.Dropdown(label=_("Target Language"),
|
| 356 |
+
value=nllb_params["target_lang"],
|
| 357 |
choices=self.nllb_inf.available_target_langs)
|
| 358 |
with gr.Row():
|
| 359 |
nb_max_length = gr.Number(label="Max Length Per Line", value=nllb_params["max_length"],
|
|
|
|
| 376 |
nb_max_length, cb_timestamp],
|
| 377 |
outputs=[tb_indicator, files_subtitles])
|
| 378 |
|
| 379 |
+
btn_openfolder.click(
|
| 380 |
+
fn=lambda: self.open_folder(os.path.join(self.args.output_dir, "translations")),
|
| 381 |
+
inputs=None,
|
| 382 |
+
outputs=None)
|
| 383 |
|
| 384 |
with gr.TabItem(_("BGM Separation")):
|
| 385 |
+
files_audio = gr.Files(type="filepath", label=_("Upload Audio Files to separate background music"))
|
| 386 |
dd_uvr_device = gr.Dropdown(label=_("Device"), value=self.whisper_inf.music_separator.device,
|
| 387 |
choices=self.whisper_inf.music_separator.available_devices)
|
| 388 |
dd_uvr_model_size = gr.Dropdown(label=_("Model"), value=uvr_params["model_size"],
|
| 389 |
choices=self.whisper_inf.music_separator.available_models)
|
| 390 |
+
nb_uvr_segment_size = gr.Number(label="Segment Size", value=uvr_params["segment_size"],
|
| 391 |
+
precision=0)
|
| 392 |
cb_uvr_save_file = gr.Checkbox(label=_("Save separated files to output"),
|
| 393 |
value=True, visible=False)
|
| 394 |
btn_run = gr.Button(_("SEPARATE BACKGROUND MUSIC"), variant="primary")
|
|
|
|
| 412 |
btn_open_vocals_folder.click(inputs=None,
|
| 413 |
outputs=None,
|
| 414 |
fn=lambda: self.open_folder(os.path.join(
|
| 415 |
+
self.args.output_dir, "UVR", "vocals"
|
| 416 |
)))
|
| 417 |
|
| 418 |
# Launch the app with optional gradio settings
|
|
|
|
| 446 |
return gr.Checkbox(visible=True, value=False, label="Translate to English?", interactive=True)
|
| 447 |
|
| 448 |
|
|
|
|
| 449 |
parser = argparse.ArgumentParser()
|
| 450 |
parser.add_argument('--whisper_type', type=str, default="faster-whisper",
|
| 451 |
+
choices=["whisper", "faster-whisper", "insanely-fast-whisper"],
|
| 452 |
+
help='A type of the whisper implementation (Github repo name)')
|
| 453 |
parser.add_argument('--share', type=str2bool, default=False, nargs='?', const=True, help='Gradio share value')
|
| 454 |
parser.add_argument('--server_name', type=str, default=None, help='Gradio server host')
|
| 455 |
parser.add_argument('--server_port', type=int, default=None, help='Gradio server port')
|
|
|
|
| 458 |
parser.add_argument('--password', type=str, default=None, help='Gradio authentication password')
|
| 459 |
parser.add_argument('--theme', type=str, default=None, help='Gradio Blocks theme')
|
| 460 |
parser.add_argument('--colab', type=str2bool, default=False, nargs='?', const=True, help='Is colab user or not')
|
| 461 |
+
parser.add_argument('--api_open', type=str2bool, default=False, nargs='?', const=True,
|
| 462 |
+
help='Enable api or not in Gradio')
|
| 463 |
+
parser.add_argument('--inbrowser', type=str2bool, default=True, nargs='?', const=True,
|
| 464 |
+
help='Whether to automatically start Gradio app or not')
|
| 465 |
parser.add_argument('--whisper_model_dir', type=str, default=WHISPER_MODELS_DIR,
|
| 466 |
help='Directory path of the whisper model')
|
| 467 |
parser.add_argument('--faster_whisper_model_dir', type=str, default=FASTER_WHISPER_MODELS_DIR,
|