LAP-DEV commited on
Commit
733eb3f
·
verified ·
1 Parent(s): b82d94c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +84 -89
app.py CHANGED
@@ -141,96 +141,91 @@ class App:
141
  " before separating it")
142
  nb_speech_pad_ms = gr.Number(label="Speech Padding (ms)", precision=0, value=vad_params["speech_pad_ms"],
143
  info="Final speech chunks are padded by this time each side")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
 
145
- with gr.Accordion("Advanced options", open=False, visible=True):
146
- # with gr.Accordion("Advanced diarization options", open=False, visible=True):
147
- # dd_diarization_device = gr.Dropdown(label="Device",
148
- # choices=self.whisper_inf.diarizer.get_available_device(),
149
- # value=self.whisper_inf.diarizer.get_device())
150
-
151
- with gr.Accordion("Advanced processing options", open=False):
152
- nb_beam_size = gr.Number(label="Beam Size", value=whisper_params["beam_size"], precision=0, interactive=True,
153
- info="Beam size to use for decoding.")
154
- nb_log_prob_threshold = gr.Number(label="Log Probability Threshold", value=whisper_params["log_prob_threshold"], interactive=True,
155
- info="If the average log probability over sampled tokens is below this value, treat as failed.")
156
- nb_no_speech_threshold = gr.Number(label="No Speech Threshold", value=whisper_params["no_speech_threshold"], interactive=True,
157
- 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.")
158
- dd_compute_type = gr.Dropdown(label="Compute Type", choices=self.whisper_inf.available_compute_types,
159
- value=self.whisper_inf.current_compute_type, interactive=True,
160
- allow_custom_value=True,
161
- info="Select the type of computation to perform.")
162
- nb_best_of = gr.Number(label="Best Of", value=whisper_params["best_of"], interactive=True,
163
- info="Number of candidates when sampling with non-zero temperature.")
164
- nb_patience = gr.Number(label="Patience", value=whisper_params["patience"], interactive=True,
165
- info="Beam search patience factor.")
166
- cb_condition_on_previous_text = gr.Checkbox(label="Condition On Previous Text", value=whisper_params["condition_on_previous_text"],
167
- interactive=True,
168
- info="Condition on previous text during decoding.")
169
- sld_prompt_reset_on_temperature = gr.Slider(label="Prompt Reset On Temperature", value=whisper_params["prompt_reset_on_temperature"],
170
- minimum=0, maximum=1, step=0.01, interactive=True,
171
- info="Resets prompt if temperature is above this value."
172
- " Arg has effect only if 'Condition On Previous Text' is True.")
173
- tb_initial_prompt = gr.Textbox(label="Initial Prompt", value=None, interactive=True,
174
- info="Initial prompt to use for decoding.")
175
- sd_temperature = gr.Slider(label="Temperature", value=whisper_params["temperature"], minimum=0.0,
176
- step=0.01, maximum=1.0, interactive=True,
177
- 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`.")
178
- nb_compression_ratio_threshold = gr.Number(label="Compression Ratio Threshold", value=whisper_params["compression_ratio_threshold"],
179
- interactive=True,
180
- info="If the gzip compression ratio is above this value, treat as failed.")
181
- nb_chunk_length = gr.Number(label="Chunk Length (s)", value=lambda: whisper_params["chunk_length"],
182
- precision=0,
183
- info="The length of audio segments. If it is not None, it will overwrite the default chunk_length of the FeatureExtractor.")
184
- with gr.Group(visible=isinstance(self.whisper_inf, FasterWhisperInference)):
185
- nb_length_penalty = gr.Number(label="Length Penalty", value=whisper_params["length_penalty"],
186
- info="Exponential length penalty constant.")
187
- nb_repetition_penalty = gr.Number(label="Repetition Penalty", value=whisper_params["repetition_penalty"],
188
- info="Penalty applied to the score of previously generated tokens (set > 1 to penalize).")
189
- nb_no_repeat_ngram_size = gr.Number(label="No Repeat N-gram Size", value=whisper_params["no_repeat_ngram_size"],
190
- precision=0,
191
- info="Prevent repetitions of n-grams with this size (set 0 to disable).")
192
- tb_prefix = gr.Textbox(label="Prefix", value=lambda: whisper_params["prefix"],
193
- info="Optional text to provide as a prefix for the first window.")
194
- cb_suppress_blank = gr.Checkbox(label="Suppress Blank", value=whisper_params["suppress_blank"],
195
- info="Suppress blank outputs at the beginning of the sampling.")
196
- tb_suppress_tokens = gr.Textbox(label="Suppress Tokens", value=whisper_params["suppress_tokens"],
197
- info="List of token IDs to suppress. -1 will suppress a default set of symbols as defined in the model config.json file.")
198
- nb_max_initial_timestamp = gr.Number(label="Max Initial Timestamp", value=whisper_params["max_initial_timestamp"],
199
- info="The initial timestamp cannot be later than this.")
200
- cb_word_timestamps = gr.Checkbox(label="Word Timestamps", value=whisper_params["word_timestamps"],
201
- info="Extract word-level timestamps using the cross-attention pattern and dynamic time warping, and include the timestamps for each word in each segment.")
202
- tb_prepend_punctuations = gr.Textbox(label="Prepend Punctuations", value=whisper_params["prepend_punctuations"],
203
- info="If 'Word Timestamps' is True, merge these punctuation symbols with the next word.")
204
- tb_append_punctuations = gr.Textbox(label="Append Punctuations", value=whisper_params["append_punctuations"],
205
- info="If 'Word Timestamps' is True, merge these punctuation symbols with the previous word.")
206
- nb_max_new_tokens = gr.Number(label="Max New Tokens", value=lambda: whisper_params["max_new_tokens"],
207
- precision=0,
208
- info="Maximum number of new tokens to generate per-chunk. If not set, the maximum will be set by the default max_length.")
209
- nb_hallucination_silence_threshold = gr.Number(label="Hallucination Silence Threshold (sec)",
210
- value=lambda: whisper_params["hallucination_silence_threshold"],
211
- info="When 'Word Timestamps' is True, skip silent periods longer than this threshold (in seconds) when a possible hallucination is detected.")
212
- tb_hotwords = gr.Textbox(label="Hotwords", value=lambda: whisper_params["hotwords"],
213
- info="Hotwords/hint phrases to provide the model with. Has no effect if prefix is not None.")
214
- nb_language_detection_threshold = gr.Number(label="Language Detection Threshold", value=lambda: whisper_params["language_detection_threshold"],
215
- info="If the maximum probability of the language tokens is higher than this value, the language is detected.")
216
- nb_language_detection_segments = gr.Number(label="Language Detection Segments", value=lambda: whisper_params["language_detection_segments"],
217
- precision=0,
218
- info="Number of segments to consider for the language detection.")
219
- with gr.Group(visible=isinstance(self.whisper_inf, InsanelyFastWhisperInference)):
220
- nb_batch_size = gr.Number(label="Batch Size", value=whisper_params["batch_size"], precision=0)
221
-
222
- with gr.Accordion("Background Music Remover Filter", open=False):
223
- cb_bgm_separation = gr.Checkbox(label="Enable Background Music Remover Filter", value=uvr_params["is_separate_bgm"],
224
- interactive=True,
225
- info="Enabling this will remove background music by submodel before transcribing.")
226
- dd_uvr_device = gr.Dropdown(label="Device", value=self.whisper_inf.music_separator.device,
227
- choices=self.whisper_inf.music_separator.available_devices)
228
- dd_uvr_model_size = gr.Dropdown(label="Model", value=uvr_params["model_size"],
229
- choices=self.whisper_inf.music_separator.available_models)
230
- nb_uvr_segment_size = gr.Number(label="Segment Size", value=uvr_params["segment_size"], precision=0)
231
- cb_uvr_save_file = gr.Checkbox(label="Save separated files to output", value=uvr_params["save_file"])
232
- cb_uvr_enable_offload = gr.Checkbox(label="Offload sub model after removing background music",
233
- value=uvr_params["enable_offload"])
234
 
235
 
236
  #dd_model.change(fn=self.on_change_models, inputs=[dd_model], outputs=[cb_translate])
 
141
  " before separating it")
142
  nb_speech_pad_ms = gr.Number(label="Speech Padding (ms)", precision=0, value=vad_params["speech_pad_ms"],
143
  info="Final speech chunks are padded by this time each side")
144
+
145
+
146
+ with gr.Accordion("Background Music Remover Filter", open=False):
147
+ cb_bgm_separation = gr.Checkbox(label="Enable Background Music Remover Filter", value=uvr_params["is_separate_bgm"],
148
+ interactive=True,
149
+ info="Enabling this will remove background music by submodel before transcribing")
150
+ dd_uvr_device = gr.Dropdown(label="Device", value=self.whisper_inf.music_separator.device,
151
+ choices=self.whisper_inf.music_separator.available_devices)
152
+ dd_uvr_model_size = gr.Dropdown(label="Model", value=uvr_params["model_size"],
153
+ choices=self.whisper_inf.music_separator.available_models)
154
+ nb_uvr_segment_size = gr.Number(label="Segment Size", value=uvr_params["segment_size"], precision=0)
155
+ cb_uvr_save_file = gr.Checkbox(label="Save separated files to output", value=uvr_params["save_file"])
156
+ cb_uvr_enable_offload = gr.Checkbox(label="Offload sub model after removing background music",
157
+ value=uvr_params["enable_offload"])
158
 
159
+ with gr.Accordion("Advanced processing options", open=False, visible=False):
160
+ nb_beam_size = gr.Number(label="Beam Size", value=whisper_params["beam_size"], precision=0, interactive=True,
161
+ info="Beam size to use for decoding.")
162
+ nb_log_prob_threshold = gr.Number(label="Log Probability Threshold", value=whisper_params["log_prob_threshold"], interactive=True,
163
+ info="If the average log probability over sampled tokens is below this value, treat as failed.")
164
+ nb_no_speech_threshold = gr.Number(label="No Speech Threshold", value=whisper_params["no_speech_threshold"], interactive=True,
165
+ 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.")
166
+ dd_compute_type = gr.Dropdown(label="Compute Type", choices=self.whisper_inf.available_compute_types,
167
+ value=self.whisper_inf.current_compute_type, interactive=True,
168
+ allow_custom_value=True,
169
+ info="Select the type of computation to perform.")
170
+ nb_best_of = gr.Number(label="Best Of", value=whisper_params["best_of"], interactive=True,
171
+ info="Number of candidates when sampling with non-zero temperature.")
172
+ nb_patience = gr.Number(label="Patience", value=whisper_params["patience"], interactive=True,
173
+ info="Beam search patience factor.")
174
+ cb_condition_on_previous_text = gr.Checkbox(label="Condition On Previous Text", value=whisper_params["condition_on_previous_text"],
175
+ interactive=True,
176
+ info="Condition on previous text during decoding.")
177
+ sld_prompt_reset_on_temperature = gr.Slider(label="Prompt Reset On Temperature", value=whisper_params["prompt_reset_on_temperature"],
178
+ minimum=0, maximum=1, step=0.01, interactive=True,
179
+ info="Resets prompt if temperature is above this value."
180
+ " Arg has effect only if 'Condition On Previous Text' is True.")
181
+ tb_initial_prompt = gr.Textbox(label="Initial Prompt", value=None, interactive=True,
182
+ info="Initial prompt to use for decoding.")
183
+ sd_temperature = gr.Slider(label="Temperature", value=whisper_params["temperature"], minimum=0.0,
184
+ step=0.01, maximum=1.0, interactive=True,
185
+ 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`.")
186
+ nb_compression_ratio_threshold = gr.Number(label="Compression Ratio Threshold", value=whisper_params["compression_ratio_threshold"],
187
+ interactive=True,
188
+ info="If the gzip compression ratio is above this value, treat as failed.")
189
+ nb_chunk_length = gr.Number(label="Chunk Length (s)", value=lambda: whisper_params["chunk_length"],
190
+ precision=0,
191
+ info="The length of audio segments. If it is not None, it will overwrite the default chunk_length of the FeatureExtractor.")
192
+ with gr.Group(visible=isinstance(self.whisper_inf, FasterWhisperInference)):
193
+ nb_length_penalty = gr.Number(label="Length Penalty", value=whisper_params["length_penalty"],
194
+ info="Exponential length penalty constant.")
195
+ nb_repetition_penalty = gr.Number(label="Repetition Penalty", value=whisper_params["repetition_penalty"],
196
+ info="Penalty applied to the score of previously generated tokens (set > 1 to penalize).")
197
+ nb_no_repeat_ngram_size = gr.Number(label="No Repeat N-gram Size", value=whisper_params["no_repeat_ngram_size"],
198
+ precision=0,
199
+ info="Prevent repetitions of n-grams with this size (set 0 to disable).")
200
+ tb_prefix = gr.Textbox(label="Prefix", value=lambda: whisper_params["prefix"],
201
+ info="Optional text to provide as a prefix for the first window.")
202
+ cb_suppress_blank = gr.Checkbox(label="Suppress Blank", value=whisper_params["suppress_blank"],
203
+ info="Suppress blank outputs at the beginning of the sampling.")
204
+ tb_suppress_tokens = gr.Textbox(label="Suppress Tokens", value=whisper_params["suppress_tokens"],
205
+ info="List of token IDs to suppress. -1 will suppress a default set of symbols as defined in the model config.json file.")
206
+ nb_max_initial_timestamp = gr.Number(label="Max Initial Timestamp", value=whisper_params["max_initial_timestamp"],
207
+ info="The initial timestamp cannot be later than this.")
208
+ cb_word_timestamps = gr.Checkbox(label="Word Timestamps", value=whisper_params["word_timestamps"],
209
+ info="Extract word-level timestamps using the cross-attention pattern and dynamic time warping, and include the timestamps for each word in each segment.")
210
+ tb_prepend_punctuations = gr.Textbox(label="Prepend Punctuations", value=whisper_params["prepend_punctuations"],
211
+ info="If 'Word Timestamps' is True, merge these punctuation symbols with the next word.")
212
+ tb_append_punctuations = gr.Textbox(label="Append Punctuations", value=whisper_params["append_punctuations"],
213
+ info="If 'Word Timestamps' is True, merge these punctuation symbols with the previous word.")
214
+ nb_max_new_tokens = gr.Number(label="Max New Tokens", value=lambda: whisper_params["max_new_tokens"],
215
+ precision=0,
216
+ info="Maximum number of new tokens to generate per-chunk. If not set, the maximum will be set by the default max_length.")
217
+ nb_hallucination_silence_threshold = gr.Number(label="Hallucination Silence Threshold (sec)",
218
+ value=lambda: whisper_params["hallucination_silence_threshold"],
219
+ info="When 'Word Timestamps' is True, skip silent periods longer than this threshold (in seconds) when a possible hallucination is detected.")
220
+ tb_hotwords = gr.Textbox(label="Hotwords", value=lambda: whisper_params["hotwords"],
221
+ info="Hotwords/hint phrases to provide the model with. Has no effect if prefix is not None.")
222
+ nb_language_detection_threshold = gr.Number(label="Language Detection Threshold", value=lambda: whisper_params["language_detection_threshold"],
223
+ info="If the maximum probability of the language tokens is higher than this value, the language is detected.")
224
+ nb_language_detection_segments = gr.Number(label="Language Detection Segments", value=lambda: whisper_params["language_detection_segments"],
225
+ precision=0,
226
+ info="Number of segments to consider for the language detection.")
227
+ with gr.Group(visible=isinstance(self.whisper_inf, InsanelyFastWhisperInference)):
228
+ nb_batch_size = gr.Number(label="Batch Size", value=whisper_params["batch_size"], precision=0)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
 
230
 
231
  #dd_model.change(fn=self.on_change_models, inputs=[dd_model], outputs=[cb_translate])